Skip to content

fix: normalize numeric MCP server names to str (fixes #6901)#6962

Closed
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/numeric-mcp-server-name
Closed

fix: normalize numeric MCP server names to str (fixes #6901)#6962
kagura-agent wants to merge 1 commit into
NousResearch:mainfrom
kagura-agent:fix/numeric-mcp-server-name

Conversation

@kagura-agent

Copy link
Copy Markdown
Contributor

Problem

When an MCP server is configured with a purely numeric name in config.yaml (e.g. 12306: without quotes), YAML parses the key as int. This causes TypeError: '<' not supported between instances of 'int' and 'str' when sorted() is called on the enabled toolsets collection.

Root Cause

_get_platform_tools() in hermes_cli/tools_config.py returns a Set[str] but could contain int values from two sources:

  1. toolset_names list from platform_toolsets config (YAML int keys)
  2. enabled_mcp_servers set built from mcp_servers.items() (YAML int keys)

Fix

  • Normalize toolset_names entries to str early: [str(ts) for ts in toolset_names]
  • Cast MCP server names: str(name) when building enabled_mcp_servers

Testing

  • Added regression test test_numeric_mcp_server_name_does_not_crash_sorted that reproduces the exact scenario with int keys
  • All 19 existing tests in test_tools_config.py pass (1 pre-existing failure unrelated)

Closes #6901

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
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #7654 with authorship preserved. Thanks for the contribution!

@teknium1 teknium1 closed this Apr 11, 2026
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.

[Bug]: TypeError: '<' not supported between instances of 'int' and 'str' when using numeric MCP server names (e.g., "12306")

2 participants