MCPcopy
hub / github.com/modelcontextprotocol/python-sdk / stdin_reader

Function stdin_reader

src/mcp/server/stdio.py:49–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47 write_stream, write_stream_reader = create_context_streams[SessionMessage](0)
48
49 async def stdin_reader():
50 try:
51 async with read_stream_writer:
52 async for line in stdin:
53 try:
54 message = types.jsonrpc_message_adapter.validate_json(line, by_name=False)
55 except Exception as exc:
56 await read_stream_writer.send(exc)
57 continue
58
59 session_message = SessionMessage(message)
60 await read_stream_writer.send(session_message)
61 except anyio.ClosedResourceError: # pragma: no cover
62 await anyio.lowlevel.checkpoint()
63
64 async def stdout_writer():
65 try:

Callers

nothing calls this directly

Calls 2

SessionMessageClass · 0.90
sendMethod · 0.45

Tested by

no test coverage detected