Skip to content

Add auto-discovery of standard MCP config files for mcpc connect#165

Open
jancurn wants to merge 9 commits intomainfrom
claude/mcpc-find-all-configs-YXXCl
Open

Add auto-discovery of standard MCP config files for mcpc connect#165
jancurn wants to merge 9 commits intomainfrom
claude/mcpc-find-all-configs-YXXCl

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented Apr 15, 2026

Summary

Key changes

Config discovery (src/lib/config.ts)

  • getStandardMcpConfigPaths() — returns prioritized list of standard MCP config file locations (project first, then global)
  • discoverMcpConfigFiles() — discovers and parses config files, returning only those with valid mcpServers
  • tryReadMcpConfig() — lenient parser that gracefully handles missing files, invalid JSON, and configs without mcpServers (e.g. ~/.claude.json)

Bulk-connect refactor (src/cli/commands/sessions.ts)

  • Extracted shared BulkConnectOptions, BulkConnectEntry, BulkConnectResult types
  • bulkConnectEntries() — connects entries in parallel with compact status badges
  • printBulkConnectSummary() — formats active/connecting/failed summary
  • aggregateDiscoveredEntries() — deduplicates entries across configs (project wins), filters stdio entries when --stdio not set
  • connectAllFromStandardConfigs() — discovers configs and connects all servers
  • connectAllFromConfig() now uses BulkConnectOptions instead of inline options type

CLI (src/cli/index.ts)

  • mcpc connect with no server argument routes to connectAllFromStandardConfigs()
  • @session argument rejected when discovering all servers
  • --stdio threaded to both connectAllFromConfig and connectAllFromStandardConfigs
  • Help text documents auto-discovery locations, session name auto-generation, and stdio gating

Searched locations

Project scope (CWD): .mcp.json, .cursor/mcp.json, .vscode/mcp.json, .kiro/settings/mcp.json

Global scope (~): ~/.claude.json, ~/.cursor/mcp.json, ~/.vscode/mcp.json, ~/.codeium/windsurf/mcp_config.json, ~/.kiro/settings/mcp.json, Claude Desktop (platform-specific)

Tests

  • Unit tests for getStandardMcpConfigPaths() — platform-specific paths (macOS, Linux, Windows), deduplication
  • Unit tests for discoverMcpConfigFiles() — discovery, missing files, invalid JSON, empty configs, multi-scope
  • E2E test suite (connect-discover.test.sh) — no configs found, project-only, global-only, collision handling, session reuse, JSON output

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd

jancurn added a commit that referenced this pull request Apr 24, 2026
…lag (#201)

* Skip stdio config entries by default in bulk connect, add --stdio flag

Stdio entries in MCP config files execute arbitrary local commands via
child_process.spawn(). To prevent supply-chain attacks through malicious
config files, `mcpc connect <config-file>` (bulk connect) now skips stdio
entries by default. Pass --stdio to opt in. Single-entry connects
(`mcpc connect file:entry`) are unaffected.

Isolated from #165 to make review and testing easier.

https://claude.ai/code/session_0138fCGaEqxPbT7y2hWFAAC1

* Tighten --stdio help text in `mcpc connect`

https://claude.ai/code/session_0138fCGaEqxPbT7y2hWFAAC1

---------

Co-authored-by: Claude <noreply@anthropic.com>
claude added 2 commits April 24, 2026 22:19
Running `mcpc connect` with no arguments now scans the current directory
and the user's home dir for standard MCP config file locations (inspired
by https://www.withone.ai/docs/cli#mcp-server-installation) and connects
every server defined across them:

- Project scope (CWD): .mcp.json, .cursor/mcp.json, .vscode/mcp.json,
  .kiro/settings/mcp.json
- Global (home):       ~/.claude.json, ~/.cursor/mcp.json,
  ~/.vscode/mcp.json, ~/.codeium/windsurf/mcp_config.json,
  ~/.kiro/settings/mcp.json, plus Claude Desktop's platform-specific path

Entries with the same auto-generated session name across files are
deduplicated (project scope wins over global). Re-running the command
reuses existing sessions. Missing files and files without `mcpServers`
are silently skipped; invalid JSON is logged and skipped.

The existing parallel bulk-connect logic was extracted into a shared
helper (`bulkConnectEntries`) used by both `mcpc connect <config-file>`
and the new no-arg discovery path.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
…g-file connect

The --stdio gating from #201 only covered connectAllFromConfig. This extends
it to connectAllFromStandardConfigs / aggregateDiscoveredEntries so bare
`mcpc connect` also skips stdio entries by default.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
@jancurn jancurn force-pushed the claude/mcpc-find-all-configs-YXXCl branch from 84b5f14 to 64951dc Compare April 24, 2026 22:22
claude added 7 commits April 24, 2026 22:48
Some projects use `mcp.json` rather than `.mcp.json` in the project root.
Include it in the standard discovery list right after `.mcp.json`.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
When `mcpc connect` (auto-discovery) runs and the APIFY_API_TOKEN
environment variable is present, automatically connect to
https://mcp.apify.com as @apify with the token as a Bearer header.
Existing live @apify sessions are reused without restart.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
VS Code stores MCP config at ~/Library/Application Support/Code/User/mcp.json
(macOS), %APPDATA%/Code/User/mcp.json (Windows), and ~/.config/Code/User/mcp.json
(Linux), using a "servers" key instead of "mcpServers". Discovery now checks
these paths and normalizes "servers" to "mcpServers" when parsing.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
…remove labels

- loadConfig() now normalizes VS Code's "servers" key to "mcpServers",
  fixing "missing mcpServers field" errors for VS Code app configs
- Discovery output groups entries under their config file path, showing
  each entry with session name, target URL/command, and skip status
- Summary line shows "Connecting N servers. Skipped M stdio servers..."
- Removed redundant label field from ConfigCandidate, DiscoveredConfig,
  and all JSON output — the file path is sufficient

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
The collision test checked for "skipping" but the new grouped output
uses "skipped (duplicate)" instead.

https://claude.ai/code/session_01LuMKCJPYJSU8GyqsrLveXd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants