fix(mcp): silence expected Method-not-found log noise and improve reload error messages#10292
Open
AJV20 wants to merge 3 commits into
Open
fix(mcp): silence expected Method-not-found log noise and improve reload error messages#10292AJV20 wants to merge 3 commits into
AJV20 wants to merge 3 commits into
Conversation
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.
355da15 to
fcf86b0
Compare
…-reload-error # Conflicts: # gateway/run.py # tools/mcp_tool.py
Author
|
Updated this PR branch in What changed:
Verification:
Current pushed head: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small quality-of-life fixes for MCP error handling.
1. Downgrade
list_resources/list_prompts"Method not found" from ERROR to DEBUGProblem:
_make_list_resources_handlerand_make_list_prompts_handlerlog atERRORlevel when a server returnsMcpError(-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:
Fix: Detect
McpErrorwith code-32601and log atDEBUGinstead, returning an empty{resources: []}/{prompts: []}so the caller degrades gracefully.2. Use
repr(e)for MCP reload error to avoid blank log messagesProblem:
_handle_reload_mcp_commandlogs failures aslogger.warning("MCP reload failed: %s", e). When the exception carries no message (e.g. a bareException()),str(e)is an empty string and the log line appears as:...giving no diagnostic information.
Fix: Use
repr(e)instead, which always includes the exception class name even when the message is empty.