Skip to content

fix(core): resolve MCP union ambiguity with discriminator#35389

Open
Nook127 wants to merge 1 commit into
anomalyco:devfrom
Nook127:fix-mcp-union-ambiguity
Open

fix(core): resolve MCP union ambiguity with discriminator#35389
Nook127 wants to merge 1 commit into
anomalyco:devfrom
Nook127:fix-mcp-union-ambiguity

Conversation

@Nook127

@Nook127 Nook127 commented Jul 5, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #35359

Type of change

  • Bug fix

What does this PR do?

When MCP config entries include enabled or environment keys, all CLI commands exit 1 with zero stdout/stderr. The root cause is a non-discriminated Schema.Union([ConfigMCPV1.Info, Schema.Struct({ enabled: Schema.Boolean })]) in the mcp field of ConfigV1.Info. With errors: "all" mode in ConfigParse.schema, all union members are evaluated. When an entry has enabled: true (also an optional field on Local), both members match the input, creating an ambiguity that Effect Schema 4.0.0-beta.83 reports as a parse error. This throws an InvalidError inside Effect.fnUntraced, becoming an uncaught defect that kills the process.

Added { discriminator: "type" } to the outer Schema.Union. The discriminator routes entries with type: "local"/"remote" unambiguously to ConfigMCPV1.Info, while entries without type fall through to { enabled: boolean } (used for config-layering disable overrides).

How did you verify your code works?

The change is a one-line addition of { discriminator: "type" } annotation to an existing Schema.Union, following the exact same pattern already used by ConfigMCPV1.Info (line 62 of mcp.ts). The discriminator makes the union unambiguous: entries with type route exclusively to ConfigMCPV1.Info, entries without type fall through to { enabled: boolean }. The existing isMcpConfigured check ("type" in entry) in the MCP service remains correct since the decoded output shape is unchanged.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

mcp entry with "environment" or "enabled" key makes every CLI command exit 1 with no output

1 participant