Skip to content

Conversation

pengwa
Copy link
Contributor

@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

Kludex
Kludex previously requested changes Jun 11, 2025
@pengwa
Copy link
Contributor 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
gspencergoog pushed a commit to gspencergoog/mcp-python-sdk that referenced this pull request Jul 29, 2025
@felixweinberger felixweinberger requested a review from a team as a code owner September 17, 2025 15:42
Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pengwa thanks for this contribution! And apologies for the time it took to get back to you on this.

Change looks good to me, let's just fix the duplicate logger instantiation - happy to get back to this quickly if you have bandwidth to make the update?

@felixweinberger felixweinberger added needs sync Needs sync with latest main branch to ensure CI passes needs more work Not ready to be merged yet, needs additional changes. labels Sep 17, 2025
@pengwa
Copy link
Contributor Author

pengwa commented Sep 18, 2025

Hi @pengwa thanks for this contribution! And apologies for the time it took to get back to you on this.

Change looks good to me, let's just fix the duplicate logger instantiation - happy to get back to this quickly if you have bandwidth to make the update?

Thanks @felixweinberger , thanks for reminding me there is such a PR here. Just updated the code, feel free to review again.

Copy link
Contributor

@felixweinberger felixweinberger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pengwa thanks for updating your PR.

@felixweinberger felixweinberger dismissed Kludex’s stale review September 26, 2025 14:37

Dismissing review as it's been addressed.

@felixweinberger felixweinberger removed the request for review from Kludex September 26, 2025 14:38
@felixweinberger felixweinberger merged commit 146d7ef into modelcontextprotocol:main Sep 26, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more work Not ready to be merged yet, needs additional changes. needs sync Needs sync with latest main branch to ensure CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants