Install mcprouter
Documentation for v0.0.1. Additional guides and API reference coverage are being expanded.
Install the core package
@surf-lab/mcprouter, version 0.0.1 is published on npm. Use a Node.js ESM application.
Install the latest release
Run this in your application directory:latest resolved to 0.0.1. A fresh public-npm install with lifecycle scripts disabled passed on Linux ARM64 with Node 24.21.0 and npm 11.19.0; the first governed call then passed with networking disabled. This verifies the core example, not the optional AI SDK integration or every dependency combination.
latest is a moving npm tag, not a version pin. These docs cover 0.0.1; future releases may differ. Commit your lockfile, and use the pinned command below when you need this documented release.
Pin the documented release
Can I use npx?
Not as a standalone command in0.0.1. mcprouter is an SDK library, not a CLI: the published package has no bin executable. Direct npx @surf-lab/mcprouter@latest fails with could not determine executable to run for this release. Do not use it as an install or server-start command.
Install with npm, import the SDK in your application, and run your own JavaScript with Node.js. For example, save the first governed call as first-call.mjs, then run node first-call.mjs from the same application directory. No global installation or npx wrapper is needed.
Choose optional AI SDK dependencies
The optional integration requires a compatibleai peer and a host-supplied model. Choose dependencies explicitly; mcprouter does not automatically install peers, apply patches, download models or discover providers.
- Core only: install just
@surf-lab/mcprouter; no AI SDK dependencies are needed. - Original vendor packages: install
aiand@ai-sdk/openaidirectly, with no patches or aliases. Use this path if you want the original packages, subject to the strict-TypeScript limitation below. - Optional patched packages: explicitly replace those two dependencies with the public
0.0.1aliases. Use these for the release’s qualified strict-TypeScript AI SDK profile; patches are not required just to use the integration.
Original vendor packages
For a vendor-only setup, copy this block. It installs the original packages, not mcprouter’s patched replacements:ai version 7.0.137 with @ai-sdk/openai version 4.0.91. These are exact reviewed pairs, not a recommendation to install arbitrary latest versions. The optional ai peer admits these versions, but admission alone is not compatibility evidence for every dependency graph or provider.
TypeScript caveat: both reviewed vendor pairs fail strict declaration checking with TypeScript 5.9.3; this is not evidence that the upstream runtime is broken. This command is not the release’s qualified strict-TypeScript profile. Keeping the original packages also means you do not receive the patch-specific declaration fixes or security dependency updates described below. Check your application’s resolved dependencies and lockfile separately.
Next: Use original vendor packages. generateText comes from original ai, createOpenAI from original @ai-sdk/openai, and toAITools separately from @surf-lab/mcprouter/ai-sdk. No patch option or different adapter is needed.
Optional patched packages
For the selected strict-TypeScript profile, install the patches under their upstream import names instead:
These are prepatched packages, not patch scripts consumers must run. An alias replaces what the whole application resolves under that dependency name, not only mcprouter’s usage. Test your existing application against that choice. Do not install upstream and patched copies under the same dependency key or assume isolated copies interoperate. The OpenAI provider here is
@ai-sdk/openai, not the separate openai npm client; other providers need their own compatibility checks.
Next: Use both patched packages together. See how the aliased imports connect createOpenAI → model construction → generateText, with toAITools supplied separately by mcprouter. These replacements are not plugins or options passed to generateText.
TypeScript compatibility boundary
The reviewed upstream pairs fail strict declaration checking with TypeScript5.9.3: shared @ai-sdk/provider-utils tool types disagree about optional properties and explicit undefined. This is a type-declaration finding, not evidence that the upstream runtime is broken, and it does not describe every future release.
The selected public patches address the declaration issue and include security dependency updates: bundled Undici 7.30.1 and a Zod peer floor of ^4.6.6. They are not merely declaration-only replacements. The selected profile pins zod to version 4.6.6 and retains strict, exactOptionalPropertyTypes and noUncheckedIndexedAccess, with skipLibCheck: false. Relaxing compiler checks would not repair upstream declarations.
One package, one integration subpath
The main package remains@surf-lab/mcprouter. Its optional @surf-lab/mcprouter/ai-sdk subpath contains createBoundedModel, createRoutingModel, createModelRanker and toAITools. It is part of the same package, not one of the patched dependencies or a separate npm installation. There is no /openai or /ai integration export. Importing /ai-sdk neither installs peers nor selects a provider; core imports do not eagerly load the AI SDK.
Runtime and release scope
The support contract is Node.js>=22.3.0 and npm >=10.9.0 on compatible pairs. Ten exact-candidate Linux compatibility cells and native macOS/Windows Node 22/24 core smoke checks passed. Windows smoke is not the full Linux suite or proof of whole-process-tree isolation. CommonJS, browsers and universal MCP protocol/provider compatibility are not supported claims.
Fresh public-registry core and selected-peer consumers passed installed exports, strict declarations and offline runtime checks on Linux ARM64 with Node 24.21.0, npm 11.21.0 and TypeScript 5.9.3. Core’s fresh transitive Zod 4.6.7 resolution has core smoke/type evidence only, not a repeat of the selected-peer/model matrix. Version ranges do not qualify every future dependency graph.
All three 0.0.1 public archives were verified against the approved release bytes. Npm attestation is explicitly deferred, not verified, for these three initial 0.0.1 releases only. Integrity checks are not attestations or permission to publish another version. See security and trust boundaries.
For offline checks, provision dependencies first and deny external networking during execution rather than falling back to a registry. Imports must resolve from installed public packages, not a source-tree or dist alias.
After installing, try a synthetic first governed call. See integration choices before setting up a model or a remote MCP endpoint.