mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
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:
27
testutil/json.go
Normal file
27
testutil/json.go
Normal file
@ -0,0 +1,27 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
// RequireJSONEq is like assert.RequireJSONEq, but it's actually readable.
|
||||
// Note that this calls t.Fatalf under the hood, so it should never
|
||||
// be called in a goroutine.
|
||||
func RequireJSONEq(t *testing.T, expected, actual string) {
|
||||
t.Helper()
|
||||
|
||||
var expectedJSON, actualJSON any
|
||||
if err := json.Unmarshal([]byte(expected), &expectedJSON); err != nil {
|
||||
t.Fatalf("failed to unmarshal expected JSON: %s", err)
|
||||
}
|
||||
if err := json.Unmarshal([]byte(actual), &actualJSON); err != nil {
|
||||
t.Fatalf("failed to unmarshal actual JSON: %s", err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(expectedJSON, actualJSON); diff != "" {
|
||||
t.Fatalf("JSON diff (-want +got):\n%s", diff)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user