Spanly Docs

Installation

Install the @spanly/sdk package and wire up your API key.

The TypeScript SDK ships as @spanly/sdk on npm. It works under Node, Bun, and Deno (with npm: specifiers). No native dependencies.

Install

npm install @spanly/sdk
# or
pnpm add @spanly/sdk
# or
yarn add @spanly/sdk
# or
bun add @spanly/sdk

Supported runtimes

RuntimeVersionsStatus
Node.js20 LTS, 22 LTSSupported
Bun≥ 1.1Supported
Deno≥ 1.40 (via npm:@spanly/sdk)Supported

The package is ESM-only and ships type definitions. Under CommonJS, load it with a dynamic import().

Configure the API key

The middleware reads the API key from the apiKey option, falling back to the SPANLY_API_KEY environment variable. Always source it from the environment, never hard-code it:

import express from 'express';
import { spanly } from '@spanly/sdk';

const app = express();
app.use(spanly({ apiKey: process.env.SPANLY_API_KEY }));

Get a key by signing in at spanly.com, opening your project, and going to Settings → API keys. The region (us / eu) is encoded in the key prefix, so no extra config is needed.

When to use the SDK vs the CLI

Mount spanly() (or wrapFetchHandler()) in front of your MCP server when it runs over HTTP on Node, Bun, or Deno. It needs no extra process, no sidecar, and no separate binary.

Reach for the Spanly CLI (@spanly/spanly) instead when:

  • Your MCP server speaks stdio, not HTTP.
  • Your server is not Node or Python (Go, Rust, Java, and so on).
  • You are running a Mend shim or canary (Mend rewriting lives in the CLI only, not in this SDK).
  • You are on AWS Lambda, where this SDK's serverless delivery guarantees do not hold. See Serverless delivery.
npx -y @spanly/spanly run -- node ./server.js

On this page