Add support for connecting all servers from a config file#160
Merged
Conversation
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
a0607c6 to
597506f
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Key changes
New command variant:
mcpc connect <config-file>connects allmcpServersentries in the file"playwright"→@playwright)@sessionargument is rejected (usefile:entryformat for a specific entry with custom name)Parallel execution: All bridge processes launch concurrently via
Promise.allSettled, reducing total connect time fromO(n × handshake)toO(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 failedSession reuse: Deterministic session names from entry names ensure re-running the command reuses existing sessions instead of creating
@entry-2duplicatesParser enhancement (
parseServerArg): Newconfig-filereturn type for bare file paths (no:entrysuffix), detected via path prefixes (/,~,./) or config file extensions (.json,.yaml,.yml)JSON output: Structured results with
statusper entry (created,active,failed)Implementation details
.json/.yaml/.ymlto avoidconfig.jsonbeing misinterpreted as a hostnameC:\path) properly handledconnectSessiongainsskipDetails(skip blocking MCP handshake) andquiet(suppress console output) options for bulk connectTests
parseServerArgtests for bare file paths, Windows paths, and ensuring bare hostnames still parse as URLsconnect-config-file.test.sh): First connect creates sessions, second connect reuses them (no duplicates), reused sessions remain functionalhttps://claude.ai/code/session_012EySvxnMeDXKuhiotcCs6R