π Hello World β LangChain
Ghost tools inside a LangChain agent. In the video, a LangChain agent harvests subreddits into SQLite β the phone does the browsing, the framework does the orchestrating.
Prerequisites
Section titled βPrerequisitesβ- A phone connected over ADB with USB debugging on (
adb devicesshows it) - Python 3.11+ and an Anthropic (or other LangChain-supported) API key
Step 1 β Install with the LangChain extra
Section titled βStep 1 β Install with the LangChain extraβpip install "ghost-in-the-droid[langchain]"Ghostβs core never imports the adapter β the framework dependency is an optional extra, so plain installs stay lean.
Step 2 β Give your agent a body
Section titled βStep 2 β Give your agent a bodyβ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 Ghost tool (tap, type_text, launch_app, get_screen_tree, find_on_screen, screenshots, OCR, β¦) arrives as a native LangChain tool, so it slots straight into LangGraph or any existing agent loop.
Step 3 β Verify
Section titled βStep 3 β VerifyβSwap the prompt for something observable:
agent.invoke({"messages": "Read the top post on r/LocalLLaMA in the Reddit app and summarize it"})The video runs exactly this pattern in a loop β five harvests, results written to a local SQLite table.
Two things worth knowing
Section titled βTwo things worth knowingβ- Device binding is locked. The serial you pass to
ghost_langchain_tools(...)canβt be overridden by a tool call β one toolset drives exactly one phone. - Dangerous tools are opt-in. Raw
shellandrun_skillare excluded unless you passinclude_dangerous=True. The allow-list fails closed.
What next?
Section titled βWhat next?β- LangChain & LlamaIndex β full adapter docs, incl. the LlamaIndex twin
- MCP Server β skip the adapter, point any MCP client at Ghost
- Skill System β reusable automations your agent can invoke
Try another approach β
Section titled βTry another approach ββMCP + Claude Code Β· MCP + Codex Β· MCP + Antigravity Β· Ghost CLI Β· Web Chat Β· On-Device Android Β· On-Device iPhone Β· iPhone Duolingo