hermes - 💡(How to fix) Fix [Bug]: mcp_serve string tool args can crash on malformed external client inputs [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

can raise before returning a structured JSON error. 3. Observe that some tool paths can raise before returning a structured JSON tool error. Required string fields should return a structured JSON error. Some malformed inputs can reach dict lookups, string-normalization logic, or downstream bridge calls with list/dict values and raise before the tool returns a controlled JSON error.

Additional Logs / Traceback (optional)

Several entrypoints use those values in string operations, dict lookups, or downstream bridge calls before validating type/shape. When malformed JSON values such as lists or dicts are passed, the handler can raise instead of returning a structured JSON error.

Root Cause

This issue is based on MCP tool boundary analysis rather than a platform-specific runtime environment. The failure mode is caused by malformed external JSON arguments reaching string-oriented tool entrypoints without defensive validation.

Fix Action

Fixed

Code Example

N/A

This issue is based on MCP tool boundary analysis rather than a platform-specific runtime environment. The failure mode is caused by malformed external JSON arguments reaching string-oriented tool entrypoints without defensive validation.

---
RAW_BUFFERClick to expand / collapse

Bug Description

Some mcp_serve.py tool entrypoints trust string-shaped arguments from external MCP clients. When a malformed client sends non-string JSON values for fields that are treated as str / Optional[str], the tool can raise before returning a structured JSON error. This is the same external-boundary hardening class as #21055, but for string arguments instead of numeric ones.

Steps to Reproduce

  1. Start the MCP server entrypoint that exposes the mcp_serve.py tools.
  2. Call string-accepting tools with malformed JSON values from an external MCP client, for example:
    • {"session_key": []}
    • {"message_id": []}
    • {"target": []}
    • {"platform": ["slack"]}
    • {"search": ["Alice"]}
  3. Observe that some tool paths can raise before returning a structured JSON tool error.

Expected Behavior

Malformed string-shaped arguments should not crash tool handlers. Required string fields should return a structured JSON error. Optional/filter-like string fields should ignore invalid structured values or coerce safe scalar values consistently.

Actual Behavior

Some malformed inputs can reach dict lookups, string-normalization logic, or downstream bridge calls with list/dict values and raise before the tool returns a controlled JSON error.

Affected Component

Tools (terminal, file ops, web, code execution, etc.)

Messaging Platform (if gateway-related)

No response

Debug Report

N/A

This issue is based on MCP tool boundary analysis rather than a platform-specific runtime environment. The failure mode is caused by malformed external JSON arguments reaching string-oriented tool entrypoints without defensive validation.

Operating System

windows 10 wsl

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

mcp_serve.py trusts annotated str / Optional[str] parameters from external MCP clients at the tool boundary.

Several entrypoints use those values in string operations, dict lookups, or downstream bridge calls before validating type/shape. When malformed JSON values such as lists or dicts are passed, the handler can raise instead of returning a structured JSON error.

This is the same class of issue previously fixed for numeric MCP arguments in #21055, but for string-shaped fields.

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix [Bug]: mcp_serve string tool args can crash on malformed external client inputs [2 pull requests]