Skip to content

fix(gateway): sanitize exposed MCP tool names for strict clients#528

Open
syf2211 wants to merge 1 commit into
docker:mainfrom
syf2211:fix/sanitize-tool-names
Open

fix(gateway): sanitize exposed MCP tool names for strict clients#528
syf2211 wants to merge 1 commit into
docker:mainfrom
syf2211:fix/sanitize-tool-names

Conversation

@syf2211

@syf2211 syf2211 commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Sanitize upstream tool names when exposing them through the gateway so strict MCP clients (e.g. Claude Desktop) accept tools/list responses.

Motivation

Fixes #434. Catalog servers such as husqvarna-automower expose tool names with spaces (e.g. Husqvarna Automowers Status), which violate the MCP tool name pattern ^[a-zA-Z0-9_-]{1,64}$ and break client validation.

Changes

  • Add sanitizeMcpToolName, exposeToolName, and uniqueExposeToolName in pkg/gateway/tool_names.go
  • Apply sanitized exposed names in listCapabilities() for MCP servers and POCI tools
  • Align catalogToolNameWarnings diagnostics with sanitized exposed names
  • Backend CallTool still uses the original upstream tool name via existing handlers

Tests

go test ./pkg/gateway/ -short -count=1

All gateway unit tests pass.

Notes

  • Intra-server collisions after sanitization are resolved with _2, _3, … suffixes
  • Cross-server collisions continue to be rejected by existing collision validation
  • Composer-2.5 pre-PR review: APPROVE

Replace invalid characters in upstream tool names when exposing them
through the gateway so clients like Claude Desktop accept tools/list
responses. Backend tool calls still use the original upstream names.

Fixes docker#434
@syf2211 syf2211 requested a review from a team as a code owner June 27, 2026 19:42
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.

Husqvarna Automower tool name contains spaces, breaks Claude Desktop validation

1 participant