MCP ExplorerExplorer

Mcp Builder

@alikarimiion 10 months ago
2 MIT
FreeCommunity
AI Systems
Convert OpenAPI specifications into TypeScript code and generate MCP Server

Overview

What is Mcp Builder

mcp_builder is a tool designed to convert OpenAPI specifications into TypeScript code, facilitating the generation of an MCP Server.

Use cases

Use cases include generating TypeScript code for RESTful APIs, setting up an MCP Server for handling API requests, and integrating with development tools like VSCode and Cline.

How to use

To use mcp_builder, activate a virtual environment, install dependencies, and run the generator script with your OpenAPI YAML file as input. After generating the TypeScript code, prepare the MCP Server by creating a .env file and installing necessary packages, then run the server using Node.js.

Key features

Key features include support for OpenAPI v3, automatic TypeScript schema and handler generation, and easy integration with MCP Server.

Where to use

mcp_builder can be used in software development projects that require API development and server-side code generation, particularly in TypeScript environments.

Content

MCP Builder

This project is designed to convert OpenAPI specifications into TypeScript code and generate MCP Server. It provides a simple way to generate TypeScript schemas and handlers based on the definitions provided in an OpenAPI YAML file.

This project works with OpenAPI v3, to convert v2 to v3 check this doc: openapi3-parser

Generate Code

To run the project, activate venv:

uv venv --python 3.12.9
source .venv/bin/activate
uv install

Then, you can run the generator script to convert your OpenAPI YAML file into TypeScript code. The command below assumes you have an OpenAPI YAML file named example/openapi_v3.yaml and you want to generate a TypeScript files in output directory, using the templates located in the src/templates directory.

python -m src.main --input=example/openapi_v3.yaml --output_dir=output --templates_dir=src/templates

or

make run

Prepare MCP Server

change directory to output,create .env file and put your envs there, then run:

npm i

Check server

run node dist/server.js. you shuold see the starting message. (MCP Server running …)

Use MCP Server

VsCode

Create .vscode folder in root of your project and create mcp.json file.

Cline

find cline_mcp_settings.json in your device and add this:

If more than about 50 tools are generated, they are not shown in the Cline list. you can filter list in src/templates/server.ts.j2 and generate it again:

...
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: Object.entries(toolStore).slice(0,50).map(([name, tool]) => ({
      name,
      description: tool.definition.description,
      inputSchema: tool.definition.inputSchema,
    })),
  };
});
...

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers