Bridge API¶
The stdio bridge adapts local MCP stdio clients to a Litestar MCP Streamable
HTTP endpoint. Most users should run it through Litestar's app-bound CLI:
litestar --app my_app:app mcp bridge. The functions below are available
for tests and embedded launchers.
run_stdio_streamable_http_bridge¶
- async litestar_mcp.bridge.run_stdio_streamable_http_bridge(endpoint, *, headers=None, token_provider=None, header_name='Authorization', token_prefix='Bearer ', timeout=30.0, sse_read_timeout=300.0, stdin=None, stdout=None, stderr=None, max_message_size=16777216)[source]¶
Bridge local stdio JSON-RPC to a Litestar Streamable HTTP MCP endpoint.
- Parameters:
headers¶ (
Optional[Mapping[str,str]]) -- Static HTTP headers sent to the endpoint.token_provider¶ (
Union[Callable[[],str],Callable[[],Awaitable[str]],None]) -- Optional callable that returns a fresh token per request.timeout¶ (
float) -- HTTP connect, write, and pool timeout in seconds.sse_read_timeout¶ (
float|None) -- Read timeout for streaming SSE responses.Noneor0disables quiet-period timeouts for server streams.stdin¶ (
Optional[ByteReceiveStream]) -- Optional byte receive stream for tests or embedding.stdout¶ (
Optional[ByteSendStream]) -- Optional byte send stream for tests or embedding.stderr¶ (
Optional[Any]) -- Optional diagnostic text stream. Defaults tosys.stderr.max_message_size¶ (
int) -- Maximum bytes allowed for one newline-delimited stdin JSON-RPC message. Set to-1to disable the limit.
- Return type:
- Returns:
Process-style exit code.
0means clean EOF/shutdown; non-zero means a transport or pump error was surfaced to the local stdio client.
DEFAULT_MAX_STDIN_MESSAGE_SIZE¶
- litestar_mcp.bridge.DEFAULT_MAX_STDIN_MESSAGE_SIZE = 16777216¶
int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by '+' or '-' and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int('0b100', base=0) 4
run_bridge¶
- litestar_mcp.bridge.run_bridge(endpoint, *, headers=None, token_provider=None, header_name='Authorization', token_prefix='Bearer ', timeout=30.0, sse_read_timeout=300.0, stdout=None, stderr=None, max_message_size=16777216)[source]¶
Synchronously run the stdio bridge for CLI integrations.
- Return type:
MissingDependencyError¶
- class litestar_mcp.bridge.MissingDependencyError[source]¶
Bases:
LitestarMCPError,ImportErrorMissing optional dependency.
This exception is raised when a module depends on a dependency that has not been installed.
- Parameters: