Skip to content

fix(mcp): match tool definitions to their registered server - #1972

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
Afloat16:fix/mcp-definition-owner-20261117
Nov 21, 2026
Merged

lizhengfeng101 merged 1 commit into
alibaba:mainfrom
Afloat16:fix/mcp-definition-owner-20261117

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

When two MCP servers publish the same tool name, a per-server allowlist can exclude the first server's tool while the second server registers its implementation. CollectToolDefs currently checks only whether the name exists in the registry, so it can advertise the first server's description and input schema while execution goes to the second server. Arguments following that advertised schema then fail at the actual tool.

Only collect a definition when the registered provider is an MCP provider owned by that client. This also prevents advertising an MCP definition after a non-MCP provider has already claimed the name. Existing registration priority, allowlists, and definition ordering are retained.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

How Has This Been Tested?

All three new regressions fail before the fix and pass afterward:

  • A filtered-out duplicate must not replace the registered server's description or schema, in either collection order.
  • A tool name claimed by a non-MCP provider must not advertise an unregistered MCP schema.
  • Two real MCP SDK client/server sessions communicate over in-memory transports. The test builds arguments from the advertised schema and executes the registry's provider. Before the fix, execution fails with a missing query argument; afterward, the intended server returns the expected result.

Validation with Go 1.26.11 on Linux amd64:

  • make check — passed.
  • make test — the complete package list passed with race detection.
  • make coverage — passed, 91.7% overall statement coverage (90% required).
  • make build — passed.
  • make license-add, LF verification, independent diff review, and git diff --cached --check — passed.

The inherited telemetry sampler was set to always_on for the test suite. The required ocr review --audience agent --background "..." command was attempted, but could not start because no valid LLM endpoint is configured.

Checklist

  • The change follows the project's coding style.
  • Regression tests demonstrate the schema/execution mismatch and the fix.
  • New and existing unit tests pass locally.
  • I have signed the CLA.

AI/LLM disclosure: OpenAI ChatGPT (GPT-6 Astra Pro).

@CLAassistant

CLAassistant commented Nov 17, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

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

@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 2de8b4d into alibaba:main Nov 21, 2026
13 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.

4 participants