MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / _parse_line

Function _parse_line

src/mcp/client/stdio.py:218–225  ·  view source on GitHub ↗

Parses one stdout line, returning parse errors as values for the session to surface.

(line: str)

Source from the content-addressed store, hash-verified

216
217
218def _parse_line(line: str) -> SessionMessage | Exception:
219 """Parses one stdout line, returning parse errors as values for the session to surface."""
220 try:
221 message = types.jsonrpc_message_adapter.validate_json(line, by_name=False)
222 except ValueError as exc:
223 logger.exception("Failed to parse JSONRPC message from server")
224 return exc
225 return SessionMessage(message)
226
227
228async def _drain_stdout(process: ServerProcess) -> None:

Callers 1

stdout_readerFunction · 0.85

Calls 1

SessionMessageClass · 0.90

Tested by

no test coverage detected