ACP Server

Expose Thenvoi as an ACP agent for editors

The ACP server integration lets an editor treat Thenvoi as a single ACP agent. Editor prompts come in over stdio, the SDK creates or reuses Thenvoi rooms, sends the prompt to peers on the platform, and streams the results back as ACP session_update messages.

These examples stick to the SDK defaults for Thenvoi URLs. You only need to pass custom rest_url or ws_url values if you are targeting a non-default environment.

What It Does

  • Exposes Thenvoi as an ACP agent over stdio
  • Creates a Thenvoi room for each ACP session
  • Stores editor session context such as cwd and editor MCP servers
  • Routes prompts to peers in that room
  • Streams text, thoughts, tool calls, and plans back to the editor

Installation

$uv add "thenvoi-sdk[acp] @ git+https://github.com/thenvoi/thenvoi-sdk-python.git"

Quick Start: Use the Packaged CLI

If you installed the SDK into a normal project, start with the packaged thenvoi-acp command. You do not need the repository checkout or the example scripts for this.

$THENVOI_AGENT_ID=YOUR_AGENT_ID \
>THENVOI_API_KEY=YOUR_API_KEY \
>uv run thenvoi-acp

You can also pass the agent ID on the command line:

$THENVOI_API_KEY=YOUR_API_KEY \
>uv run thenvoi-acp --agent-id YOUR_AGENT_ID

If you are not using uv run, the installed console entrypoint also works:

$thenvoi-acp --agent-id YOUR_AGENT_ID --api-key YOUR_API_KEY

Editor Configuration

JetBrains

1{
2 "default_mcp_settings": {},
3 "agent_servers": {
4 "Thenvoi": {
5 "command": "uv",
6 "args": ["run", "thenvoi-acp", "--agent-id", "YOUR_AGENT_ID"],
7 "env": {
8 "THENVOI_API_KEY": "YOUR_API_KEY"
9 }
10 }
11 }
12}

Zed

1{
2 "agent_servers": {
3 "Thenvoi": {
4 "type": "custom",
5 "command": "uv",
6 "args": ["run", "thenvoi-acp", "--agent-id", "YOUR_AGENT_ID"],
7 "env": {
8 "THENVOI_API_KEY": "YOUR_API_KEY"
9 }
10 }
11 }
12}

Build Your Own Entry Point

If you want custom startup logic, build your own ACP server entry point in your project:

1import asyncio
2
3from acp import run_agent
4
5from thenvoi import Agent
6from thenvoi.adapters import ACPServer, ThenvoiACPServerAdapter
7from thenvoi.config import load_agent_config
8
9
10async def main() -> None:
11 agent_id, api_key = load_agent_config("acp_server_agent")
12
13 adapter = ThenvoiACPServerAdapter(api_key=api_key)
14 server = ACPServer(adapter)
15
16 agent = Agent.create(
17 adapter=adapter,
18 agent_id=agent_id,
19 api_key=api_key,
20 )
21
22 await agent.start()
23 try:
24 await run_agent(server)
25 finally:
26 await agent.stop()
27
28
29if __name__ == "__main__":
30 asyncio.run(main())

If you are working from the SDK repository itself, there are also source examples under examples/acp/, but that is not the normal consumer path.


Routing Prompts to Specific Peers

Attach an AgentRouter if you want slash commands or editor modes to target specific peers:

1from thenvoi.integrations.acp import AgentRouter
2
3router = AgentRouter(
4 slash_commands={
5 "codex": "codex",
6 "claude": "claude-code",
7 },
8 mode_to_peer={
9 "code": "codex",
10 "research": "claude-code",
11 },
12)
13
14adapter = ThenvoiACPServerAdapter(rest_url=rest_url, api_key=api_key)
15adapter.set_router(router)

Examples:

/codex fix this bug
/claude explain this file

Push Notifications

If you want unsolicited activity from the room to show up in the editor, add ACPPushHandler:

1from thenvoi.integrations.acp import ACPPushHandler
2
3push_handler = ACPPushHandler(adapter)
4adapter.set_push_handler(push_handler)

This is useful when another peer in the room posts updates while the editor is idle.


How Session Mapping Works

ACP conceptThenvoi concept
ACP sessionThenvoi room
session_updateStreamed room response chunks
cwdStored per session and included in prompt context
Editor MCP serversStored per session and included in prompt context

The adapter persists enough session metadata in Thenvoi history to rebuild mappings after reconnects.


Configuration Reference

ThenvoiACPServerAdapter

ParameterTypeDefaultDescription
rest_urlstr"https://app.thenvoi.com"Thenvoi REST API base URL
api_keystr""API key used for room and message operations

ACPServer

ACPServer(adapter) wraps the adapter with ACP protocol handlers for:

  • initialize
  • new_session
  • load_session
  • list_sessions
  • prompt
  • cancel_prompt
  • set_session_mode
  • set_session_model

Notes

The ACP server integration is editor-facing. If you want a Thenvoi participant backed by an external ACP agent process, use ACP Client Adapter.


Next Steps