Skip to content

fix(mcp): silence expected Method-not-found log noise and improve reload error messages#10292

Open
AJV20 wants to merge 3 commits into
NousResearch:mainfrom
AJV20:fix/mcp-log-noise-and-reload-error
Open

fix(mcp): silence expected Method-not-found log noise and improve reload error messages#10292
AJV20 wants to merge 3 commits into
NousResearch:mainfrom
AJV20:fix/mcp-log-noise-and-reload-error

Conversation

@AJV20

@AJV20 AJV20 commented Apr 15, 2026

Copy link
Copy Markdown

Summary

Two small quality-of-life fixes for MCP error handling.


1. Downgrade list_resources/list_prompts "Method not found" from ERROR to DEBUG

Problem: _make_list_resources_handler and _make_list_prompts_handler log at ERROR level when a server returns McpError(-32601 Method not found). This fires on every session that enumerates prompts or resources against a server that does not implement those optional capabilities — which is normal and expected per the MCP spec.

Result: every conversation produces spurious ERROR lines like:

ERROR tools.mcp_tool: MCP searxng/list_prompts failed: Method not found
ERROR tools.mcp_tool: MCP hermes-config/list_resources failed: Method not found

Fix: Detect McpError with code -32601 and log at DEBUG instead, returning an empty {resources: []} / {prompts: []} so the caller degrades gracefully.


2. Use repr(e) for MCP reload error to avoid blank log messages

Problem: _handle_reload_mcp_command logs failures as logger.warning("MCP reload failed: %s", e). When the exception carries no message (e.g. a bare Exception()), str(e) is an empty string and the log line appears as:

WARNING gateway.run: MCP reload failed: 

...giving no diagnostic information.

Fix: Use repr(e) instead, which always includes the exception class name even when the message is empty.

AJV20 added 2 commits April 17, 2026 20:05
list_resources and list_prompts return McpError(-32601) for servers that
don't implement those optional capabilities. This is expected behaviour,
not an error, so logging at ERROR level creates noise on every session
that tries to enumerate prompts or resources.

Fix: detect McpError with code -32601 and log at DEBUG instead, returning
an empty result so the caller degrades gracefully.
When an exception has no message (e.g. bare Exception()), str(e) is an
empty string, producing "MCP reload failed: " in logs with no useful
context. repr(e) always includes the exception type, making failures
diagnosable.
@AJV20 AJV20 force-pushed the fix/mcp-log-noise-and-reload-error branch from 355da15 to fcf86b0 Compare April 18, 2026 00:05
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have tool/mcp MCP client and OAuth labels Apr 26, 2026
…-reload-error

# Conflicts:
#	gateway/run.py
#	tools/mcp_tool.py
@AJV20

AJV20 commented May 22, 2026

Copy link
Copy Markdown
Author

Updated this PR branch in 35ced7bc8 after the latest main merge.

What changed:

  • Merged current origin/main into fix/mcp-log-noise-and-reload-error.
  • Resolved conflicts where needed by preserving this PR's scoped behavior while keeping current upstream changes.

Verification:

  • git diff --check; python3.11 -m py_compile gateway/run.py tools/mcp_tool.py

Current pushed head: 35ced7bc844f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have tool/mcp MCP client and OAuth type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants