muppet logo
OpenAPI

Using OpenAPI Specs

Generate MCP servers from OpenAPI Specs

You can create an MCP server from OpenAPI specs using the fromOpenAPI function. This function takes in the OpenAPI specs and generates the MCP server from it. This is useful if you have an existing OpenAPI spec, from any codebase and want to generate a MCP server from it.

import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { bridge } from "muppet";
import { fromOpenAPI } from "muppet/openapi";
 
const mcp = fromOpenAPI({
  // Add your OpenAPI spec here
  info: {
    title: "My Muppet",
    version: "1.0.0",
  },
  openapi: "3.1.0",
  paths: {},
});
 
bridge({
  mcp,
  transport: new StdioServerTransport(),
});
 

This will create all the routes as tools for the MCP server. Currently you cannot change this behavior but we are working on improving this in the future.