From dd412fbf343acdd9985014a75177ac3d9896f0d5 Mon Sep 17 00:00:00 2001 From: DevCats Date: Tue, 25 Nov 2025 12:44:12 -0500 Subject: [PATCH] fix(claude-code): change mcp add command to use mcp add-json instead (#564) ## Description changes the `claude-code mcp add` command to `claude-code mcp add-json` instead, and updates usage examples with real world mcp server example. ## Type of Change - [ ] New module - [ ] New template - [X] Bug fix - [ ] Feature/enhancement - [ ] Documentation - [ ] Other ## Module Information **Path:** `registry/coder/modules/claude-code` **New version:** `v4.2.2` **Breaking change:** [ ] Yes [X] No ## Testing & Validation - [X] Tests pass (`bun test`) - [X] Code formatted (`bun fmt`) - [X] Changes tested locally ## Related Issues #562 --- registry/coder/modules/claude-code/README.md | 22 ++++++++++--------- .../modules/claude-code/scripts/install.sh | 17 ++++++++------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/registry/coder/modules/claude-code/README.md b/registry/coder/modules/claude-code/README.md index c787c832..516b5748 100644 --- a/registry/coder/modules/claude-code/README.md +++ b/registry/coder/modules/claude-code/README.md @@ -13,7 +13,7 @@ Run the [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_api_key = "xxxx-xxxxx-xxxx" @@ -51,7 +51,7 @@ module "claude-code" { boundary_log_level = "WARN" boundary_additional_allowed_urls = ["GET *google.com"] boundary_proxy_port = "8087" - version = "4.2.1" + version = "4.2.2" } ``` @@ -70,7 +70,7 @@ data "coder_parameter" "ai_prompt" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" @@ -89,9 +89,11 @@ module "claude-code" { mcp = <<-EOF { "mcpServers": { - "my-custom-tool": { - "command": "my-tool-server" - "args": ["--port", "8080"] + "memory": { + "type": "stdio", + "command": "npx", + "args": ["-y", "@modelcontextprotocol/server-memory"], + "env": {} } } } @@ -106,7 +108,7 @@ Run and configure Claude Code as a standalone CLI in your workspace. ```tf module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder" install_claude_code = true @@ -129,7 +131,7 @@ variable "claude_code_oauth_token" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" claude_code_oauth_token = var.claude_code_oauth_token @@ -202,7 +204,7 @@ resource "coder_env" "bedrock_api_key" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" model = "global.anthropic.claude-sonnet-4-5-20250929-v1:0" @@ -259,7 +261,7 @@ resource "coder_env" "google_application_credentials" { module "claude-code" { source = "registry.coder.com/coder/claude-code/coder" - version = "4.2.1" + version = "4.2.2" agent_id = coder_agent.example.id workdir = "/home/coder/project" model = "claude-sonnet-4@20250514" diff --git a/registry/coder/modules/claude-code/scripts/install.sh b/registry/coder/modules/claude-code/scripts/install.sh index 80f84e6d..8aa0d1ac 100644 --- a/registry/coder/modules/claude-code/scripts/install.sh +++ b/registry/coder/modules/claude-code/scripts/install.sh @@ -68,13 +68,16 @@ function setup_claude_configurations() { mkdir -p "$module_path" if [ "$ARG_MCP" != "" ]; then - while IFS= read -r server_name && IFS= read -r server_json; do - echo "------------------------" - echo "Executing: claude mcp add \"$server_name\" '$server_json'" - claude mcp add "$server_name" "$server_json" - echo "------------------------" - echo "" - done < <(echo "$ARG_MCP" | jq -r '.mcpServers | to_entries[] | .key, (.value | @json)') + ( + cd "$ARG_WORKDIR" + while IFS= read -r server_name && IFS= read -r server_json; do + echo "------------------------" + echo "Executing: claude mcp add-json \"$server_name\" '$server_json' (in $ARG_WORKDIR)" + claude mcp add-json "$server_name" "$server_json" + echo "------------------------" + echo "" + done < <(echo "$ARG_MCP" | jq -r '.mcpServers | to_entries[] | .key, (.value | @json)') + ) fi if [ -n "$ARG_ALLOWED_TOOLS" ]; then