Skip to content

Commit d2d6a54

Browse files
authored
fix: update claude mcp configuration with repo and org headers (#1238)
# Motivation Codegen MCP server takes in option repo and org id for the initialization of the mcp session <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> Set the organization and repo id headers when setting up claude with the codegen mcp # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ x] I have updated the documentation or added new documentation as needed
1 parent 87c21a5 commit d2d6a54

File tree

3 files changed

+53
-19
lines changed

3 files changed

+53
-19
lines changed

docs/integrations/mcp.mdx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ The remote MCP server provides:
2323
To configure the remote Codegen MCP server in Claude Code:
2424

2525
```bash
26-
claude mcp add --transport http codegen-tools https://mcp.codegen.com/mcp/ --header "Authorization: Bearer <auth token>"
26+
claude mcp add --transport http codegen-tools https://mcp.codegen.com/mcp/ \
27+
--header "Authorization: Bearer <auth token>" \
28+
--header "x-organization-id: <org-id>" \
29+
--header "x-repo-id: <repo-id>"
2730
```
2831

29-
Replace `<auth token>` with your Codegen API key.
32+
Replace:
33+
- `<auth token>` with your Codegen API key
34+
- `<org-id>` with your organization ID (optional, automatically added when using `codegen claude`)
35+
- `<repo-id>` with your repository ID (optional, automatically added when using `codegen claude`)
3036

3137
### For Cursor/Windsurf/VSCode Forks
3238

@@ -39,14 +45,19 @@ Add the following configuration to your settings:
3945
"transport": "http",
4046
"url": "https://mcp.codegen.com/mcp/",
4147
"headers": {
42-
"Authorization": "Bearer <auth token>"
48+
"Authorization": "Bearer <auth token>",
49+
"x-organization-id": "<org-id>",
50+
"x-repo-id": "<repo-id>"
4351
}
4452
}
4553
}
4654
}
4755
```
4856

49-
Replace `<auth token>` with your Codegen API key.
57+
Replace:
58+
- `<auth token>` with your Codegen API key
59+
- `<org-id>` with your organization ID (optional)
60+
- `<repo-id>` with your repository ID (optional)
5061

5162
### For VSCode with MCP Extension
5263

@@ -60,14 +71,19 @@ If you're using VSCode with an MCP extension, add this to your settings.json:
6071
"transport": "http",
6172
"url": "https://mcp.codegen.com/mcp/",
6273
"headers": {
63-
"Authorization": "Bearer <auth token>"
74+
"Authorization": "Bearer <auth token>",
75+
"x-organization-id": "<org-id>",
76+
"x-repo-id": "<repo-id>"
6477
}
6578
}
6679
]
6780
}
6881
```
6982

70-
Replace `<auth token>` with your Codegen API key.
83+
Replace:
84+
- `<auth token>` with your Codegen API key
85+
- `<org-id>` with your organization ID (optional)
86+
- `<repo-id>` with your repository ID (optional)
7187

7288
## Authentication
7389

src/codegen/cli/commands/claude/config/mcp_setup.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from codegen.cli.commands.claude.utils import resolve_claude_path
77

88

9-
def add_codegen_mcp_server():
9+
def add_codegen_mcp_server(org_id: int | None = None, repo_id: int | None = None):
1010
console.print("🔧 Configuring MCP server 'codegen-tools'...", style="blue")
1111
try:
1212
token = get_current_token()
@@ -19,18 +19,31 @@ def add_codegen_mcp_server():
1919
console.print("⚠️ 'claude' CLI not found to add MCP server", style="yellow")
2020
return
2121

22+
# Build the command with required headers
23+
cmd = [
24+
claude_path,
25+
"mcp",
26+
"add",
27+
"--transport",
28+
"http",
29+
"codegen-tools",
30+
MCP_SERVER_ENDPOINT,
31+
"--header",
32+
f"Authorization: Bearer {token}",
33+
]
34+
35+
# Add organization ID header if available
36+
if org_id is not None:
37+
cmd.extend(["--header", f"x-organization-id: {org_id}"])
38+
console.print(f" Adding organization ID: {org_id}", style="dim")
39+
40+
# Add repository ID header if available
41+
if repo_id is not None:
42+
cmd.extend(["--header", f"x-repo-id: {repo_id}"])
43+
console.print(f" Adding repository ID: {repo_id}", style="dim")
44+
2245
add_result = subprocess.run(
23-
[
24-
claude_path,
25-
"mcp",
26-
"add",
27-
"--transport",
28-
"http",
29-
"codegen-tools",
30-
MCP_SERVER_ENDPOINT,
31-
"--header",
32-
f"Authorization: Bearer {token}",
33-
],
46+
cmd,
3447
capture_output=True,
3548
text=True,
3649
timeout=15,

src/codegen/cli/commands/claude/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from codegen.cli.commands.claude.utils import resolve_claude_path
2828
from codegen.cli.rich.spinners import create_spinner
2929
from codegen.cli.utils.org import resolve_org_id
30+
from codegen.cli.utils.repo import resolve_repo_id
3031
from codegen.shared.logging.get_logger import get_logger
3132

3233
# Initialize logger
@@ -218,7 +219,11 @@ def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None:
218219

219220
# If MCP endpoint provided, register MCP server via Claude CLI before launch
220221
if not no_mcp:
221-
add_codegen_mcp_server()
222+
# Resolve repository ID if available
223+
repo_id = resolve_repo_id()
224+
if repo_id:
225+
console.print(f"🎯 Repository ID: {repo_id}", style="dim")
226+
add_codegen_mcp_server(org_id=resolved_org_id, repo_id=repo_id)
222227

223228
console.print("🔵 Starting Claude Code session...", style="blue")
224229

0 commit comments

Comments
 (0)