T

openapi2mcptools

Created Oct 19, 2025 by 2013xile

Language:

TypeScript

Stars:

11

Forks:

3

README

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

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.

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

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

Example:

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

const converter = new Converter({
  httpClient: axios
});
Last updated: Oct 19, 2025

Publisher info

2013xile's avatar

2013xile

Free to play.

@Nocobase
Guangzhou, China
33
followers
30
following
38
repos

More MCP servers built with TypeScript

Vue.js

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

By vuejs 209.9K
Excalidraw

Virtual whiteboard for sketching hand-drawn like diagrams

By excalidraw 114.9K
Angular

Deliver web apps with confidence 🚀

By angular 99.7K