Skip to content

Add error log for client stdio #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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mcp/client/stdio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys
from contextlib import asynccontextmanager
Expand All @@ -19,6 +20,8 @@
terminate_windows_process,
)

logger = logging.getLogger(__name__)

# Environment variables to inherit by default
DEFAULT_INHERITED_ENV_VARS = (
[
Expand Down Expand Up @@ -145,6 +148,7 @@ async def stdout_reader():
try:
message = types.JSONRPCMessage.model_validate_json(line)
except Exception as exc:
logger.exception("Failed to parse JSONRPC message from server")
await read_stream_writer.send(exc)
continue

Expand Down
Loading