feat(cli): add coder exp mcp command (#17066)

Adds a `coder exp mcp` command which will start a local MCP server
listening on stdio with the following capabilities:
* Show logged in user (`coder whoami`)
* List workspaces (`coder list`)
* List templates (`coder templates list`)
* Start a workspace (`coder start`)
* Stop a workspace (`coder stop`)
* Fetch a single workspace (no direct CLI analogue)
* Execute a command inside a workspace (`coder exp rpty`)
* Report the status of a task (currently a no-op, pending task support)

This can be tested as follows:

```
# Start a local Coder server.
./scripts/develop.sh
# Start a workspace. Currently, creating workspaces is not supported.
./scripts/coder-dev.sh create -t docker --yes
# Add the MCP to your Claude config.
claude mcp add coder ./scripts/coder-dev.sh exp mcp
# Tell Claude to do something Coder-related. You may need to nudge it to use the tools.
claude 'start a docker workspace and tell me what version of python is installed'
```
This commit is contained in:
Cian Johnston
2025-03-31 18:52:09 +01:00
committed by GitHub
parent 8ea956fc11
commit 057cbd4d80
9 changed files with 1469 additions and 5 deletions
+4
View File
@@ -480,3 +480,7 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
)
require github.com/mark3labs/mcp-go v0.17.0
require github.com/yosida95/uritemplate/v3 v3.0.2 // indirect