HM

hannesj/mcp-openapi-schema

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

50 stars 14 forks 质量 53 趋势 0

hannesj/mcp-openapi-schema 是从 https://github.com/hannesj/mcp-openapi-schema. 导入的 MCP 服务器候选

概览

hannesj/mcp-openapi-schema 是从 https://github.com/hannesj/mcp-openapi-schema. 导入的 MCP 服务器候选

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,向大型语言模型(LLM)如Claude开放OpenAPI模式信息。该服务器允许LLM通过一套专用工具探索和理解OpenAPI规范。

特色

  • 加载通过命令行参数指定的任意 OpenAPI 模式文件(JSON 或 YAML)
  • 探索 API 路径、操作、参数和模式
  • 查看详细的请求和响应模式
  • 查找组件定义和示例
  • 在整个API规范中进行搜索
  • 以YAML格式获得回答,以提升LLM理解

用途

命令行

运行MCP服务器并使用特定的模式文件:

Claude桌面集成

要在 Claude Desktop 中使用此 MCP 服务器,请编辑您的 claude_desktop_config.json 配置文件:

配置文件的位置:

  • macOS/Linux:~/Library/Application Support/Claude/claude_desktop_config.json
  • 窗口:$env:AppData\Claude\claude_desktop_config.json

Claude 代码集成

要使用该MCP服务器配合Claude代码CLI,请遵循以下步骤:

  1. 将OpenAPI Schema MCP服务器添加到Claude Code中

  2. 确认MCP服务器已注册

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

OpenAPI Schema Model Context Protocol Server

A Model Context Protocol (MCP) server that exposes OpenAPI schema information to Large Language Models (LLMs) like Claude. This server allows an LLM to explore and understand OpenAPI specifications through a set of specialized tools.

Features

  • Load any OpenAPI schema file (JSON or YAML) specified via command line argument
  • Explore API paths, operations, parameters, and schemas
  • View detailed request and response schemas
  • Look up component definitions and examples
  • Search across the entire API specification
  • Get responses in YAML format for better LLM comprehension

Usage

Command Line

Run the MCP server with a specific schema file:

# Use the default openapi.yaml in current directory
npx -y mcp-openapi-schema

# Use a specific schema file (relative path)
npx -y mcp-openapi-schema ../petstore.json

# Use a specific schema file (absolute path)
npx -y mcp-openapi-schema /absolute/path/to/api-spec.yaml

# Show help
npx -y mcp-openapi-schema --help

Claude Desktop Integration

To use this MCP server with Claude Desktop, edit your claude_desktop_config.json configuration file:

{
  "mcpServers": {
    "OpenAPI Schema": {
      "command": "npx",
      "args": ["-y", "mcp-openapi-schema", "/ABSOLUTE/PATH/TO/openapi.yaml"]
    }
  }
}

Location of the configuration file:

  • macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: $env:AppData\Claude\claude_desktop_config.json

Claude Code Integration

To use this MCP server with Claude Code CLI, follow these steps:

  1. Add the OpenAPI Schema MCP server to Claude Code

    # Basic syntax
    claude mcp add openapi-schema npx -y mcp-openapi-schema
    
    # Example with specific schema
    claude mcp add petstore-api npx -y mcp-openapi-schema ~/Projects/petstore.yaml
    
  2. Verify the MCP server is registered

    # List all configured servers
    claude mcp list
    
    # Get details for your OpenAPI schema server
    claude mcp get openapi-schema
    
  3. Remove the server if needed

    claude mcp remove openapi-schema
    
  4. Use the tool in Claude Code

    Once configured, you can invoke the tool in your Claude Code session by asking questions about the OpenAPI schema.

Tips:

  • Use the -s or --scope flag with project (default) or global to specify where the configuration is stored
  • Add multiple MCP servers for different APIs with different names

MCP Tools

The server provides the following tools for LLMs to interact with OpenAPI schemas:

  • list-endpoints: Lists all API paths and their HTTP methods with summaries in a nested object structure
  • get-endpoint: Gets detailed information about a specific endpoint including parameters and responses
  • get-request-body: Gets the request body schema for a specific endpoint and method
在 GitHub 查看完整 README

安装

npx -y mcp-openapi-schema /ABSOLUTE/PATH/TO/openapi.yaml
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "OpenAPI Schema": { "command": "npx", "args": ["-y", "mcp-openapi-schema", "/ABSOLUTE/PATH/TO/openapi.yaml"] } } }