mcp-openapi-swagger

mcp-openapi-swagger

An MCP server that crawls and parses OpenAPI JSON or Swagger UI URLs to provide concise endpoint summaries. It enables LLMs to discover and interact with API interfaces by extracting methods, paths, and operation IDs from documentation sources.

Category
Visit Server

README

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

安装依赖与构建

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured