-
Notifications
You must be signed in to change notification settings - Fork 81
Description
The Claude Code module MCP server setup via the mcp var produces an invalid MCP config. Here's how the README says to specify MCP servers:
module "claude-code" {
source = "registry.coder.com/coder/claude-code/coder"
version = "4.2.1"
agent_id = coder_agent.example.id
workdir = "/home/coder/project"
claude_api_key = "xxxx-xxxxx-xxxx"
# OR
claude_code_oauth_token = "xxxxx-xxxx-xxxx"
mcp = <<-EOF
{
"mcpServers": {
"my-custom-tool": {
"command": "my-tool-server"
"args": ["--port", "8080"]
}
}
}
EOF
}Rather than just patching the .claude.json config file, this attempts to load the config via claude mcp add, after splitting each tool into key value pairs. The actual command executes in this case is claude mcp add 'my-custom-tool' '{"command": "my-tool-server", "args": ["--port", "8080"]}. The CLI treats this JSON string as a command, producing this MCP config:
{
"mcpServers": {
"type": "stdio"
"command": "{\"command\": \"my-tool-server\", \"args\": [\"--port\", \"8080\"]}",
"args": [],
"env": {}
}
}It should produce:
{
"mcpServers": {
"type": "stdio"
"command": "my-tool-server",
"args": ["--port", "8080"],
"env": {}
}
}Even if this somehow worked (e.g. if the code was updated to parse this prior to calling claude mcp add), it wouldn't handle remote MCP servers.
This can be way simplified - just use jq to merge the and/or set the MCP server key within the claude code config.