Skip to content

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

@acherontia003

Description

@acherontia003

Bug Description

When an MCP server is configured with a purely numeric name (like 12306) in config.yaml, the YAML parser interprets the key as an int. During the gateway's initialization or
agent-run phase, the code collects all enabled toolsets (which are mostly strings) and the numeric MCP name into a list. When sorted() is called on this mixed-type list,
Python 3 raises a TypeError, causing the agent to crash with an "Empty response" or a visible traceback in the logs.

Steps to Reproduce

  1. Add a numeric MCP server to config.yaml:

1 mcp_servers:
2 12306: # Note: no quotes
3 command: uvx
4 args: ["mcp-server-12306"]
2. Start the Hermes Gateway.
3. Send a message to the agent (specifically in a platform that triggers toolset resolution, like Discord threads).
4. Observe the crash: TypeError: '<' not supported between instances of 'int' and 'str' in gateway/run.py.

Expected Behavior

The agent should handle numeric tool/MCP names gracefully by treating them as strings during the sorting and resolution process.

Actual Behavior

The agent crashes because sorted() cannot compare integers and strings in Python 3.

Affected Component

Configuration (config.yaml, .env, hermes setup)

Messaging Platform (if gateway-related)

Discord

Operating System

macOS / Linux

Python Version

3.11+

Hermes Version

v0.8.0

Relevant Logs / Traceback

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

In hermes-agent/gateway/run.py (and any other place where _get_platform_tools is sorted), explicitly convert the toolset names to strings before calling sorted().

File: hermes-agent/gateway/run.py

1 # Change this:
2 enabled_toolsets = sorted(_get_platform_tools(user_config, platform_key))
3
4 # To this:
5 enabled_toolsets = sorted([str(ts) for ts in _get_platform_tools(user_config, platform_key)])

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions