npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spec2tools/stdio-mcp

v0.2.1

Published

MCP server that exposes OpenAPI endpoints as tools via stdio transport

Readme

@spec2tools/stdio-mcp

MCP (Model Context Protocol) server that exposes OpenAPI endpoints as tools via stdio transport. This allows AI agents like Claude to call any API described by an OpenAPI specification.

Installation

npm install @spec2tools/stdio-mcp
# or
pnpm add @spec2tools/stdio-mcp

Quick Start

With Claude Code

# Add as an MCP server
claude mcp add stdio my-api \
  -- npx @spec2tools/stdio-mcp ./path/to/openapi.yaml

# With authentication
claude mcp add --env API_KEY=your-api-key my-api \
  -- npx @spec2tools/stdio-mcp ./openapi.yaml

# With code mode (2 tools: search + execute)
claude mcp add my-api \
  -- npx @spec2tools/stdio-mcp ./openapi.yaml --code-mode

With Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "my-api": {
      "command": "npx",
      "args": ["@spec2tools/stdio-mcp", "./path/to/openapi.yaml"]
    }
  }
}

For authenticated APIs:

{
  "mcpServers": {
    "my-api": {
      "command": "npx",
      "args": ["@spec2tools/stdio-mcp", "./openapi.yaml", "--api-key", "your-api-key"]
    }
  }
}

CLI Usage

# Start server with local spec
spec2tools-mcp ./openapi.yaml

# Start server with remote spec
spec2tools-mcp https://api.example.com/openapi.json

# Start with authentication
spec2tools-mcp ./api.yaml --api-key your-api-key

# Or use environment variable
API_KEY=your-api-key spec2tools-mcp ./api.yaml

Remote MCP Server

Proxy an existing remote MCP server through stdio. This lets you connect any HTTP or SSE-based MCP server to clients that only support stdio transport (like Claude Desktop), and optionally apply code mode to reduce token usage.

# Proxy via Streamable HTTP
spec2tools-mcp --http https://example.com/mcp

# Proxy via SSE
spec2tools-mcp --sse https://example.com/sse

# Proxy with code mode
spec2tools-mcp --sse https://example.com/sse --code-mode

With Claude Code:

claude mcp add my-remote-api \
  -- npx @spec2tools/stdio-mcp --sse https://example.com/sse --code-mode

Code Mode

Code mode collapses all API endpoints into 2 tools (search + execute), reducing token usage by ~99.9%. The model discovers endpoints via keyword search and calls them by writing Python code in a sandboxed interpreter.

spec2tools-mcp ./openapi.yaml --code-mode

Programmatic Usage

import { startMcpServer } from '@spec2tools/stdio-mcp';

await startMcpServer({
  spec: './openapi.yaml',
  name: 'my-api-server',
  version: '1.0.0',
  apiKey: 'your-api-key', // optional
});

CLI Options

| Option | Description | |--------|-------------| | <spec-path> | Path or URL to OpenAPI specification (JSON or YAML) | | --name <name> | Server name for MCP (default: openapi-mcp-server) | | --version <ver> | Server version for MCP (default: 1.0.0) | | --api-key <key> | API key or bearer token for authentication | | --http <url> | Connect to a remote MCP server (Streamable HTTP) | | --sse <url> | Connect to a remote MCP server (SSE transport) | | --code-mode | Use code mode (2 tools: search + execute) | | -h, --help | Show help message |

Environment Variables

| Variable | Description | |----------|-------------| | API_KEY | API key or bearer token for authentication |

How It Works

  1. Loads OpenAPI Spec: Reads your OpenAPI 3.x specification from a local file or URL (supports both JSON and YAML)

  2. Parses Operations: Converts each API operation into an MCP tool with:

    • Tool name from operationId (or generated from method + path)
    • Description from summary or description
    • Input schema from parameters and request body
  3. Starts MCP Server: Creates a stdio-based MCP server that AI agents can connect to

  4. Handles Tool Calls: When an agent calls a tool, the server:

    • Validates the parameters
    • Builds the HTTP request (URL, headers, body)
    • Adds authentication if configured
    • Executes the request and returns the response

Supported OpenAPI Features

  • HTTP Methods: GET, POST, PUT, PATCH, DELETE
  • Parameters: Path and query parameters (string, number, boolean, arrays)
  • Request Bodies: JSON with primitives and flat objects
  • Authentication: Bearer tokens, API keys (header or query)

Limitations

  • Nested objects beyond 1 level deep are not supported
  • Arrays of objects are not supported
  • Schema composition (anyOf, oneOf, allOf) is not supported
  • File uploads are not supported
  • $ref schema references are not supported

Example

Given this OpenAPI spec:

openapi: 3.0.0
info:
  title: User API
  version: 1.0.0
servers:
  - url: https://api.example.com
paths:
  /users:
    get:
      operationId: listUsers
      summary: List all users
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
      responses:
        '200':
          description: Success
  /users/{id}:
    get:
      operationId: getUser
      summary: Get user by ID
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Success

The MCP server will expose two tools:

  • listUsers(limit?: number) - List all users
  • getUser(id: number) - Get user by ID

An AI agent can then call these tools naturally:

"Get me the user with ID 42"

The agent will call getUser({ id: 42 }) and receive the API response.

Related Packages

License

MIT