trackmcp
Back to directory
2013xile

openapi2mcptools

View on GitHub

OpenAPI specifications => MCP (Model Context Protocol) tools

19 stars TypeScriptDeveloper Kits Updated Oct 23, 2025
mcpmcp-servermcp-toolsmodelcontextprotocolopenapi

Documentation

OPENAPI Specifications => MCP (Model Context Protocol) Tools

  • ๐Ÿ”ง An utility library for converting OpenAPI specifications to MCP tools.
  • ๐Ÿš€ Faster the development of MCP servers based on OPENAPI specifications.

Usage

ts
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
import { Converter } from 'openapi2mcptools';

const converter = new Converter({
  baseURL, // optional
  httpClient // optional
});
await converter.load({
  // specs
});
const tools = converter.getToolsList();
const toolCaller = converter.getToolsCaller();

const server = new Server(
  {
    name: 'mcp-server-openapi',
    version: '1.0.0',
  },
  {
    capabilities: {
      tools: {},
    },
  },
);

// Define available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools,
  };
});

// Handle tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  return await toolCaller(request);
});

const transport = new StdioServerTransport();
await server.connect(transport);

Custom client

Set `baseURL`, `headers`, etc for http client.

ts
export type RequestConfig = {
  url?: string;
  method?: string;
  headers?: any;
  params?: any;
  data?: any;
}

export interface HTTPClient {
  request: (requestConfig: RequestConfig) => Promise;
}

Example:

ts
import axios from axios;
import { Converter } from 'openapi2mcptools';

const converter = new Converter({
  httpClient: axios
});

Frequently asked questions

What is openapi2mcptools?

openapi2mcptools is OpenAPI specifications => MCP (Model Context Protocol) tools

How do I install openapi2mcptools?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is openapi2mcptools open source?

Yes โ€” it is hosted on GitHub at https://github.com/2013xile/openapi2mcptools and has 19 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP