LangChain & LlamaIndex
⭐ New in 1.3 — Give the agent you already have a body. Ghost ships first-class adapters for LangChain and LlamaIndex: every on-device tool (tap, type_text, launch_app, get_screen_tree, find_on_screen, screenshots, OCR, …) becomes a native tool in your framework. No rewrite, no separate runner.
Ghost’s core never imports these adapters — the framework dependencies are optional extras, so installing Ghost doesn’t pull LangChain or LlamaIndex unless you ask for them.
LangChain
Section titled “LangChain”pip install "ghost-in-the-droid[langchain]"from langchain.chat_models import init_chat_modelfrom langgraph.prebuilt import create_react_agentfrom integrations.langchain import ghost_langchain_tools
tools = ghost_langchain_tools("emulator-5554") # bound to one deviceagent = create_react_agent(init_chat_model("anthropic:claude-sonnet-4"), tools)
agent.invoke({"messages": "Open Settings and turn on Wi-Fi"})# → the agent taps its way through the real phoneEvery tool Ghost exposes is now a LangChain tool the agent can call, so it slots straight into LangGraph or any existing LangChain agent loop.
LlamaIndex
Section titled “LlamaIndex”pip install "ghost-in-the-droid[llamaindex]"from llama_index.core.agent.workflow import FunctionAgentfrom llama_index.llms.anthropic import Anthropicfrom integrations.llamaindex import ghost_llamaindex_tools
tools = ghost_llamaindex_tools("emulator-5554")agent = FunctionAgent(tools=tools, llm=Anthropic(model="claude-sonnet-4"))
await agent.run("Open the camera and take a selfie")The tools arrive as native LlamaIndex FunctionTools, usable in a FunctionAgent or any LlamaIndex workflow.
Fallback: point any MCP agent at Ghost
Section titled “Fallback: point any MCP agent at Ghost”Both frameworks also speak MCP, so you can skip the adapters entirely and connect to Ghost’s MCP server directly:
python3 -m gitd.mcp_server # serves MCP at http://127.0.0.1:8002/mcpThen register that endpoint with your framework’s MCP client — langchain-mcp-adapters for LangChain, or McpToolSpec for LlamaIndex. See the MCP Clients matrix for every other client that can drive Ghost the same way.
Two things worth knowing
Section titled “Two things worth knowing”- Device binding is locked. The serial is bound when you build the toolset (
ghost_langchain_tools("emulator-5554")), so the agent never has to pass adeviceargument — and a bound serial can’t be overridden by a tool call. One toolset drives exactly one phone. - Dangerous tools are opt-in. The raw
shellandrun_skilltools are excluded by default. Passinclude_dangerous=Truetoghost_langchain_tools/ghost_llamaindex_toolsif you actually want them.
When to use which
Section titled “When to use which”| You want… | Use |
|---|---|
| Ghost tools inside an existing LangChain / LlamaIndex agent | the adapters above |
| To drive Ghost from another MCP client (Claude Code, Cursor, …) | the MCP server + MCP Clients |
| A quick one-device script with no framework | Ghost’s own agent chat |
Related
Section titled “Related”- MCP Server — the same tools, exposed over MCP
- MCP Clients — every client that can drive Ghost
- ADB Device Control — the device layer these tools wrap
- How Ghost Compares — where the framework-adapter story fits vs alternatives