# @askrjs/node/mcp

> Published API exports for @askrjs/node/mcp.

Source: [https://askrjs.com/docs/reference/api/node/mcp](https://askrjs.com/docs/reference/api/node/mcp)

Status: stable. Packages: @askrjs/node/mcp.

**Published packages are authoritative.** Examples may lag behind a published contract. When guidance differs, verify the exports and TypeScript declarations in your installed package, then file an issue.

## Exports

This entrypoint publishes 3 exports from the declarations shipped by @askrjs/node.

### `connectMcpStdio`

```ts
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.

### `McpStdioConnection`

```ts
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.

### `McpStdioOptions`

```ts
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.

## Documentation navigation

[Previous](https://askrjs.com/docs/reference/api/node/root/index.md) | [Next](https://askrjs.com/docs/reference/api/otel/root/index.md)
