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

概覽

AI 產生的概覽

一個本機 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 等命名模式。
安裝前請注意
伺服器會寫入你的規格檔:設定 {API_NAME}_SERVER_URL 時,它會更新 servers 項目或 host、schemes 與 basePath,並在 .env 檔加入空白預留項目。憑證以明文存放在 specs 資料夾的 .env 檔中。產生的工具會呼叫真實 API,因此呼叫可能建立、修改或刪除遠端資料,並可能產生費用或副作用;批次執行會放大這一點,大批次需要明確確認。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Specrun,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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_addCar to call POST /cars from cars.json spec to create a new car, or github_get_user_repos to call GET /user/repos from github.yaml spec 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_batch tool can execute any tool with multiple inputs and returns a consolidated JSON resource
  • Auto Authentication: Simple .env file with {API_NAME}_API_KEY pattern
  • Auto .env Placeholders: Adds {API_NAME}_SERVER_URL and {API_NAME}_BEARER_TOKEN entries 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)

bash
npm install -g specrun

2️⃣ Create a specs folder where the server can read OpenAPI spec files. For example:

bash
mkdir ~/specs

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:

bash
# ~/specs/.envCARS_API_KEY=your_api_key_here

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 servers entry.
  • OpenAPI 2.0 (formerly Swagger 2.0): updates host, schemes, and basePath (no servers section 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:

json
{  "mcpServers": {    "specrun": {      "command": "specrun",      "args": ["--specs", "/path/to/your/specs/folder"]    }  }}

Otherwise:

json
{  "mcpServers": {    "specrun": {      "command": "npx",      "args": ["-y", "specrun", "--specs", "/absolute/path/to/your/specs"]    }  }}

or with specific Node version:

json
{  "mcpServers": {    "specrun": {      "command": "/Users/YOUR_USER_NAME/.local/bin/mcp-npx-node22",      "args": ["specrun@latest", "--specs", "/absolute/path/to/your/specs"],      "type": "stdio"    }  }}

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.:

bash
#!/bin/bash# Set the PATH to include NVM's Node.js v22.14.0 installationexport PATH="/Users/YOUR_USER_NAME/.nvm/versions/node/v22.14.0/bin:$PATH"
# Execute npx with all passed argumentsexec npx "$@"

💻 CLI Usage

🚀 Start the server

bash
# Default: stdio transport, current directoryspecrun
# Custom specs folderspecrun --specs ~/specs
# HTTP transport modespecrun --transport httpStream --port 8080

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@latest is an npm package spec and works directly with npx only when your current Node version already satisfies SpecRun requirements.
bash

# Or list toolsnpx -y node@22 ./node_modules/.bin/specrun list --specs ~/specs
# If your default Node is already 22+, this also worksnpx -y specrun@latest --specs ~/specs

📋 List loaded specs and tools

bash
# List all loaded specifications and their toolsspecrun list
# List specs from custom folderspecrun list --specs ~/specs

🔑 Authentication Patterns

The server automatically detects authentication from environment variables using these patterns:

PatternAuth TypeUsage
{API_NAME}_API_KEY🗝️ API KeyX-API-Key header
{API_NAME}_TOKEN🎫 Bearer TokenAuthorization: Bearer {token}
{API_NAME}_BEARER_TOKEN🎫 Bearer TokenAuthorization: Bearer {token}
{API_NAME}_USERNAME + {API_NAME}_PASSWORD👤 Basic AuthAuthorization: Basic {base64}

SpecRun also creates .env placeholders for:

PatternPurpose
{API_NAME}_SERVER_URLBase URL for the API
{API_NAME}_BEARER_TOKENToken placeholder if missing

If {API_NAME}_SERVER_URL is set, SpecRun writes that value into the spec before generating tools:

  • OpenAPI 3.0: writes the first servers entry.
  • OpenAPI 2.0 (formerly Swagger 2.0): writes host, schemes, and basePath.

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_KEY
  • github-api.yaml → GITHUB_TOKEN
  • my_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 from GET /user/repos)

Use the shared batch tool to run any tool with an array of inputs:

json
{  "toolName": "cars_getCarById",  "items": [{ "id": "123" }, { "id": "456" }],  "failFast": false}

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:

  1. Request URL
  2. Request body
  3. Response status and body

Example resource payload:

json
{  "requestUrl": "https://api.example.com/v1/users/123",  "requestBody": null,  "response": {    "status": 200,    "body": {      "id": "123",      "name": "Jane Doe"    }  }}

Batch runs return a single consolidated resource containing all item results.

📁 File Structure

your-project/── specs/           # Your OpenAPI specs folder   ├── .env            # Authentication credentials   └── custom-api.yml  # Your OpenAPI spec files

🧭 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 endpoint
  • generate_api_call: Generate a ready-to-run JSON input payload for a tool
  • explain_api_schema: Explain parameters and request body schema with examples
  • generate_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:

yaml
# ~/specs/example.yamlopenapi: 3.0.0info:  title: Example API  version: 1.0.0servers:  - url: https://api-server.placeholderpaths:  /users/{id}:    get:      operationId: getUser      summary: Get user by ID      parameters:        - name: id          in: path          required: true          schema:            type: string      responses:        "200":          description: User found  /users:    post:      operationId: createUser      summary: Create a new user      requestBody:        required: true        content:          application/json:            schema:              type: object              properties:                name:                  type: string                email:                  type: string      responses:        "201":          description: User created

This creates tools named:

  • example_getUser
  • example_createUser

🔧 Troubleshooting

❌ No tools appearing?

  1. Check that your OpenAPI specs are valid:

    bash
    specrun list --specs /path/to/specs
  2. Ensure files have correct extensions (.json, .yaml, .yml)

  3. Check the server logs for parsing errors

⚠️ Note: SpecRun works best when you use absolute paths (with no spaces) for the --specs argument and other file paths. Relative paths or paths containing spaces may cause issues on some platforms or with some MCP clients.

🔐 Authentication not working?

  1. Verify your .env file is in the specs directory
  2. Check the naming pattern matches your spec filename
  3. Use the list command to verify auth configuration:
    bash
    specrun list

🔄 Tools not updating after spec changes?

  1. Restart the MCP server to reload the specs
  2. Check file permissions
  3. Restart the MCP client if needed

🛠️ Development

bash
# Clone and installgit clone [email protected]:Pavel-Piha/specrun.gitcd specrunnpm install
# Buildnpm run build
npm run dev -- list --specs ./specs

🤝 Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

來源:README.md,提交 d3d6811

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.4.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分