Skip to content

feat(agent): load MCP servers from ~/.claude.json project configuration#2033

Merged
jonathanlab merged 2 commits intomainfrom
fix/handle-user-mcps
May 5, 2026
Merged

feat(agent): load MCP servers from ~/.claude.json project configuration#2033
jonathanlab merged 2 commits intomainfrom
fix/handle-user-mcps

Conversation

@jonathanlab
Copy link
Copy Markdown
Contributor

@jonathanlab jonathanlab commented May 5, 2026

we werent loading mcp servers from ~.claude.json bc our CLAUDE_CONFIG_DIR is set to application support

lets load them in so people can use their mcp servers :)

Closes #1590


Created with PostHog Code

Generated-By: PostHog Code
Task-Id: a95f56d1-781c-4264-9ca8-a006091f79fa
@jonathanlab jonathanlab added the Create release This will trigger a new release label May 5, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Comments Outside Diff (1)

  1. packages/agent/src/adapters/claude/session/options.ts, line 92-102 (link)

    P2 The parameter is named projectScopedServers, but loadUserClaudeJsonMcpServers returns a merged record of both the top-level mcpServers and the project-scoped mcpServers from ~/.claude.json. The name implies only project-scoped entries, which makes the merge semantics harder to reason about at the call site.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/agent/src/adapters/claude/session/options.ts
    Line: 92-102
    
    Comment:
    The parameter is named `projectScopedServers`, but `loadUserClaudeJsonMcpServers` returns a merged record of **both** the top-level `mcpServers` and the project-scoped `mcpServers` from `~/.claude.json`. The name implies only project-scoped entries, which makes the merge semantics harder to reason about at the call site.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/agent/src/adapters/claude/session/options.ts:92-102
The parameter is named `projectScopedServers`, but `loadUserClaudeJsonMcpServers` returns a merged record of **both** the top-level `mcpServers` and the project-scoped `mcpServers` from `~/.claude.json`. The name implies only project-scoped entries, which makes the merge semantics harder to reason about at the call site.

```suggestion
function buildMcpServers(
  userServers: Record<string, McpServerConfig> | undefined,
  acpServers: Record<string, McpServerConfig>,
  claudeJsonServers: Record<string, McpServerConfig>,
): Record<string, McpServerConfig> {
  return {
    ...claudeJsonServers,
    ...(userServers || {}),
    ...acpServers,
  };
}
```

### Issue 2 of 2
packages/agent/src/adapters/claude/session/mcp-config.test.ts:18-31
**Prefer parameterised tests for the "returns empty" cases.** The two cases that verify an empty result (`~/.claude.json` missing, invalid JSON) share the same assertion and differ only in precondition setup — a natural fit for `it.each`. Per the project's simplicity rules, saying everything OnceAndOnlyOnce means the shared assertion should not be repeated across separate `it` blocks.

Reviews (1): Last reviewed commit: "feat(agent): load MCP servers from ~/.cl..." | Re-trigger Greptile

Comment thread packages/agent/src/adapters/claude/session/mcp-config.test.ts Outdated
Address greptile P2: collapse the two "returns empty" tests
(missing file, invalid JSON) into one it.each — same assertion,
different precondition.

Generated-By: PostHog Code
Task-Id: a95f56d1-781c-4264-9ca8-a006091f79fa
@jonathanlab jonathanlab enabled auto-merge (squash) May 5, 2026 13:37
@jonathanlab jonathanlab merged commit 520c23b into main May 5, 2026
15 checks passed
@jonathanlab jonathanlab deleted the fix/handle-user-mcps branch May 5, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Create release This will trigger a new release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check whether we properly read .claude/mcp.json

3 participants