mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add Coder Agents chat tools to the MCP toolsdk (#28025)
Exposes the experimental Coder Agents chats API through the MCP tool registry, so MCP clients (the hosted `/api/experimental/mcp/http` server and `coder exp mcp server`) can start and drive server-side coding agents. New tools in `codersdk/toolsdk`, all thin wrappers over existing `codersdk.ExperimentalClient` methods: | Tool | Wraps | |---|---| | `coder_create_chat` | `CreateChat` (prompt, optional org, model config, labels) | | `coder_get_chat` | `GetChat` (status, last error, last turn summary, workspace, files) | | `coder_get_chat_messages` | `GetChatMessages` (user-facing parts, chronological, cursor pagination, queued prompts) | | `coder_send_chat_message` | `CreateChatMessage` (queue or interrupt busy behavior) | | `coder_interrupt_chat` | `InterruptChat` | | `coder_archive_chat` | `UpdateChat` with `archived: true` | | `coder_list_chat_model_configs` | `ListChatModelConfigs` (enabled configs with default flag) | Both MCP servers register tools from `toolsdk.All`, so no additional wiring is needed. Responses are trimmed to what an MCP caller needs (IDs as strings, user-facing transcripts) rather than full SDK payloads. No new endpoints and no database changes. Also adds MCP [prompts](https://modelcontextprotocol.io/specification/2026-07-28/server/prompts) for the chat workflows, defined once in `codersdk/toolsdk` and registered by both servers: | Prompt | Purpose | |---|---| | `coder_agents_delegate` | delegate a task to a Coder Agents chat and monitor it to completion | | `coder_agents_check` | check the status and recent activity of an existing chat | Each prompt declares the tools its workflow needs; the stdio server skips prompts whose tools are excluded by `--allowed-tools`. Tests run the tools against a chat-enabled coderdtest instance (fake OpenAI-compatible provider plus in-process AI bridge), covering the full lifecycle, an interrupt against a blocked turn, pagination cursors, permission-dependent model config filtering, and argument validation. Prompt coverage spans SDK rendering, the hosted `prompts/list`/`prompts/get` round trip, and the stdio server including allowlist gating. > Mux created this PR on Mike's behalf.
This commit is contained in:
@@ -199,6 +199,7 @@ The MCP server exposes tools across several areas:
|
||||
- **File operations**: read, write, and edit files in a workspace
|
||||
- **Workspace interaction**: run commands, forward ports, list apps, and read logs
|
||||
- **Task management**: create, list, inspect, and control tasks
|
||||
- **Coder Agents chats**: create chats, send messages, read transcripts and status, interrupt, archive, and list available models
|
||||
- **User and system**: authenticated user details, tar uploads, and task reporting
|
||||
|
||||
The full, authoritative set of tools, including their names, descriptions, and
|
||||
@@ -206,6 +207,18 @@ arguments, is defined in Coder's
|
||||
[`toolsdk` package](../../codersdk/toolsdk/toolsdk.go). Refer to it for the
|
||||
current list, since the available tools can change between releases.
|
||||
|
||||
## Available Prompts
|
||||
|
||||
The MCP server also exposes
|
||||
[prompts](https://modelcontextprotocol.io/specification/2026-07-28/server/prompts)
|
||||
for common Coder Agents chat workflows. Clients that support prompts surface
|
||||
them for you to invoke, for example as slash commands:
|
||||
|
||||
- `coder_agents_delegate`: delegate a coding task to a Coder Agents chat and
|
||||
monitor it to completion
|
||||
- `coder_agents_check`: check the status and recent activity of an existing
|
||||
Coder Agents chat
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Unauthorized" errors
|
||||
|
||||
Reference in New Issue
Block a user