Skip to main content
Glama
Leivoo
by Leivoo

mcp-openapi-swagger

一个基于 NodeJS 的 MCP Server:输入 OpenAPI JSON URL 或 Swagger UI URL,自动抓取/解析文档并返回接口清单(summary 级),供 Cursor 的提示词继续处理。

你会得到什么

  • 支持两种输入:

    • OpenAPI JSON URL(例如 /openapi.json/v3/api-docs

    • Swagger UI URL(例如 /swagger-ui/index.html),会自动发现其背后的 spec URL

  • 输出:method + path + summary + tags + operationId

Related MCP server: openapi-mcp-proxy

安装依赖与构建

npm install
npm run build

构建产物在 dist/,并且已配置 bin,可以被 npx 直接执行。

在 Cursor 配置 MCP(npx 启动本地目录)

项目内已提供示例配置:.cursor/mcp.json

关键配置如下(示例):

{
  "mcpServers": {
    "openapi-swagger": {
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "E:/API-MCP"],
      "env": {
        "OPENAPI_SOURCE_URL": "https://example.com/v3/api-docs"
      }
    }
  }
}

E:/API-MCP 替换成你本机的项目根目录路径。

你也可以把 OPENAPI_SOURCE_URL 配成 Swagger UI 地址(例如 https://example.com/swagger-ui/index.html)。

工具(Tools)

openapi_setSource

缓存一个文档地址,后续 openapi_listEndpoints 可省略入参。

输入:

{ "sourceUrl": "https://example.com/swagger-ui/index.html" }

openapi_listEndpoints

抓取并解析 OpenAPI,然后返回接口清单(summary 级)。

输入(两种用法二选一):

{ "sourceUrl": "https://example.com/v3/api-docs" }

或(使用已缓存的 source):

{}

如果你在 .cursor/mcp.json 里配置了 OPENAPI_SOURCE_URL,那么第一次调用 openapi_listEndpoints 直接传 {} 就能生效。

输出示例:

{
  "ok": true,
  "source": {
    "inputUrl": "https://example.com/swagger-ui/index.html",
    "resolvedSpecUrl": "https://example.com/v3/api-docs",
    "openapiVersion": "3.0.3"
  },
  "endpoints": [
    {
      "method": "GET",
      "path": "/pets/{id}",
      "operationId": "getPetById",
      "summary": "Get a pet",
      "tags": ["pets"]
    }
  ]
}

失败时输出示例(便于提示词分支处理):

{
  "ok": false,
  "stage": "fetch/parse/extract",
  "inputUrl": "https://example.com/swagger-ui/index.html",
  "details": {
    "name": "Error",
    "message": "Failed to discover spec URL from Swagger UI page"
  }
}

运行/调试

npm run dev

如果你要验证 npx 启动(Cursor 同款):

npx -y E:/API-MCP

Available Tools

2 tools
openapi_listEndpointsB

Fetch OpenAPI/Swagger spec and return endpoints summary (method/path/summary/tags).

ParametersJSON Schema
NameRequiredDescriptionDefault
sourceUrlNoOpenAPI JSON URL or Swagger UI URL; if omitted uses cached source

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool fetches and returns a summary, but lacks details on behavioral traits such as error handling (e.g., what happens with invalid URLs), caching behavior (e.g., how the cache is managed), rate limits, or authentication needs. The description is minimal and does not compensate for the absence of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the key action ('Fetch') and output, with no wasted words. It directly communicates the tool's function and parameter implication, making it easy to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (fetching and summarizing API specs), no annotations, no output schema, and 100% schema coverage, the description is minimally adequate. It covers the basic purpose and parameter use but lacks details on output format, error handling, or integration with the sibling tool, leaving gaps in completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents the single parameter 'sourceUrl' as an optional URI. The description adds marginal value by clarifying that it's for 'OpenAPI JSON URL or Swagger UI URL' and mentions 'if omitted uses cached source', which provides context beyond the schema's format and optionality. This aligns with the baseline score of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Fetch') and resource ('OpenAPI/Swagger spec'), and specifies the output format ('endpoints summary (method/path/summary/tags)'). It distinguishes from the sibling tool 'openapi_setSource' by focusing on fetching and summarizing rather than setting the source. However, it doesn't explicitly differentiate the scope or limitations compared to the sibling beyond the different action.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by stating it fetches from a URL or uses a cached source, which suggests when to provide the 'sourceUrl' parameter. However, it lacks explicit guidance on when to use this tool versus the sibling 'openapi_setSource' (e.g., for initial setup vs. retrieval), and does not mention any prerequisites, exclusions, or alternative scenarios beyond the optional parameter.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

openapi_setSourceC

Set OpenAPI/Swagger source URL for later calls.

ParametersJSON Schema
NameRequiredDescriptionDefault
sourceUrlYesOpenAPI JSON URL or Swagger UI URL

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this sets a source URL for later use, implying a configuration or initialization action, but lacks details on permissions, persistence, error handling, or side effects. This is a significant gap for a tool that likely mutates state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, and the tool's likely role in configuration or state mutation, the description is insufficient. It doesn't explain what happens after setting the source, how errors are handled, or the scope of 'later calls', leaving critical gaps for agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the parameter 'sourceUrl' fully documented in the schema as a URI for OpenAPI JSON or Swagger UI. The description adds no additional semantic context beyond what the schema provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Set') and the resource ('OpenAPI/Swagger source URL'), specifying it's for configuring a source for subsequent operations. It doesn't explicitly differentiate from the sibling tool 'openapi_listEndpoints', which appears to be a read operation, but the purpose is well-defined.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions 'for later calls', implying this tool should be used to configure a source before making API calls, but it provides no explicit guidance on when to use it versus alternatives, prerequisites, or exclusions. No comparison to the sibling tool is made.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.0
    • First observedopenapi_listEndpoints
    • First observedopenapi_setSource

TDQS

B3.1/5.0
Disambiguation5/5

The two tools have completely distinct purposes: one fetches endpoint summaries from an OpenAPI spec, while the other sets the source URL for that spec. There is no overlap in functionality, making them easy to tell apart.

Naming Consistency5/5

Both tools follow a consistent naming pattern with the 'openapi_' prefix and descriptive action_noun structure (listEndpoints, setSource). The naming is uniform and predictable throughout the set.

Tool Count2/5

With only 2 tools, the server feels thin for its apparent purpose of interacting with OpenAPI/Swagger specs. Core operations like testing endpoints, validating specs, or detailed querying are missing, making the toolset underpowered for typical API exploration workflows.

Completeness2/5

The toolset is severely incomplete for OpenAPI/Swagger interaction. While it covers fetching endpoints and setting a source, it lacks essential operations such as testing API calls, retrieving detailed schema information, or validating specs, which are critical for comprehensive API exploration and integration.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Leivoo/APIMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server