Skip to content

fix(config): address dotted MCP server names in config set - #1826

Merged
lizhengfeng101 merged 2 commits into
alibaba:mainfrom
LuckVd:fix/mcp-config-set-dotted-server-names
Nov 16, 2026
Merged

lizhengfeng101 merged 2 commits into
alibaba:mainfrom
LuckVd:fix/mcp-config-set-dotted-server-names

Conversation

@LuckVd

@LuckVd LuckVd commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Description

ocr config set mcp_servers.<name>.<field> could not address any server name containing a dot: setMCPServerValue parsed keys with strings.SplitN(key, ".", 3), so mcp_servers.github.v2.type resolved to name github + field v2.type and failed with unknown MCP server field "v2.type", while config unset mcp_servers.github.v2 already handles the same dotted name. Since config set is the only documented way to create MCP servers, dotted names were un-creatable, and hand-edited dotted entries could only be deleted, never updated.

This completes the parsing #1661 established for providers.* / custom_providers.*: the last dot now separates the field from the server name, and a new validateMCPServerName keeps mistyped keys (mcp_servers..command, mcp_servers.a..command, whitespace segments) rejected, with rejected writes leaving the config untouched.

I deliberately did not carry over #1661's "dotted names must exist before their fields can be set" guard: providers have a separate creation entry (ocr config set provider <name> / the provider command), while for MCP servers config set itself is the creation path — the guard would make dotted names entirely uncreatable instead of addressable.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally (25 packages, -race -count=1)
  • Manual testing (describe below)

New regressions in config_cmd_test.go:

  • TestSetMCPServerValue_DottedServerName — dotted name is stored under its full spelling, fields accumulate across type/command, dot-free names keep their meaning, no prefix-named entry leaks.
  • TestSetMCPServerValue_DottedServerNameRejectsEmptySegments — malformed keys are all rejected and leave the existing config unchanged.

Manual: built main and this branch side by side — on main both config set mcp_servers.github.v2.type stdio and ...command npx fail with unknown MCP server field; on this branch they succeed (exit 0) and config unset mcp_servers.github.v2 round-trips (Deleted MCP server "github.v2".). Also go vet ./cmd/opencodereview/ and gofmt -l clean.

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI tool used: ZCode (GLM) drafted the change and tests under my direction; I reviewed every line before submitting.

Related Issues

Fixes #1825

setMCPServerValue parsed keys with SplitN(key, ".", 3), so a server
name containing dots could never be configured: mcp_servers.github.v2.type
resolved to name "github" and field "v2.type", failing with a
misleading unknown-field error, while runConfigUnset already accepts the
same dotted name. alibaba#1661 switched providers/custom_providers to last-dot
parsing; this completes the same fix for mcp_servers, with segment
validation so mistyped keys cannot create empty-segment names.
@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s).

@LuckVd

LuckVd commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi maintainers — both the CLA and code-review checks pass, but this PR has not had a human review yet. Could someone take a look when available? Please let me know if there is a required update from me.

@NanaseInori NanaseInori left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed both changed files, the surrounding field setter and its prefix-gated caller, #1825, and the existing discussion. The issue-number search returned only this PR. The provider-name work in #1661 addresses a different setter; this is a justified follow-up for MCP configuration.

Splitting at the last dot preserves the complete server name while leaving the existing flat field validation unchanged. Empty/whitespace-only name segments are rejected before the map is touched. The new tests cover accumulating fields under github.v2, preserving dot-free names, avoiding a leaked github entry, and rejecting malformed keys without changing the existing server. I found no blocking defect in this patch.

Allowing a new dotted MCP name is appropriate here: config set is also the creation path, so copying the provider setter's existing-entry requirement would prevent the intended operation.

Validation was source and regression-test inspection. I did not independently execute the CLI round trip, race detector, or full repository suite.

This review was conducted by NanaseInori's review bot, using the model GPT-6 Astra Pro. If you need a human review, please manually @NanaseInori.

@chaojixinren chaojixinren left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit e4c8011 into alibaba:main Nov 16, 2026
12 checks passed
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.

ocr config set cannot address MCP server names containing dots, yet config unset can delete them

4 participants