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.
{
"servers": {
"gitlab": {
"command": "node",
"args": [
"/path/to/mcp_builder/output/dist/server.js" ## Change this base on your path
],
"env": {
"ACCESS_TOKEN": "ss", ## change it
"API_URL": "ss" ## change it
},
"type": "stdio"
}
}
}
Cline
find cline_mcp_settings.json in your device and add this:
{
"mcpServers": {
"gitlab": {
"disabled": false,
"timeout": 60,
"command": "node",
"args": [
"/path/to/mcp_builder/output/dist/server.js" ## Change this base on your path
],
"env": {
"ACCESS_TOKEN": "ss", ## change it
"API_URL": "ss" ## change it
},
"transportType": "stdio"
}
}
}
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.j2and 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,
})),
};
});
...
