Repository navigation
fix(mecated): mcp add settings corruption and late illegal-name failure - #2038
Merged
Merged
Conversation
Adding a server to an mcp section that held only `mode` appended a `servers` fragment parsed at column 1, which serialized as a top-level key instead of mcp.servers, so the server was never found. Removing the last server had the inverse bug, writing `mode: global` at the document root. Shift the fragment to the existing keys' column, as provider_map_mutate already does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`mecated mcp add connector-gateway ...` ran protected-resource discovery and credential custody selection, then failed schema validation with an opaque "invalid permission config schema at mcp" error: names must match [A-Za-z0-9_]+ without "__" because they derive the MCP_<NAME>_TOKEN environment variable. Validate the name first, in both the CLI and mcplifecycle.Add, with an error that states the rule, the reason, and a suggested legal name. Export permconfig.ValidateMCPServerName so the schema and the early check share one rule, and document the naming rule on the owning page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jhrozek
approved these changes
Oct 1, 2026
Merged
2 tasks
This branch was successfully deployed
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
Two
mecated mcp addbugs.Settings corruption with a mode-only
mcpsectionmecated mcp addcorrupted settings when themcp:section held onlymode(e.g.mcp: {mode: global}in block form). The insertedservers:fragment was parsed standalone at column 1 and kept that position, so goccy/go-yaml serialized it as a top-level key instead ofmcp.servers— mecatl then never found the server:RemoveDirectMCPServerhad the inverse bug: removing the last server replaced the section withmode: globalwritten at the document root. This is also the most likely way operators reach the mode-only state in the first place (remove → add).Fix
Add
alignDirectMCPEntry, which shifts a standalone fragment to the column of the parent mapping's existing keys before appending — the same approachprovider_map_mutate.goalready uses. Both the add (serversinsertion) and remove (mode: globalre-insertion) paths use it.Illegal server names fail late and opaquely
mecated mcp add connector-gateway ...ran discovery and custody selection, then failed withinvalid permission config schema at mcp (line N). Server names must match[A-Za-z0-9_]+without__because they derive theMCP_<NAME>_TOKENenv var (ADR 0082). The CLI andmcplifecycle.Addnow validate the name first, before discovery or custody selection (which can provision key material), with an actionable error:permconfig.ValidateMCPServerNameis exported so the schema and the early check share one rule. The naming rule is documented inuser-docs/features/mcp-oauth-and-credentials.md.Tests
TestDirectMCPMutationNestsUnderModeOnlySection: add then remove against 2- and 4-space indentedmcp: mode: global, parsed through the real schema to assertmcp.modeandmcp.serversland correctly. Mutation-checked: fails without the fix.TestDirectMCPLifecycleAddRejectsIllegalNameBeforeDiscoveryand CLI-levelTestDirectMCPAddRejectsIllegalNameBeforeDiscovery(discovery stub fails the test if called; asserts no progress output and settings unchanged). Both mutation-checked.go testpasses forpermconfig,mcplifecycle, andcmd/mecatedMCP tests;task docsandtask site:buildpass;go run ./cmd/mecademoshows tool call, permission ask/approval, and result.Pre-existing gate failures (also on
main, unrelated to this change)task lint: 3 staticcheck SA4023 findings incmd/mecatl-executor/main.goandinternal/executionexecutor/executor.go.task test:race:TestDevelopmentReleaseInputsRemainBoundAfterPathReplacement,TestDevelopmentReleaseDownloadNeverUsesHTTP(microvmmanager, "release bundle omitted the platform manifest") andTestMecatedCLICompositionValidatesMicroVMDefaultAfterReadiness(cmd/mecated).Follow-ups (not in this PR)
mcp: {mode: global}still failsadd, cleanly with "updated settings document is invalid" rather than corrupting the file.ValidateYAMLaccepted the corrupted output (unknown top-levelservers/modekeys), which is why the bug surfaced late. Consider whether stricter root-key validation is wanted.🤖 Generated with Claude Code