Skip to content

Fix MCP server registry: auth merging, schema enforcement, config immutability#321

Draft
Copilot wants to merge 2 commits intoclaude/add-mcp-task-registry-y9KGEfrom
copilot/sub-pr-307
Draft

Fix MCP server registry: auth merging, schema enforcement, config immutability#321
Copilot wants to merge 2 commits intoclaude/add-mcp-task-registry-y9KGEfrom
copilot/sub-pr-307

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

Review feedback on the MCP server registry PR identified several correctness issues: incomplete config merging (auth fields dropped), missing schema constraints allowing runtime-only failures, task.config mutation persisting resolved references across runs, and server_updated event never being emitted.

Changes

  • getMcpServerConfig() — all 4 MCP task files
    Replace hardcoded key list (transport, server_url, command, args, env) with iteration over mcpServerConfigSchema.properties, picking up all auth fields (auth_type, auth_token, auth_client_id, etc.). Inline values still override registry base. Keys array cached at module level.

  • discoverSchemas()McpToolCallTask, McpPromptGetTask
    Spread full serverConfig into mcpList() instead of a 5-field subset, so auth config is forwarded during schema discovery for authenticated servers.

  • Schema validation — all 4 MCP task files
    Add anyOf: [{ required: ["server"] }, { required: ["transport"] }] so configs missing both a registry reference and inline transport fail at validation, not at runtime. Removes the now-redundant top-level if/then/else (already covered by allOf: mcpServerConfigSchema.allOf).

  • TaskRunnerrun() and runReactive()
    Replace Object.assign(task.config, resolvedConfig) with a per-run shallow copy ({ ...originalConfig, ...resolvedConfig }), restoring the original reference in finally. Registry server ID strings are now re-resolved on every run instead of being permanently overwritten with the expanded object.

  • McpServerRepository
    addServer() now checks existence before writing and emits server_updated (not server_added) when overwriting. New updateServer() method provides an explicit update path that throws if the record doesn't exist.

  • McpServerConfigSchema
    Add allOf: mcpServerConfigSchema.allOf so persisted server records are validated against transport-specific constraints (e.g., command required for stdio, server_url for sse/streamable-http). Fix misleading doc comment about the format: "mcp-server" resolution mechanism.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Fix McpServerSchema.ts: correct doc comment for format resolution mechanism and add allOf transport-specific constraints
- Fix McpServerRepository.ts: add updateServer() method and fix addServer() to emit correct event (server_updated when overwriting)
- Fix TaskRunner.ts: avoid mutating task.config by using per-run copy; restore original in finally block for re-resolution on subsequent runs
- Fix getMcpServerConfig() in all 4 MCP task files: merge all MCP config keys (including auth fields) using mcpServerConfigSchema.properties, not just a subset
- Fix schema validation in all 4 MCP task files: require either 'server' or 'transport' via anyOf constraint
- Fix discoverSchemas() in McpToolCallTask/McpPromptGetTask: spread full serverConfig into mcpList() so auth fields are included
- Cache mcpServerConfigKeys at module level to avoid repeated Object.keys() allocations

Co-authored-by: sroussey <127349+sroussey@users.noreply.github.com>
Copilot AI changed the title [WIP] Add MCP server registry and support server references in tasks Fix MCP server registry: auth merging, schema enforcement, config immutability Mar 19, 2026
Copilot AI requested a review from sroussey March 19, 2026 07:46
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.

2 participants