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