Skip to content

fix(mcp): shorten registered MCP tool names to fit provider limits - #15617

Open
guantik-gm wants to merge 1 commit into
NousResearch:mainfrom
guantik-gm:fix/mcp-tool-name-length-limit
Open

guantik-gm wants to merge 1 commit into
NousResearch:mainfrom
guantik-gm:fix/mcp-tool-name-length-limit

Conversation

@guantik-gm

@guantik-gm guantik-gm commented Apr 25, 2026 •

Copy link
Copy Markdown

Summary

  • shorten generated MCP registry names to 64 chars or less with a stable hash suffix
  • apply the same length guard to MCP utility tool names
  • add regression tests for deterministic shortening, collision resistance, and preserved dispatch to the original MCP tool name

Why

Some providers and backends reject oversized tool names. This patch keeps generated MCP tool schemas within those limits without breaking dispatch to the original MCP server tool name.

Test Plan

  • python -m pytest tests/tools/test_mcp_tool.py -q -o 'addopts='

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists tool/mcp MCP client and OAuth comp/tools Tool registry, model_tools, toolsets labels Apr 25, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the targeted regression coverage. The underlying length-limit problem is still present on current main: tools/mcp_tool.py:4484 returns an unbounded concatenated MCP name, and both normal schemas (:4498) and utility schemas (:4515, :4526) use that helper.

Problems

  • The PR edits the obsolete mcp_<server>_<tool> construction. Current main moved native MCP names to the centralized mcp_prefixed_tool_name() helper and mcp__<server>__<tool> format in commit e01f58ff1 (tools/mcp_tool.py:4477-4484). The patch therefore needs a focused salvage rather than applying at its original sites.

Suggested changes

  • Put the stable length guard in the shared helper so normal and utility MCP names cannot drift.
  • Update the tests for the current mcp__ format and keep the original-name dispatch assertion; registration still builds handlers with mcp_tool.name at tools/mcp_tool.py:4794.

Automated hermes-sweeper review.

Comment thread tools/mcp_tool.py
@@ -2391,7 +2408,7 @@ def _convert_mcp_schema(server_name: str, mcp_tool) -> dict:
"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Current main no longer constructs native MCP names here: commit e01f58ff1 centralized the mcp__<server>__<tool> convention in mcp_prefixed_tool_name(). Apply the length guard in that shared helper so _convert_mcp_schema() and utility schemas use the same current naming path.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026

This branch has not been deployed

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

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/mcp MCP client and OAuth type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants