Askr documentation
Generated API snapshot

@askrjs/node/mcp

Exports from the declarations published in @askrjs/node. Signatures reflect the published artifact.

Exports

This entrypoint publishes 3 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

connectMcpStdiotype

connectMcpStdio: <Dependencies>(mcp: McpServer<Dependencies>, options: McpStdioOptions<Dependencies>) => McpStdioConnection

Connects an MCP server to newline-delimited JSON-RPC over stdio (or any pair of readable/writable streams). Reads one JSON-RPC message per line, dispatches it to `mcp.handle`, and writes the response back as a line of JSON. Handles request cancellation notifications, enforces `maxConcurrency` and `maxLineBytes`, and cleans up the MCP session when the connection closes.

McpStdioConnectiontype

McpStdioConnection: any

A live MCP stdio connection returned by {@link connectMcpStdio}.

closed
Resolves once the connection has fully closed.
close
Closes the connection, aborting in-flight requests and terminating the MCP session.

McpStdioOptionstype

McpStdioOptions: any

Options for {@link connectMcpStdio}.

dependencies
Application dependencies passed through to each MCP request.
input
Stream to read newline-delimited JSON-RPC requests from; defaults to `process.stdin`.
output
Stream to write newline-delimited JSON-RPC responses to; defaults to `process.stdout`.
diagnostics
Stream that non-protocol errors are reported to; defaults to `process.stderr`.
signal
Aborting this signal closes the connection.
auth
Auth context to use for requests, or a function that derives one from the environment.
environment
Environment passed to the `auth` function; defaults to `process.env`.
maxLineBytes
Maximum size, in bytes, of a single input line before it is rejected; defaults to 1 MiB.
maxConcurrency
Maximum number of requests handled concurrently; defaults to 16.