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

@ezmcpz/openapi

v0.1.3

Published

OpenAPI integration for EZMCPZ with automatic tool generation

Downloads

17

Readme

@ezmcpz/openapi

Automatic MCP tool generation from OpenAPI/Swagger specifications.

Installation

npm install @ezmcpz/openapi
# or
pnpm add @ezmcpz/openapi

Quick Start

import { McpServer } from '@ezmcpz/core';
import { openApiTools } from '@ezmcpz/openapi';

const server = new McpServer({
  name: 'api-server',
  version: '1.0.0'
})
  .use(openApiTools({
    spec: 'https://api.example.com/openapi.json',
    autoGenerate: true,
    prefix: 'api_',
    auth: {
      type: 'bearer',
      token: process.env.API_TOKEN
    }
  }));

await server.start();

Features

  • Automatic Tool Generation: Convert OpenAPI operations to MCP tools
  • Type Safety: Generate Zod schemas from OpenAPI schemas
  • Authentication: Support for Bearer, API Key, and Basic auth
  • Flexible Configuration: Include/exclude specific operations
  • Custom Naming: Override tool names and descriptions

Configuration

Basic Options

openApiTools({
  spec: './openapi.yaml',        // URL or file path
  autoGenerate: true,             // Auto-generate all operations
  prefix: 'api_',                 // Prefix for tool names
  baseUrl: 'https://api.example.com' // Override base URL
})

Authentication

// Bearer token
openApiTools({
  spec: './openapi.yaml',
  auth: {
    type: 'bearer',
    token: process.env.API_TOKEN
  }
})

// API Key
openApiTools({
  spec: './openapi.yaml',
  auth: {
    type: 'apiKey',
    apiKey: process.env.API_KEY,
    headerName: 'X-API-Key'
  }
})

// Basic auth
openApiTools({
  spec: './openapi.yaml',
  auth: {
    type: 'basic',
    username: 'user',
    password: 'pass'
  }
})

Selective Operations

// Include only specific operations
openApiTools({
  spec: './openapi.yaml',
  includeOperations: [
    'GET /users',
    'POST /users',
    'GET /users/{id}'
  ]
})

// Exclude specific operations
openApiTools({
  spec: './openapi.yaml',
  excludeOperations: [
    'DELETE /users/{id}'
  ]
})

Custom Tool Configuration

openApiTools({
  spec: './openapi.yaml',
  operations: {
    'GET /users': {
      toolName: 'list_users',
      description: 'List all users in the system'
    },
    'POST /users': {
      toolName: 'create_user',
      description: 'Create a new user'
    }
  }
})

Complete Example

import { McpServer } from '@ezmcpz/core';
import { httpTransport } from '@ezmcpz/transport-http';
import { openApiTools } from '@ezmcpz/openapi';

const server = new McpServer({
  name: 'github-api',
  version: '1.0.0'
})
  .use(openApiTools({
    spec: 'https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json',
    prefix: 'github_',
    auth: {
      type: 'bearer',
      token: process.env.GITHUB_TOKEN
    },
    includeOperations: [
      'GET /repos/{owner}/{repo}',
      'GET /repos/{owner}/{repo}/issues',
      'POST /repos/{owner}/{repo}/issues'
    ],
    operations: {
      'GET /repos/{owner}/{repo}': {
        toolName: 'get_repository',
        description: 'Get repository information'
      },
      'GET /repos/{owner}/{repo}/issues': {
        toolName: 'list_issues',
        description: 'List repository issues'
      },
      'POST /repos/{owner}/{repo}/issues': {
        toolName: 'create_issue',
        description: 'Create a new issue'
      }
    }
  }))
  .use(httpTransport({ port: 3000 }));

await server.start();

Programmatic Usage

You can also use the tool generator directly:

import { parseOpenAPISpec, generateTools } from '@ezmcpz/openapi';

// Parse spec
const spec = await parseOpenAPISpec('./openapi.yaml');

// Generate tools
const tools = generateTools(spec, {
  prefix: 'api_',
  autoGenerate: true,
  auth: {
    type: 'bearer',
    token: 'my-token'
  }
});

// Register tools manually
for (const tool of tools) {
  server.tool(tool.name, {
    description: tool.description,
    schema: tool.schema,
    handler: tool.handler
  });
}

Supported OpenAPI Features

  • ✅ Path parameters
  • ✅ Query parameters
  • ✅ Request body (JSON)
  • ✅ Basic types (string, number, boolean, array, object)
  • ✅ Enums
  • ✅ Required/optional fields
  • ✅ $ref resolution
  • ✅ allOf, oneOf, anyOf
  • ✅ Bearer, API Key, Basic auth
  • ⚠️ Limited support for complex schemas
  • ❌ File uploads
  • ❌ External $refs

License

MIT