fix(gateway): sanitize exposed MCP tool names for strict clients#528
Open
syf2211 wants to merge 1 commit into
Open
fix(gateway): sanitize exposed MCP tool names for strict clients#528syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
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
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.
Summary
Sanitize upstream tool names when exposing them through the gateway so strict MCP clients (e.g. Claude Desktop) accept
tools/listresponses.Motivation
Fixes #434. Catalog servers such as
husqvarna-automowerexpose 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
sanitizeMcpToolName,exposeToolName, anduniqueExposeToolNameinpkg/gateway/tool_names.golistCapabilities()for MCP servers and POCI toolscatalogToolNameWarningsdiagnostics with sanitized exposed namesCallToolstill uses the original upstream tool name via existing handlersTests
go test ./pkg/gateway/ -short -count=1All gateway unit tests pass.
Notes
_2,_3, … suffixes