Start from another agent
Every runner is also an MCP server. From any client that speaks the Model Context Protocol, you can start a thread, a factory or a loop on Threadrun without leaving your session, then keep the conversation there: reply to the agent, read its answer and steer it. Work started inside a project runs on that project's repository.
This page shows where to find the address and key, how to add the server to a client, how to talk to a thread from the CLI, and how to install the Threadrun skill that makes the hand-off reliable.
The address and key
Open Settings → Runners, open a runner's Access tab. A runner that is running or installed has a Start work from other agents section with:
- MCP URL: the address a client connects to.
- MCP key: a key derived from the runner's access token. It can start work, reply to it and read it, but it can't change the runner's settings, policy or team. It stays the same across restarts.
On this computer the address is:
http://127.0.0.1:8787/agent/mcp
On a server, use the HTTPS address the card shows when phone access is on. With phone access off, the runner listens only on the server's loopback address: forward it from a terminal on your computer and use the same local address.
ssh -N -L 8787:127.0.0.1:8787 you@your-server
Keep that command running while the other agent uses Threadrun.
Add the server
Add a remote MCP server to your client, using the URL and key from the runner's card:
- Transport: streamable HTTP
- URL: the MCP URL from the card, such as
https://178-62-201-159.nip.io/agent/mcp - Header:
Authorization: Bearer <key>
A client that takes a JSON entry accepts this shape (the field names depend on the client):
{
"type": "remote",
"url": "https://178-62-201-159.nip.io/agent/mcp",
"headers": { "Authorization": "Bearer trmcp_…" }
}
A client with an add command takes the same URL and header. Check the client's server list before asking for work, and keep the entry in the project you want the work to run on when the client stores servers per project.
Keep talking in the CLI
The first request starts the thread. To read the first answer, call read_thread with the thread id, after: 0 and wait_seconds; it returns the conversation when the turn ends. To continue it, the client calls reply with the thread id and the next message. reply waits for the agent's turn to end and returns the conversation, so the CLI can show the answer and take the next instruction:
{
"thread": "t-1a1c455e64b",
"complete": true,
"state": "Idle",
"messages": [
{ "role": "you", "text": "Also handle empty text." },
{ "role": "agent", "text": "Done: readingTime(\"\") returns 0, with a test. Tests still pass." },
{ "role": "turn", "text": "done" }
],
"next": 42
}
- **
messages** is only the conversation:you,agent,error,approval,permissionandturn. Tool calls and logs stay out;thread_statushas those. - **
complete: false** means the turn was still running afterwait_seconds(default 30, at most 120). Callread_threadwithafterset tonextand a newwait_secondsfor the rest. - **
waiting_for: "approval"or"permission"** means a person must answer in Threadrun or its web app. Answering there lets the turn continue;replythen reports the rest. - **
read_thread** withafter: 0shows the latest conversation. Withafter: nextit shows only what came later, and withwait_secondsit waits for the agent before answering.
Use send_prompt instead of reply when the work is long and you don't want to hold the CLI: it sends and returns at once, and read_thread reads progress when the user asks.
After the first request, ask the client to reply on the thread id it reported; the conversation stays in that thread.
Which project the work runs on
A client can't see your project through MCP. To make the hand-off inherit the project, the agent passes the repository with the call. The Threadrun skill tells it to run git remote get-url origin in the current project and pass the result as repo. Threadrun then gives the agents their own clone of that repository on the runner.
https://github.com/owner/repo.gitandowner/repoboth work.- A local checkout path also works when it is on the runner itself: Threadrun reads its
originremote. - Without
repo, the work has no repository. That is only right when the task doesn't touch code.
If your client can't use skills, you can set the project once in the server URL instead:
http://127.0.0.1:8787/agent/mcp?repo=owner/repo
harness=codex (or opencode, gemini, pi, omp, vibe) sets the default agent for that entry too.
Install the Threadrun skill
The skill is a short instruction file. It tells an agent when to use Threadrun, to pass the project's Git remote, how to shape a factory, how to keep the conversation going with reply and read_thread, and to stop at a pending approval instead of polling.
The skill is published for skills.sh, the open Agent Skills directory, so its CLI installs it and keeps it updated:
npx skills add https://threadrun.dev --skill threadrun
It asks which agents to install for. Add -g to make it available in every project.
Without skills.sh, download the same file and save it as SKILL.md in the folder your agent searches for skills:
| Client | Folder |
|---|---|
| OpenCode | ~/.config/opencode/skills/threadrun/SKILL.md |
| Claude Code | ~/.claude/skills/threadrun/SKILL.md |
| Codex | ~/.codex/skills/threadrun/SKILL.md |
Some clients also read a project's own skills folder, such as .opencode/skills/threadrun/SKILL.md; a project skill works too. The skill only governs when the model should call the MCP tools; the tools work without it.
The tools
| Tool | What it does |
|---|---|
runner_info | The runner's name, version, location, agents and how many are working. |
list_threads | Threads and factory runs, newest first, optionally by state. |
start_thread | One agent in its own sandbox and branch: prompt, repo, and optional harness, model, effort, mode. |
reply | Send a prompt and wait for the agent's answer; returns the conversation and the next cursor. |
read_thread | The conversation without tool noise, optionally waiting for the turn to finish. |
send_prompt | Send a prompt without waiting, for long work; read progress with read_thread. |
thread_status | A thread's or run's state, cost, tokens and latest events, including tools. |
cancel_thread | Stop the agent working in a thread. |
start_factory | A run of stages, with goal, repo, optional stages, limits and approval gates. |
list_loops | Saved loops with their triggers and recent runs. |
run_loop | Start a saved loop now, by name or id. |
create_loop | Save a loop (interval, cron, webhook or manual), optionally starting it now. |
memory_write | Remember a durable fact about you (a preference, a person, a project, a decision), with the conversation it came from. |
memory_search | Recall remembered facts by keyword and recency. |
memory_delete | Forget a fact by its id. |
Agents working in a thread also get two per-thread servers: threadrun-memory with the three memory tools, and threadrun-threads with convert_thread_to_loop (below).
A factory stage is an object with name, instructions, and optionally harness, model, effort, after, approval and spawn. Without stages, one agent does the goal.
Remember and recall
A runner keeps a small long-term memory of facts an agent writes with memory_write, each with the conversation it came from and a timestamp. memory_search returns the ones matching every keyword, newest first, so a client can recall what you told it before instead of asking again. The text is encrypted at rest with the runner's storage key, so it stays on your runner; memory_delete forgets a fact when you ask.
Agents working in a thread also get memory_write, memory_search and memory_delete from threadrun-memory; the server fills in the thread as the source. When you ask one to remember something, it writes a fact to the runner's memory instead of adding a line to the project's AGENTS.md. It is told to ask first when it isn't clear whether you mean a project instruction or a fact about you.
Turn a thread into a loop
Agents working in a thread get convert_thread_to_loop from a second server, threadrun-threads, apart from the memory tools. Ask an agent to turn the conversation into recurring work ("convert this thread to a loop", "run this every morning") and it saves a loop with this thread's repository, agent and options, on the schedule you name. The loop runs as an ordinary factory run, so approvals, budgets and the audit log apply.
The tool only exists inside a thread; a client calling the runner's MCP server from outside uses create_loop instead. See Loops.
See and forget what agents remember
Open Memory in the app's sidebar. It lists every fact, newest first, with the conversation it came from. Only an admin sees it.
- Type in Search facts and conversations to filter the list.
- Click a conversation under a fact to open it.
- Forget removes a fact after you confirm; agents won't recall it again.
- Refresh picks up facts written since the page opened.
A thread's own memory is its conversation, shown in the thread; its context meter says how full it is. See Threads.
What stays true
- Same isolation, governance and budgets. Work started from another agent is a normal thread or run: its own container, clone and branch, the runner's policy, approval gates, spend limits and the hash-chained history.
- Approvals wait for a person. A stage with an approval gate, or an agent asking for permission, waits until someone answers in Threadrun or its web app.
replyreturnswaiting_forinstead of waiting silently, andthread_statusshows the details. - The key can't administer the runner. Changing the policy, team, logins or settings still needs the app or the runner's admin token.
- Costs are the same. You pay your model provider and your server provider directly. A loop's caps apply to runs started through MCP too.
Troubleshooting
- 401 Unauthorized: the header isn't
Authorization: Bearer <key>, or the runner's token changed. Copy the key from the card again. - Connection refused on a server: phone access is off and the SSH forward isn't running, or it points at another machine.
- **
replyreturnscomplete: false:** the turn is still running. Callread_threadwithafter=nextandwait_seconds, or usesend_promptand read later. Nothing is lost; the agent keeps working on the runner. - **The client times out during
reply:** lowerwait_secondsfor that client, or configure a longer tool timeout. The turn continues on the runner either way. - "This is too big": nothing to do with MCP; that message is the desktop app's.
- The agent starts work on the wrong repository: install the skill, or put
?repo=owner/repoin the server URL, and tell the agent which project the task is for.