fix: normalize numeric MCP server names to str (fixes #6901)#6962
Closed
kagura-agent wants to merge 1 commit into
Closed
fix: normalize numeric MCP server names to str (fixes #6901)#6962kagura-agent wants to merge 1 commit into
kagura-agent wants to merge 1 commit into
Conversation
YAML parses bare numeric keys (e.g. `12306:`) as int, causing TypeError when sorted() is called on mixed int/str collections. Changes: - Normalize toolset_names entries to str in _get_platform_tools() - Cast MCP server name to str(name) when building enabled_mcp_servers - Add regression test
Contributor
|
Merged via #7654 with authorship preserved. Thanks for the contribution! |
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.
Problem
When an MCP server is configured with a purely numeric name in
config.yaml(e.g.12306:without quotes), YAML parses the key asint. This causesTypeError: '<' not supported between instances of 'int' and 'str'whensorted()is called on the enabled toolsets collection.Root Cause
_get_platform_tools()inhermes_cli/tools_config.pyreturns aSet[str]but could containintvalues from two sources:toolset_nameslist fromplatform_toolsetsconfig (YAML int keys)enabled_mcp_serversset built frommcp_servers.items()(YAML int keys)Fix
toolset_namesentries tostrearly:[str(ts) for ts in toolset_names]str(name)when buildingenabled_mcp_serversTesting
test_numeric_mcp_server_name_does_not_crash_sortedthat reproduces the exact scenario with int keystest_tools_config.pypass (1 pre-existing failure unrelated)Closes #6901