
Specrun
io.github.pavelpiha由 GitHub 账号 pavelpiha 发布v1.4.0更新于 Oct 24, 2026
MCP server that converts OpenAPI specs into tools which can query API endpoints
概览
一个本地 MCP 服务器,把文件夹中的 OpenAPI 规范文件转换为工具,让助手调用这些工具查询规范所描述的 API。
- 可以做什么
- 从 specs 文件夹加载 OpenAPI 3.0 和 Swagger 2.0 规范文件,把每个操作暴露为可调用工具,按规范文件做命名空间隔离,并根据 operationId 或方法与路径自动命名。用结构化 JSON 参数和请求体调用任意生成的工具,返回包含请求 URL、请求体以及响应状态和响应体的 JSON 资源。查看某个工具的原始规范细节,包括参数以及请求和响应模式。用多个输入批量运行任意工具并获得一份合并结果,超过 200 项的批量需要确认。使用内置提示列出 API、生成输入载荷、解释模式并生成示例数据。
- 适用场景
- 当你有一个或多个 OpenAPI 或 Swagger 规范,希望助手直接探索并调用这些 API(例如读取数据或创建记录),而不必为每个 API 编写自定义集成时适用。也适合查看端点模式并生成示例请求载荷。
- 运行要求
- 作为本地 Node.js 进程运行(需要 Node.js 22 或更高版本),可全局安装或通过 npx 运行。需要一个包含 .json、.yaml 或 .yml OpenAPI 文件的 specs 文件夹,通过 --specs 参数指定;建议使用不含空格的绝对路径。认证可选,从 specs 文件夹中的 .env 文件读取,使用 {API_NAME}_API_KEY、{API_NAME}_TOKEN、{API_NAME}_BEARER_TOKEN 或 {API_NAME}_USERNAME 与 {API_NAME}_PASSWORD 等命名模式。
安装
在 SourceWeft 中
- 打开 控制台中的 Specrun,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
SpecRun
An MCP server that turns OpenAPI specifications into MCP tools. Scans a folder for OpenAPI spec files and automatically generate corresponding tools. These tools can then be used in any MCP client to interact with the APIs defined by the specs, with built-in support for authentication and server URL management via a simple `.env` file.Built with FastMCP for TypeScript.
✨ Features
- Zero Configuration: Filesystem is the interface - just drop OpenAPI specs in a folder
- Supports OpenAPI 3.0 and 2.0: Works with both OpenAPI 3.x and Swagger 2.0 specs
- Namespace Isolation: Multiple APIs coexist cleanly
- Full OpenAPI Support: Handles parameters, request bodies, authentication, and responses
- Run Any Tool to Interact with APIs: For example,
cars_addCarto callPOST /carsfromcars.jsonspec to create a new car, orgithub_get_user_reposto callGET /user/reposfromgithub.yamlspec to list repos. - Run Any Tool with Custom Inputs: Pass structured JSON inputs for parameters and request bodies
- Run Any Tool to see Spec Details: Get the original OpenAPI spec details for any tool, including parameters, request body schema, and response schema
- Run Any Tool to get API responses as resources: Each tool call returns a JSON resource containing request URL, request body, and response
- Run Any Tool in Batch: One
specrun_batchtool can execute any tool with multiple inputs and returns a consolidated JSON resource - Auto Authentication: Simple
.envfile with{API_NAME}_API_KEYpattern - Auto .env Placeholders: Adds
{API_NAME}_SERVER_URLand{API_NAME}_BEARER_TOKENentries when missing - Multiple Transports: Support for stdio and HTTP streaming
- Built-in Debugging: List command to see loaded specs and tools
- MCP Prompts: Built-in prompts for listing tools, generating inputs, and explaining schemas
- Agent: configured agent for using SpecRun tools to explore and operate APIs in a guided way (
.github/agents/specrun.agent.md)
Quick Start
Requirements
- Node.js 22 or newer
1️⃣ Install (optional)
2️⃣ Create a specs folder where the server can read OpenAPI spec files. For example:
3️⃣ Add OpenAPI specs
Drop any .json, .yaml, or .yml OpenAPI specification files into your specs folder
4️⃣ Configure authentication (optional)
Create a .env file in your specs folder:
SpecRun will also ensure {API_NAME}_SERVER_URL and {API_NAME}_BEARER_TOKEN entries exist for each spec, adding empty placeholders when missing.
When {API_NAME}_SERVER_URL has a value, SpecRun updates the spec file on load:
- OpenAPI 3.0: updates the first
serversentry. - OpenAPI 2.0 (formerly Swagger 2.0): updates
host,schemes, andbasePath(noserverssection in OpenAPI 2.0).
SpecRun also watches the .env file and refreshes server URLs and auth config automatically after changes.
5️⃣ Add to MCP client configuration
Add to your MCP configuration:
If installed on your machine:
Otherwise:
or with specific Node version:
The mcp-npx-node22 script file uses nvm to run specrun with Node.js 22.14.0, ensuring compatibility regardless of the default Node version on your system.:
💻 CLI Usage
🚀 Start the server
Run with Node 22 using npx
If your default node is older than 22, run SpecRun with Node 22 directly:
npx -y node@22 ...runs the Node.js runtime, so the next argument must be a script path (for example./node_modules/.bin/specrun).specrun@latestis an npm package spec and works directly withnpxonly when your current Node version already satisfies SpecRun requirements.
📋 List loaded specs and tools
🔑 Authentication Patterns
The server automatically detects authentication from environment variables using these patterns:
SpecRun also creates .env placeholders for:
If {API_NAME}_SERVER_URL is set, SpecRun writes that value into the spec before generating tools:
- OpenAPI 3.0: writes the first
serversentry. - OpenAPI 2.0 (formerly Swagger 2.0): writes
host,schemes, andbasePath.
Updates to .env are applied automatically without restarting the MCP server.
The {API_NAME} is derived from the filename of your OpenAPI spec:
cars.json→CARS_API_KEYgithub-api.yaml→GITHUB_TOKENmy_custom_api.yml→MY_CUSTOM_API_KEY
🏷️ Tool Naming
Tools are automatically named using this pattern:
- With operationId:
{operation_id} - Without operationId:
{method}_{path_segments}
Name normalization rules:
- Converted to
snake_case - Lowercased
- Non-alphanumeric characters normalized to
_ - Truncated at the end when longer than 52 characters. (For VS Code/Copilot compatibility, stays within the practical 64-char internal limit.)
- Adds short suffixes only when needed to resolve collisions
Specs:
get_car_by_id(from operationId)get_user_repos(generated fromGET /user/repos)
Use the shared batch tool to run any tool with an array of inputs:
Batch responses return a consolidated JSON resource with per-item outputs.
For batches over 200 items, SpecRun requires explicit confirmation. This is to prevent accidental large runs that could cause performance issues or unintended consequences. The server will return a message asking for confirmation, and you can retry with confirmLargeBatch: true and the provided confirmLargeBatchToken to proceed.
📦 Resource Outputs
Tool responses are returned as MCP resources with application/json content. Each resource includes:
- Request URL
- Request body
- Response status and body
Example resource payload:
Batch runs return a single consolidated resource containing all item results.
📁 File Structure
🧭 MCP Prompts
SpecRun exposes MCP prompts for common workflows:
Detailed prompt guide with examples: PROMPTS_README.md
list_apis: List loaded APIs/tools and ask the user to choose an endpointgenerate_api_call: Generate a ready-to-run JSON input payload for a toolexplain_api_schema: Explain parameters and request body schema with examplesgenerate_random_data: Generate random ready-to-run JSON payload samples for a tool
📄 Example OpenAPI Spec
Here's a minimal example that creates two tools:
This creates tools named:
example_getUserexample_createUser
🔧 Troubleshooting
❌ No tools appearing?
-
Check that your OpenAPI specs are valid:
-
Ensure files have correct extensions (
.json,.yaml,.yml) -
Check the server logs for parsing errors
⚠️ Note: SpecRun works best when you use absolute paths (with no spaces) for the
--specsargument and other file paths. Relative paths or paths containing spaces may cause issues on some platforms or with some MCP clients.
🔐 Authentication not working?
- Verify your
.envfile is in the specs directory - Check the naming pattern matches your spec filename
- Use the list command to verify auth configuration:
🔄 Tools not updating after spec changes?
- Restart the MCP server to reload the specs
- Check file permissions
- Restart the MCP client if needed
🛠️ Development
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
来源:README.md,提交 d3d6811
工具
0版本历史
1- v1.4.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分