Convert Express.js OpenAPI / Swagger Docs to MCP
Already documenting your Express.js REST API with swagger-jsdoc, tsoa, or zod-to-openapi? Export your JSON spec and ship a production MCP server in under a minute.
MCP Tool Selection
6 / 10 Free6 endpoints parsed • 1 safety-guarded
List Stripe customers
Create a Stripe customer
Retrieve a subscription by ID
Cancel an active subscription immediately
List billing invoices
Create a hosted Stripe payment link
1#!/usr/bin/env node2/**3* Generated by Spec2MCP (https://spec2mcp.com)4* Server: stripe-billing-api v2025-02-245* Tools exposed: 66*/7import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";8import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";9import { z } from "zod";1011const BASE_URL = (process.env.STRIPE_BILLING_API_BASE_URL ?? "https://api.stripe.com/v1").replace(/\/+$/, "");12const API_TOKEN = process.env.STRIPE_BILLING_API_API_TOKEN ?? "";13function buildAuthHeaders(): Record<string, string> {14return API_TOKEN ? { Authorization: `Bearer ${API_TOKEN}` } : {};15}1617interface UpstreamRequest {18method: string;19path: string;20query?: URLSearchParams;21body?: Record<string, unknown>;22}2324async function callUpstream(req: UpstreamRequest) {25const qs = req.query && req.query.toString() ? `?${req.query.toString()}` : "";26const url = `${BASE_URL}${req.path}${qs}`;2728const headers: Record<string, string> = {29Accept: "application/json",30"User-Agent": "spec2mcp/stripe-billing-api",31...buildAuthHeaders(),32};3334if (req.body !== undefined) {35headers["Content-Type"] = "application/json";36}3738try {39const controller = new AbortController();40const timer = setTimeout(() => controller.abort(), 20_000);41const response = await fetch(url, {42method: req.method,43headers,44body: req.body !== undefined ? JSON.stringify(req.body) : undefined,45signal: controller.signal,46});47clearTimeout(timer);4849const rawText = await response.text();50let formatted = rawText;51try {52formatted = JSON.stringify(JSON.parse(rawText), null, 2);53} catch {54// keep raw text if upstream returned non-JSON55}5657if (!response.ok) {58return {59isError: true,60content: [61{62type: "text" as const,63text: `HTTP ${response.status} ${response.statusText} from ${req.method} ${req.path}\n${formatted}`,64},65],66};67}6869return {70content: [71{72type: "text" as const,73text: formatted || `HTTP ${response.status} (empty body)`,74},75],76};77} catch (err) {78const message = err instanceof Error ? err.message : String(err);79return {80isError: true,81content: [82{83type: "text" as const,84text: `Network error calling ${req.method} ${url}: ${message}`,85},86],87};88}89}9091const server = new McpServer({92name: "stripe-billing-api",93version: "2025-02-24",94});9596server.tool(97"list_customers",98"List Stripe customers [GET /customers]",99{100"email": z.string().describe("Filter exact customer email").optional(),101"limit": z.number().int().describe("Max results (1-100)").optional(),102},103{104title: "List Stripe customers",105readOnlyHint: true,106destructiveHint: false,107idempotentHint: true,108openWorldHint: true,109},110async (args) => {111const query = new URLSearchParams();112if (args["email"] !== undefined) query.set("email", String(args["email"]));113if (args["limit"] !== undefined) query.set("limit", String(args["limit"]));114return callUpstream({115method: "GET",116path: "/customers",117query,118});119}120);121122server.tool(123"create_customer",124"Create a Stripe customer [POST /customers]",125{126"email": z.string().describe("Customer email address"),127"name": z.string().describe("Customer full name or company").optional(),128"description": z.string().describe("Internal billing memo").optional(),129},130{131title: "Create a Stripe customer",132readOnlyHint: false,133destructiveHint: false,134idempotentHint: false,135openWorldHint: true,136},137async (args) => {138const bodyPayload: Record<string, unknown> = {};139if (args["email"] !== undefined) bodyPayload["email"] = args["email"];140if (args["name"] !== undefined) bodyPayload["name"] = args["name"];141if (args["description"] !== undefined) bodyPayload["description"] = args["description"];142return callUpstream({143method: "POST",144path: "/customers",145body: bodyPayload,146});147}148);149150server.tool(151"get_subscription",152"Retrieve a subscription by ID [GET /subscriptions/{subscription_id}]",153{154"subscription_id": z.string().describe("Stripe subscription ID (sub_...)"),155},156{157title: "Retrieve a subscription by ID",158readOnlyHint: true,159destructiveHint: false,160idempotentHint: true,161openWorldHint: true,162},163async (args) => {164return callUpstream({165method: "GET",166path: `/subscriptions/${encodeURIComponent(String(args["subscription_id"]))}`,167});168}169);170171server.tool(172"cancel_subscription",173"Cancel an active subscription immediately [DELETE /subscriptions/{subscription_id}]",174{175"subscription_id": z.string().describe("Stripe subscription ID to cancel"),176"prorate": z.boolean().describe("Generate final prorated invoice item").optional(),177confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this DELETE operation."),178},179{180title: "Cancel an active subscription immediately",181readOnlyHint: false,182destructiveHint: true,183idempotentHint: false,184openWorldHint: true,185},186async (args) => {187if (!args.confirm_destructive_action) {188return {189isError: true,190content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],191};192}193const query = new URLSearchParams();194if (args["prorate"] !== undefined) query.set("prorate", String(args["prorate"]));195return callUpstream({196method: "DELETE",197path: `/subscriptions/${encodeURIComponent(String(args["subscription_id"]))}`,198query,199});200}201);202203server.tool(204"list_invoices",205"List billing invoices [GET /invoices]",206{207"customer": z.string().describe("Filter by Stripe customer ID (cus_...)").optional(),208"status": z.enum(["draft", "open", "paid", "uncollectible", "void"]).describe("Invoice payment status").optional(),209},210{211title: "List billing invoices",212readOnlyHint: true,213destructiveHint: false,214idempotentHint: true,215openWorldHint: true,216},217async (args) => {218const query = new URLSearchParams();219if (args["customer"] !== undefined) query.set("customer", String(args["customer"]));220if (args["status"] !== undefined) query.set("status", String(args["status"]));221return callUpstream({222method: "GET",223path: "/invoices",224query,225});226}227);228229server.tool(230"create_payment_link",231"Create a hosted Stripe payment link [POST /payment_links]",232{233"price_id": z.string().describe("Stripe Price ID (price_...)"),234"quantity": z.number().int().describe("Line item quantity"),235"allow_promotion_codes": z.boolean().describe("Allow checkout promo codes").optional(),236},237{238title: "Create a hosted Stripe payment link",239readOnlyHint: false,240destructiveHint: false,241idempotentHint: false,242openWorldHint: true,243},244async (args) => {245const bodyPayload: Record<string, unknown> = {};246if (args["price_id"] !== undefined) bodyPayload["price_id"] = args["price_id"];247if (args["quantity"] !== undefined) bodyPayload["quantity"] = args["quantity"];248if (args["allow_promotion_codes"] !== undefined) bodyPayload["allow_promotion_codes"] = args["allow_promotion_codes"];249return callUpstream({250method: "POST",251path: "/payment_links",252body: bodyPayload,253});254}255);256257async function main() {258const transport = new StdioServerTransport();259await server.connect(transport);260console.error("stripe-billing-api MCP server listening on stdio (6 tools)");261}262263main().catch((err) => {264console.error("Fatal MCP server error:", err);265process.exit(1);266});267
How to export & compile your Express.js OpenAPI spec
Fetch your Express swagger-ui JSON route (often /api-docs.json or /swagger.json) and upload it to Spec2MCP.
High-Signal Express.js MCP Tools to Expose First
| Method | Endpoint Path | MCP Tool Name | Purpose |
|---|---|---|---|
| GET | /api/users | list_users | Express GET route with query pagination |
| POST | /api/projects | create_project | JSON body validated with Zod before hitting Express |
| DELETE | /api/projects/{id} | delete_project | Protected with destructive confirmation guard |
Best Practices for Express.js
- Place the generated MCP server inside a monorepo package (e.g., packages/mcp-server) so developers can run npm run build alongside Express.
- Document response/parameter enums in your JSDoc or Zod OpenAPI definitions so the generated Zod schemas constrain LLM arguments tightly.
- Use the studio's token estimator to ensure your Express API's MCP surface stays under 3,000 tokens.
Common Express.js MCP Gotchas
- swagger-jsdoc annotations sometimes forget to specify servers[0].url—update the Base URL field in Spec2MCP to http://localhost:3000 before downloading.
- If your Express API relies on session cookies instead of stateless Bearer/API Key headers, add an internal service API key middleware for MCP calls.
- Ensure your Express server parses application/json (app.use(express.json())) for all POST/PATCH tools.
Express.js OpenAPI to MCP Server — Frequently Asked Questions
Which Express OpenAPI libraries are compatible with Spec2MCP?
Any library that outputs standard Swagger 2.0 or OpenAPI 3.x JSON works seamlessly—including swagger-jsdoc, tsoa, express-openapi-validator, and @asteasolutions/zod-to-openapi.
Can Cursor talk to my local Express dev server via MCP?
Yes! Point BASE_URL to http://localhost:3000 in .cursor/mcp.json and Cursor can inspect and test your local Express routes live.
Does the generated TypeScript server require Express as a dependency?
No. It only depends on @modelcontextprotocol/sdk and zod, communicating with your Express service over standard HTTP fetch().
Related OpenAPI-to-MCP Converters
View all 20NestJS JwtAuthGuard (Bearer) or ApiKeyGuard header
Bearer, API Key Header/Query, or Basic via process.env
Auto-detects Swagger 2.0 securityDefinitions (apiKey, basic, oauth2)
Cloudflare Worker Secrets / OAuth2 Bearer Proxy
Free locally forever. Upgrade when your team goes remote.
Compile focused local TypeScript & Python MCP servers in your browser for $0. Move to Pro Cloud or Team when you need unlimited endpoints, hosted Remote MCP URLs, OAuth2 proxying, and CI sync.
Everything solo engineers need to turn REST APIs into local stdio MCP servers with zero login.
- Local TypeScript SDK + Zod codegen
- Local Python FastMCP + httpx codegen
- Up to 10 endpoints per MCP server
- Live context-window token estimator
- Destructive action confirmation guards
- Claude Desktop, Cursor, Windsurf & Antigravity mcp.json
- 100% client-side — specs stay in browser
Compile unlimited endpoints and publish a hosted Remote MCP URL with encrypted credential vaulting.
- Unlimited OpenAPI endpoints & tool grouping
- 1-click hosted Remote MCP endpoint (Streamable HTTP)
- Encrypted OAuth2 & API-Key secret vault
- Custom tool presets & OpenAPI overlay persistence
- Response payload truncation to stop context blowups
- Priority email & Discord support
Built for engineering orgs keeping internal MCP servers automatically synced with OpenAPI repos.
- Everything in Pro Cloud
- GitHub / GitLab CI auto-sync on OpenAPI PR merges
- Per-tool invocation audit logs & latency metrics
- Per-user rate limits & destructive-tool approval policies
- Role-based access across engineering & ops teams
- Dedicated onboarding & custom auth helpers