hermes - ✅(Solved) Fix MCP stdio: Cannot read properties of undefined (reading '_zod') with @postman/postman-mcp-server [1 pull requests, 1 participants]

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…
GitHub stats
NousResearch/hermes-agent#16386Fetched 2026-04-28 06:53:45
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×1

Error Message

mcp.shared.exceptions.McpError: Cannot read properties of undefined (reading '_zod') File ".../mcp/client/session.py", line 529, in list_tools result = await self.send_request(...)

Root Cause

The Postman MCP server uses the @modelcontextprotocol/sdk Node.js package internally. When it responds to tools/list requests, the JSON-RPC response contains tool definitions with Zod schema metadata attached (the inputSchema objects have been processed by Zod and contain internal _zod properties).

However, the Node.js stdout transport prepends a debug/status line before the JSON response:

◇ injected env (0) from .env // tip: ⌘ enable debugging { debug: true }

When the Python MCP SDK's stdio reader reads this line, it tries to parse it as JSON and fails. Even when the reader recovers and processes the actual JSON responses, it encounters tool schemas that reference Zod internals that aren't properly serialized in the JSON-RPC protocol.

Fix Action

Fix / Workaround

Workaround: Use HTTP transport instead:

mcp_servers:
  postman:
    url: https://mcp.postman.com/minimal
    headers:
      Authorization: Bearer ${POSTMAN_API_KEY}
    enabled: true

PR fix notes

PR #16390: fix(mcp): gracefully handle tool discovery failures in MCPServerTask

Description (problem / solution / changelog)

Summary

Some MCP servers (e.g. @postman/postman-mcp-server) fail during tools/list due to internal Zod schema processing bugs, returning errors like Cannot read properties of undefined (reading _zod).

This change wraps _discover_tools() in a try/except so that tool discovery failures are logged as warnings and result in an empty tool list rather than propagating as an unhandled exception. The MCP server connection stays alive, allowing users to work around the issue.

Related issue: #16386

Workaround: Use HTTP transport instead of stdio for affected servers.

Changed files

  • tools/mcp_tool.py (modified, +18/-6)

Code Example

Cannot read properties of undefined (reading '_zod')

---

◇ injected env (0) from .env // tip: ⌘ enable debugging { debug: true }

---

mcp.shared.exceptions.McpError: Cannot read properties of undefined (reading '_zod')
  File ".../mcp/client/session.py", line 529, in list_tools
    result = await self.send_request(...)

---

mcp_servers:
  postman:
    command: /path/to/postman-mcp-wrapper
    args: []
    enabled: true

---

mcp_servers:
  postman:
    url: https://mcp.postman.com/minimal
    headers:
      Authorization: Bearer ${POSTMAN_API_KEY}
    enabled: true
RAW_BUFFERClick to expand / collapse

Bug Description

When using hermes-agent with the Postman MCP server via stdio transport, the connection fails with the error:

Cannot read properties of undefined (reading '_zod')

This error occurs during the tools/list MCP request/response cycle.

Environment

  • hermes-agent: latest (NousResearch/hermes-agent)
  • @postman/postman-mcp-server: 2.3.0 (also tested 2.3.7)
  • MCP Python SDK: 1.26.0
  • macOS

Root Cause Analysis

The Postman MCP server uses the @modelcontextprotocol/sdk Node.js package internally. When it responds to tools/list requests, the JSON-RPC response contains tool definitions with Zod schema metadata attached (the inputSchema objects have been processed by Zod and contain internal _zod properties).

However, the Node.js stdout transport prepends a debug/status line before the JSON response:

◇ injected env (0) from .env // tip: ⌘ enable debugging { debug: true }

When the Python MCP SDK's stdio reader reads this line, it tries to parse it as JSON and fails. Even when the reader recovers and processes the actual JSON responses, it encounters tool schemas that reference Zod internals that aren't properly serialized in the JSON-RPC protocol.

Error Traceback

mcp.shared.exceptions.McpError: Cannot read properties of undefined (reading '_zod')
  File ".../mcp/client/session.py", line 529, in list_tools
    result = await self.send_request(...)

Steps to Reproduce

  1. Configure hermes-agent with Postman MCP server in stdio mode:
mcp_servers:
  postman:
    command: /path/to/postman-mcp-wrapper
    args: []
    enabled: true
  1. Run hermes mcp test postman or any operation that requires tool discovery

Workaround: Use HTTP transport instead:

mcp_servers:
  postman:
    url: https://mcp.postman.com/minimal
    headers:
      Authorization: Bearer ${POSTMAN_API_KEY}
    enabled: true

Suggested Fix

The hermes-agent stdio transport reader should:

  1. Skip/ignore non-JSON output lines (like the ◇ injected env... debug line)
  2. Handle cases where tool inputSchema contains non-serializable Zod internals

A robust fix would be to add a JSON line filter in the stdio reader that skips lines not starting with {.

extent analysis

TL;DR

Modify the hermes-agent stdio transport reader to skip non-JSON output lines and handle non-serializable Zod internals in tool schemas.

Guidance

  • Implement a JSON line filter in the stdio reader to ignore lines not starting with {, such as the ◇ injected env... debug line.
  • Update the stdio reader to handle cases where tool inputSchema contains non-serializable Zod internals, potentially by removing or serializing these properties.
  • Consider using the provided workaround of switching to HTTP transport until a robust fix is implemented.
  • Verify the fix by running hermes mcp test postman and checking for successful tool discovery.

Example

import json

def filter_json_lines(lines):
    json_lines = []
    for line in lines:
        if line.startswith('{'):
            try:
                json.loads(line)
                json_lines.append(line)
            except json.JSONDecodeError:
                pass
    return json_lines

Notes

The provided workaround using HTTP transport may not be suitable for all environments or use cases, so a robust fix for the stdio transport reader is necessary.

Recommendation

Apply the workaround by switching to HTTP transport until a robust fix is implemented, as it provides a reliable solution for the time being.

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 - ✅(Solved) Fix MCP stdio: Cannot read properties of undefined (reading '_zod') with @postman/postman-mcp-server [1 pull requests, 1 participants]