Unify JSON output format for connect commands to array of entries#218
Open
Unify JSON output format for connect commands to array of entries#218
Conversation
…objects
The connect command previously emitted three different JSON shapes depending
on what was being connected:
- Single server → `{ protocolVersion, capabilities, serverInfo, ..., _mcpc }`
- Config file → `{ configFile, results: [...], skipped: [...] }`
- Auto-discovery → `{ discovered, results, skipped }`
`mcpc help connect` only documented the single-server shape, leaving scripts
and AI agents to reverse-engineer the bulk shapes from source.
All three paths now emit an array of `InitializeResult` objects (extended
with `toolNames` and `_mcpc` metadata), one entry per session. Single-server
connects emit a one-element array; bulk connects emit one entry per session.
Failed and skipped entries carry their state in `_mcpc.status` (`created` |
`active` | `failed` | `skipped`) plus `_mcpc.skipReason` / `_mcpc.error`,
and the `_mcpc` block also includes `configFile` / `entry` for entries that
came from a config file. Bulk connects now fetch InitializeResult per
successful entry in parallel via the bridge.
The connect help text is also tightened: tighter prose in the session-name
and stdio-server sections, regrouped auto-discovery locations into
project/global/system/env-var, and an updated JSON-output line that shows
the new array shape and `_mcpc` keys.
https://claude.ai/code/session_01KAWhWQStTysF6nnemZe5Ev
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
Refactors the JSON output format for all
mcpc connectcommands to return a unified array ofConnectResultEntryobjects instead of nested structures with separateresults,skipped, anddiscoveredfields. This provides a consistent, flat schema that consumers can always treat as an array of session connection results.Key Changes
New
ConnectResultEntrytype: Defines a unified structure that mirrors MCP'sInitializeResult(protocolVersion, capabilities, serverInfo, instructions) extended withtoolNamesand an_mcpcmetadata block containing session details, status, and error information.New helper functions:
buildConnectResultEntry(): Connects to a session and builds a populated entry from its InitializeResult and tools listbuildBulkConnectEntries(): Processes bulk-connect results in parallel, fetching InitializeResult for successful entries and creating minimal entries for failuresUnified JSON output: All connect commands (
connectSession,connectAllFromConfig,connectAllFromStandardConfigs) now output a flat array ofConnectResultEntryobjects where:'created'or'active'with full InitializeResult data'failed'with error details'skipped'with skipReason ('stdio'or'duplicate')Consistent error handling: Both human-readable and JSON modes now handle connection failures uniformly, with JSON mode emitting a
failedentry instead of silent success.Updated help text: Clarified documentation for server formats, auto-discovery locations, and JSON output schema to reflect the new array-based format.
Implementation Details
_mcpcmetadata block is always populated, while InitializeResult fields are conditionally included only for successful connections'created'/'active'to'failed'if the bridge becomes unresponsivehttps://claude.ai/code/session_01KAWhWQStTysF6nnemZe5Ev