Skip to content

Document and normalize MCP tool filter names - #2101

Open
syedkazmi14 wants to merge 2 commits into
github:mainfrom
syedkazmi14:fix-mcp-tool-name-prefixes-869
Open

Document and normalize MCP tool filter names#2101
syedkazmi14 wants to merge 2 commits into
github:mainfrom
syedkazmi14:fix-mcp-tool-name-prefixes-869

Conversation

@syedkazmi14

@syedkazmi14 syedkazmi14 commented Jul 27, 2026

Copy link
Copy Markdown

Title:
Fix MCP tool-name prefix handling in Python SDK

Description:
Fixes #869

This PR documents that MCP tools registered via mcp_servers are exposed to the runtime as <server-key>-<tool-name>, and updates Python tool-filter handling so bare MCP tool names automatically gain matching server-prefixed aliases when the corresponding MCP server exposes them, including wildcard server configs (tools=["*"]).

Changes included:

  • Added MCP tool-filter normalization in python/copilot/_mode.py and wired it into the Python session create/resume paths
  • Normalized MCP tool filters for available_tools, excluded_tools, custom-agent tools, and default_agent.excluded_tools
  • Documented the <server-key>-<tool-name> convention and SDK normalization behavior in python/copilot/session.py and python/README.md
  • Added regression coverage in python/test_tool_set.py and python/test_client.py

@syedkazmi14
syedkazmi14 requested a review from a team as a code owner July 27, 2026 23:50
@SteveSandersonMS

Copy link
Copy Markdown
Contributor

Thanks for digging into this, and for the detailed writeup in #869. The repro is clear and this is a genuinely confusing failure mode (zero tools, no error, hooks never fire).

Before going further with the code change, I want to flag something that changes the right scope here: the <server-key>-<tool-name> convention is actually already documented in this SDK (and every other language SDK), just not in the place you were looking. See ToolSet.add_mcp() in python/copilot/_mode.py:

def add_mcp(self, tool_name: str) -> ToolSet:
    """Add an MCP tool pattern (e.g. "github-list_issues" or "*")."""

The same docstring/example exists in the nodejs, dotnet, java, go, and rust SDKs too (ToolSet.addMcp() in each). So available_tools=["mcp:my-server-list_tables"] (or ToolSet().add_mcp("my-server-list_tables")) already works correctly today. The gap is that this isn't mentioned in the README or in the SessionConfig/MCPRemoteServerConfig docstrings that people read when passing a plain list[str], which is exactly the scenario in your repro.

Given that, I think the right-sized fix here is docs-only, and should probably span all the SDKs rather than just Python, since the naming convention is a backend/CLI-level thing and every language hits the same trap:

  • Add a line to each SDK's README (and the available_tools/excluded_tools/custom_agents/default_agent docstrings) explaining the <server-key>-<tool-name> convention and pointing to ToolSet.addMcp()/mcp: prefix as the reliable way to target MCP tools.

I'd rather not add the auto-alias-expansion logic in _mode.py/client.py. A few reasons:

  • It only fixes Python, so JS/Go/Rust/Java/.NET users still hit the exact same silent failure.
  • It changes runtime behavior silently (e.g., an excluded_tools entry that previously no-op'd against an MCP tool would now actually start excluding it), which could be a surprising behavior change for existing callers.
  • It's solving via a guess (matching against configured mcp_servers.tools) something the SDK already lets users express exactly and unambiguously via mcp:<server-key>-<tool-name>.

Would you be up for narrowing this PR to the doc changes (README + docstrings) and applying the same wording across the other SDK directories? This is a good contribution, just want to make sure it lands in the most maintainable spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation missing: MCP tools are prefixed with <server-key>- in available_tools / custom_agents[].tools

2 participants