
# Benchmarks

> `okmcp` compared with the official `@modelcontextprotocol/sdk` on bundle size, install footprint and `tools/call` throughput.

![okmcp vs @modelcontextprotocol/sdk: bundle size and throughput](/benchmarks.svg)

## Setup

Both libraries serve the same small MCP server: two tools, one resource and one prompt, with Zod schemas on both sides.

- **`okmcp`** runs one stateless, dual-era handler (`2026-07-28` + `≤2025-11-25`).
- **SDK** runs `McpServer` with the Streamable HTTP transport. It is measured with sessions, which reuse one transport, and without them, which builds a new server per request. The chart compares `okmcp` with whichever of the two is faster.

## Bundle Size

Each server is bundled and minified with esbuild. The size counts everything shipped except `node:` builtins. The H3 bytes count toward `okmcp` because its handler runs on H3.

`okmcp` accepts any Standard Schema or plain JSON Schema, so Zod is optional. The SDK requires Zod.

## Throughput

Each server answers the same `tools/call` over HTTP on loopback, with Zod-validated arguments. Every server starts in a fresh process for each round, and the median round is reported.

## Caveats

- The SDK is v1.x, which stops at `2025-11-25`.
- The SDK's fastest setup relies on protocol sessions, which `2026-07-28` removes. `okmcp` reaches its number without one.
- The feature sets differ. The SDK includes sampling, elicitation, roots and tasks. `okmcp` includes the `2026-07-28` era, but its extensions are not installed for these runs.
- The tool call is cheap, so the numbers show the overhead the library adds to each call. A handler that does real I/O spends far more time than either library.
- Results depend on the machine. Compare the ratios, not the absolute numbers.

## Run It Yourself

The benchmarks need Node.js 26:

```sh
cd bench
npm run setup   # once
npm run bench   # measure and render the chart
```
