10000 Add error log for client stdio by pengwa · Pull Request #924 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

Add error log for client stdio 10000 #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pengwa
Copy link
@pengwa pengwa commented Jun 10, 2025

When use stdio mode, the server module is provided by developers (like me). But sometimes, the module not only call FastMCP().run(), but also other code. If the other code print something, then standard output will contains those text.

When stdio client read the standard output of the server module, it will fail to parse the content in expected content.

For example:

[50] Add mon5_log_handler to original_logger fsspec.mapping{"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-03-26","capabilities":{"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"draft_2025-06-10 13:37:18","version":"0.1.0"}}} """

[50] Add mon5_log_handler to original_logger is the log I printed by mistake before calling FastMCP().run().

Motivation and Context

It is really hard to finally locate the root cause, so we need a better logging showing such error clearly.

How Has This Been Tested?

Tested in a stdio mode. Let me know if you have any suggestions on what else test to be covered.

Breaking Changes

NO!

Types of changes

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • [x ] New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@pengwa
Copy link
Author
pengwa commented Jun 13, 2025

Resolved format issue. Please take a further look. @Kludex. THanks!

@pengwa pengwa requested a review from Kludex June 13, 2025 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0