INNER CODE UNIT · Python
run_server
stevesolun/ctx · src/ctx/mcp_server/server.py:469
def run_server(
stdin: BinaryIO | None = None,
stdout: BinaryIO | None = None,
*,
allowed_tool_names: Iterable[str] | None = None,
allowed_entity_types: Iterable[str] | None = None,
) -> int:
"""Read JSON-RPC frames from ``stdin`` until EOF, write to ``stdout``.
Both args default to ``sys.stdin.buffer`` / ``sys.stdout.buffer``,
matching how an MCP host invokes the server as a subprocess.
Passing explicit streams lets tests drive the server without a
subprocess boundary.
Returns an exit code: 0 for clean EOF, 1 for a fatal error.
"""
in_stream: BinaryIO = stdin if stdin is not None else sys.stdin.buffer
out_stream: BinaryIO = stdout if stdout is not None else sys.stdout.buffer