Python: Skip MCP tools and prompts whose normalized names collide - #14236
Merged
SergeyMenshykh merged 3 commits intoJul 29, 2026
Merged
Conversation
MCP tool and prompt names are normalized to the allowed kernel function identifier pattern. The normalization is many-to-one, so two distinct remote names can produce the same local name. Previously the second registration replaced the first via setattr with no check, leaving a single kernel function whose displayed name no longer matched the remote item it invokes. Track the normalized names already registered by the plugin and skip any tool or prompt that would rebind a name owned by a different remote item, logging a warning instead. Reloading the same remote item still refreshes its function, and tools and prompts share one registry because both bind attributes on the same plugin instance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4cab25f4-d987-42b3-bb34-e8d8a7185c80
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the Python MCP connector’s tool/prompt registration to avoid silent overwrites when different remote names normalize to the same local kernel function identifier, ensuring stable and correct dispatch to the intended remote MCP item.
Changes:
- Track already-registered normalized MCP names across loads (tools + prompts) and detect collisions.
- Skip colliding tools/prompts and emit a warning describing both the existing and conflicting remote items.
- Add unit tests covering collisions within a single load, across reloads, and between prompts vs tools.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/semantic_kernel/connectors/mcp.py | Adds persistent cross-load, cross-type collision tracking for normalized MCP names and logs warnings instead of overwriting registrations. |
| python/tests/unit/connectors/mcp/test_mcp.py | Adds unit tests validating collision detection/skip behavior for tools, prompts, reload scenarios, and prompt-vs-tool collisions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The mcp requirement had no upper bound, and the Python CI workflows install with `uv sync -U`, which resolves to the newest release rather than the locked one. mcp 2.0.0 reorganizes the package, so `semantic_kernel/connectors/mcp.py` fails to import and every unit test job errors during collection. mcp 2.0 removes `mcp.client.websocket` and `mcp.shared.session`, relocates `McpError` and `RequestContext`, and renames `streamablehttp_client` to `streamable_http_client`. Supporting it requires a separate migration, so pin the supported range to `<2` in the base dependency and the mcp extra to keep CI resolving a compatible 1.x release. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4cab25f4-d987-42b3-bb34-e8d8a7185c80
Resolve conflicts in python/pyproject.toml and python/uv.lock in favor of upstream. PR microsoft#14222 already constrained mcp to the 1.x series, so the local constraint added on this branch was redundant and is dropped in favor of the upstream `<2.0` specifier. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4cab25f4-d987-42b3-bb34-e8d8a7185c80
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||
eavanvalkenburg
approved these changes
Jul 29, 2026
SergeyMenshykh
enabled auto-merge
July 29, 2026 12:52
giles17
approved these changes
Jul 29, 2026
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.
Motivation and Context
MCP tool and prompt name normalization is many-to-one, so two remote names can produce the same local name. The second registration silently replaced the first.
Description
Track normalized names already registered by the plugin and skip colliding tools or prompts with a warning instead of overwriting. Reloading the same remote item still refreshes it. Adds unit tests.
Contribution Checklist