Skip to content

Add support for connecting all servers from a config file#160

Merged
jancurn merged 8 commits intomainfrom
claude/auto-connect-servers-file-4zXQe
Apr 14, 2026
Merged

Add support for connecting all servers from a config file#160
jancurn merged 8 commits intomainfrom
claude/auto-connect-servers-file-4zXQe

Conversation

@jancurn
Copy link
Copy Markdown
Member

@jancurn jancurn commented Apr 11, 2026

Summary

mcpc connect <config-file> now connects all servers defined in a config file at once. Bridge processes launch in parallel for fast startup, and results are displayed as compact status badges. Re-running the same command reuses existing sessions instead of creating duplicates.

$ mcpc connect ~/.vscode/mcp.json
Connecting 5 servers from ~/.vscode/mcp.json...
  ● @playwright connected
  ● @filesystem connected
  ● @apify already active
  ● @github failed — connection refused
  ● @memory connected
✓ 4 of 5 servers connected, 1 failed

Key changes

  • New command variant: mcpc connect <config-file> connects all mcpServers entries in the file

    • Session names auto-generated from entry names (e.g., "playwright"@playwright)
    • @session argument is rejected (use file:entry format for a specific entry with custom name)
  • Parallel execution: All bridge processes launch concurrently via Promise.allSettled, reducing total connect time from O(n × handshake) to O(max handshake)

  • Status badges: Compact per-server status display after all connections complete

    • ● @name connected — new session created
    • ● @name already active — existing live session reused
    • ● @name failed — <error> — connection failed
    • Summary line with success/failure counts
  • Session reuse: Deterministic session names from entry names ensure re-running the command reuses existing sessions instead of creating @entry-2 duplicates

  • Parser enhancement (parseServerArg): New config-file return type for bare file paths (no :entry suffix), detected via path prefixes (/, ~, ./) or config file extensions (.json, .yaml, .yml)

  • JSON output: Structured results with status per entry (created, active, failed)

Implementation details

  • Config file detection skips URL-prefix check for args ending with .json/.yaml/.yml to avoid config.json being misinterpreted as a hostname
  • Windows drive letters (C:\path) properly handled
  • connectSession gains skipDetails (skip blocking MCP handshake) and quiet (suppress console output) options for bulk connect
  • Partial failures handled gracefully — command succeeds if any server connects, exits with error only if all fail

Tests

  • Unit tests: parseServerArg tests for bare file paths, Windows paths, and ensuring bare hostnames still parse as URLs
  • E2E test (connect-config-file.test.sh): First connect creates sessions, second connect reuses them (no duplicates), reused sessions remain functional

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R

When running `mcpc connect <file-path>` without a `:entry` suffix,
connect all servers defined in the config file with auto-generated
session names from entry names (e.g., `mcpc connect ~/.vscode/mcp.json`).

- Add `config-file` parse result type in `parseServerArg()` for bare
  file paths (detected by path prefixes or config file extensions)
- Add `connectAllFromConfig()` in sessions.ts that loads the config,
  iterates entries, and connects each sequentially
- Connect handler rejects `@session` when connecting all from a file
- Support both human and JSON output modes with summary

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
@jancurn jancurn force-pushed the claude/auto-connect-servers-file-4zXQe branch from a0607c6 to 597506f Compare April 13, 2026 08:36
claude and others added 7 commits April 13, 2026 08:48
Use deterministic session names derived from entry names in
connectAllFromConfig (e.g., "alpha" → "@Alpha") instead of going through
resolveSessionName. The previous flow would suffix names on re-runs
(@Alpha-2, @Bravo-2, ...) because findMatchingSession explicitly skips
URL-matching for type='config'. Using a fixed name lets connectSession's
existing "already active" path reuse the live session.

Add test/e2e/suites/basic/connect-config-file.test.sh covering:
- First connect creates @Alpha and @bravo from entries
- Second connect reports them as "already active"
- No suffixed duplicates exist after re-run
- Reused sessions remain functional (tools-list works)

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
connectSession now accepts `skipDetails` to skip the blocking
showServerDetails call. connectAllFromConfig passes this flag so
connecting multiple servers from a config file no longer hangs
waiting for each server's MCP handshake to complete (which can
take 25+ seconds for stdio servers like playwright).

Sessions are still created and bridges started; the user can check
individual session details with `mcpc @session` afterward.

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
Rewrite connectAllFromConfig to launch all bridge processes in
parallel via Promise.allSettled instead of sequentially. Each
connection runs with quiet+skipDetails to suppress per-session
output, then results are displayed as compact status badges:

  ● @playwright connected
  ● @filesystem already active
  ● @github failed — connection refused

This reduces total connect time from O(n × handshake) to
O(max handshake) since bridges start concurrently.

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
…een) for live

New sessions show yellow "connecting" badge since only the bridge was
started — the MCP handshake hasn't been verified. Pre-existing live
sessions show green "already active". Summary line itemizes counts
per status (e.g., "3 already active, 2 connecting") instead of a
misleading "All 5 servers connected".

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
Warn once per variable name instead of on every substitution call.
Avoids noisy repeated "[config] Environment variable not found"
lines when bulk-connecting servers from a config file that share
the same unset variable.

https://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R
@jancurn jancurn merged commit 0585845 into main Apr 14, 2026
6 checks passed
@jancurn jancurn deleted the claude/auto-connect-servers-file-4zXQe branch April 14, 2026 23:27
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