Skip to main content
Glama

MCP Server: Scalable OpenAPI Endpoint Discovery and API Request Tool

MCP サーバー: スケーラブルな OpenAPI エンドポイント検出および API リクエスト ツール

やるべきこと

  • 事前ダウンロードしたモデルなしではDockerイメージは2GBです。事前ダウンロードしたモデルを含めると3.76GBになります! 大きすぎるので、サイズを小さくするのを手伝ってください。

構成

環境変数を通じてカスタマイズします。GLOBAL_TOOL_PROMPT 重要です!

  • OPENAPI_JSON_DOCS_URL : OpenAPI 仕様 JSON への URL (デフォルトはhttps://api.staging.readymojo.com/openapi.json )
  • MCP_API_PREFIX : カスタマイズ可能なツール名前空間 (デフォルトは "any_openapi"):
    # Creates tools: custom_api_request_schema and custom_make_request docker run -e MCP_API_PREFIX=finance ...
  • GLOBAL_TOOL_PROMPT : すべてのツールの説明の先頭に追加するオプションのテキスト。これは、Claude がツールを正確に選択し、正しく選択されないために重要です。
    # Adds "Access to insights apis for ACME Financial Services abc.com . " to the beginning of all tool descriptions docker run -e GLOBAL_TOOL_PROMPT="Access to insights apis for ACME Financial Services abc.com ." ...

要約

これを作成した理由: Swagger OpenAPI ドキュメントのサイズが数百 KB のプライベート API を提供したいからです。

  • Claude MCPはこれらのファイルサイズを処理する際にエラーが発生します
  • 結果をYAMLに変換しようとしましたが、サイズが小さすぎ、エラーが多く発生しました。失敗しました。
  • APIカテゴリを指定して、MCPクライアント(Claude Desktop)にグループ別にAPIドキュメントを取得するよう依頼してみましたが、それでも大きすぎて失敗しました。

最終的に、私はこの解決策にたどり着きました:

  • メモリ内のセマンティック検索を使用して、自然言語で関連する API エンドポイントを検索します (製品のリストなど)
  • 完全なエンドポイントドキュメントを(1つのエンドポイントを1つのチャンクとして保存するように設計したため)100万秒以内に返します(メモリ内にあるため)。

なんと、Claude は完全なパラメータを使用してどの API を呼び出すべきかを知るようになりました。

待ってください。実際の RESTful リクエストを行うには、このサーバーに別のツールを作成する必要があります。「フェッチ」サーバーが単純に機能しないため、その理由をデバッグしたくないのです。

https://github.com/user-attachments/assets/484790d2-b5a7-475d-a64d-157e839ad9b0

技術的なハイライト:

query -> [Embedding] -> FAISS TopK -> OpenAPI docs -> MCP Client (Claude Desktop) MCP Client -> Construct OpenAPI Request -> Execute Request -> Return Response

特徴

  • 🧠 リモートの OpenAPI JSON ファイルをソースとして使用します。ローカル ファイル システムへのアクセスは不要で、API の変更に伴う更新は不要です。
  • 🔍 最適化された MiniLM-L3 モデルを使用したセマンティック検索 (43MB vs オリジナル 90MB)
  • 🚀 非同期サポートを備えたFastAPIベースのサーバー
  • 🧠 エンドポイントベースのチャンク化 OpenAPI 仕様 (100KB 以上のドキュメントを処理)、エンドポイントのコンテキストが失われない
  • ⚡ エンドポイントを瞬時に検出するインメモリ FAISS ベクトル検索

制限事項

  • linux/arm/v7 をサポートしていません (Transformer ライブラリでビルドが失敗します)
  • 🐢 Docker イメージを使用していない場合、コールド スタートのペナルティ (モデルの読み込みに約 15 秒)
  • [廃止] 現在のDockerイメージではモデルのダウンロードが無効になっています。huggingfaceに依存しています。Claude Desktopを読み込む際、モデルのダウンロードに時間がかかります。huggingfaceがダウンしている場合、サーバーは起動しません。
  • 最新のDockerイメージには、事前にダウンロードしたモデルが組み込まれています。問題がある場合は、古いものに戻してください。

マルチインスタンス構成の例

マルチインスタンス設定の例を以下に示します。複数のAPIセットをより柔軟に使用できるように設計しました。

{ "mcpServers": { "finance_openapi": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPENAPI_JSON_DOCS_URL=https://api.finance.com/openapi.json", "-e", "MCP_API_PREFIX=finance", "-e", "GLOBAL_TOOL_PROMPT='Access to insights apis for ACME Financial Services abc.com .'", "buryhuang/mcp-server-any-openapi:latest" ] }, "healthcare_openapi": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPENAPI_JSON_DOCS_URL=https://api.healthcare.com/openapi.json", "-e", "MCP_API_PREFIX=healthcare", "-e", "GLOBAL_TOOL_PROMPT='Access to insights apis for Healthcare API services efg.com .", "buryhuang/mcp-server-any-openapi:latest" ] } } }

この例では、

  • サーバーは OpenAPI ドキュメントからベース URL を自動的に抽出します。
    • 金融APIについてはhttps://api.finance.com
    • ヘルスケア API についてはhttps://api.healthcare.com
  • オプションで、 API_REQUEST_BASE_URL環境変数を使用してベース URL をオーバーライドできます。
{ "mcpServers": { "finance_openapi": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPENAPI_JSON_DOCS_URL=https://api.finance.com/openapi.json", "-e", "API_REQUEST_BASE_URL=https://api.finance.staging.com", "-e", "MCP_API_PREFIX=finance", "-e", "GLOBAL_TOOL_PROMPT='Access to insights apis for ACME Financial Services abc.com .'", "buryhuang/mcp-server-any-openapi:latest" ] } } }

クロードデスクトップの使用例

クロードデスクトッププロジェクトプロンプト:

You should get the api spec details from tools financial_api_request_schema You task is use financial_make_request tool to make the requests to get response. You should follow the api spec to add authorization header: Authorization: Bearer <xxxxxxxxx> Note: The base URL will be returned in the api_request_schema response, you don't need to specify it manually.

チャットでは次のことができます:

Get prices for all stocks

インストール

Smithery経由でインストール

Smithery経由で Claude Desktop 用のスケーラブルな OpenAPI エンドポイント検出と API リクエスト ツールを自動的にインストールするには:

npx -y @smithery/cli install @baryhuang/mcp-server-any-openapi --client claude

pipの使用

pip install mcp-server-any-openapi

利用可能なツール

サーバーは次のツールを提供します ( {prefix}MCP_API_PREFIXによって決定されます)。

{プレフィックス}_api_request_schema

インテントに一致するAPIエンドポイントスキーマを取得します。パス、メソッド、パラメータ、レスポンス形式などのエンドポイントの詳細を返します。

入力スキーマ:

{ "query": { "type": "string", "description": "Describe what you want to do with the API (e.g., 'Get user profile information', 'Create a new job posting')" } }

{プレフィックス}_make_request

簡素化された実装では失敗する複雑な API で信頼性の高い実行を行うために不可欠です。以下を提供します。

入力スキーマ:

{ "method": { "type": "string", "description": "HTTP method (GET, POST, PUT, DELETE, PATCH)", "enum": ["GET", "POST", "PUT", "DELETE", "PATCH"] }, "url": { "type": "string", "description": "Fully qualified API URL (e.g., https://api.example.com/users/123)" }, "headers": { "type": "object", "description": "Request headers (optional)", "additionalProperties": { "type": "string" } }, "query_params": { "type": "object", "description": "Query parameters (optional)", "additionalProperties": { "type": "string" } }, "body": { "type": "object", "description": "Request body for POST, PUT, PATCH (optional)" } }

応答形式:

{ "status_code": 200, "headers": { "content-type": "application/json", ... }, "body": { // Response data } }

Docker サポート

マルチアーキテクチャビルド

公式イメージは 3 つのプラットフォームをサポートしています。

# Build and push using buildx docker buildx create --use docker buildx build --platform linux/amd64,linux/arm64 \ -t buryhuang/mcp-server-any-openapi:latest \ --push .

柔軟なツール命名

MCP_API_PREFIXを介してツール名を制御します。

# Produces tools with "finance_api" prefix: docker run -e MCP_API_PREFIX=finance_ ...

サポートされているプラットフォーム

  • Linux/amd64
  • Linux/arm64

オプション 1: ビルド済みイメージを使用する (Docker Hub)

docker pull buryhuang/mcp-server-any-openapi:latest

オプション2: ローカル開発ビルド

docker build -t mcp-server-any-openapi .

コンテナの実行

docker run \ -e OPENAPI_JSON_DOCS_URL=https://api.example.com/openapi.json \ -e MCP_API_PREFIX=finance \ buryhuang/mcp-server-any-openapi:latest

主要コンポーネント

  1. EndpointSearcher : 以下を処理するコアクラス:
    • OpenAPI仕様の解析
    • セマンティック検索インデックスの作成
    • エンドポイントドキュメントのフォーマット
    • 自然言語クエリ処理
  2. サーバー実装:
    • 非同期FastAPIサーバー
    • MCPプロトコルのサポート
    • ツールの登録と呼び出しの処理

ソースから実行

python -m mcp_server_any_openapi

Claude Desktopとの統合

Claude Desktop 設定で MCP サーバーを構成します。

{ "mcpServers": { "any_openapi": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPENAPI_JSON_DOCS_URL=https://api.example.com/openapi.json", "-e", "MCP_API_PREFIX=finance", "-e", "GLOBAL_TOOL_PROMPT='Access to insights apis for ACME Financial Services abc.com .", "buryhuang/mcp-server-any-openapi:latest" ] } } }

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします ( git commit -m 'Add some amazing feature' )
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

ライセンス

このプロジェクトは、LICENSE ファイルに含まれる条件に基づいてライセンスされます。

実装ノート

  • エンドポイント中心の処理: 大規模な仕様で苦労するドキュメント レベルの分析とは異なり、個々のエンドポイントを次のようにインデックスします。
    • パス + メソッドを一意の識別子として
    • パラメータを考慮した埋め込み
    • レスポンススキーマコンテキスト
  • 最適化された仕様処理: 最大 10 MB (約 5,000 エンドポイント) の OpenAPI 仕様を以下を通じて処理します。
    • スキーマコンポーネントの遅延読み込み
    • パス項目の並列解析
    • 選択的埋め込み生成(冗長な記述を省略)
-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

このサーバーは、セマンティック検索と高性能処理を使用して OpenAPI エンドポイントのスケーラブルな検出と実行を容易にし、合理化された API 対話のための大規模な仕様処理の制限を克服します。

  1. やるべきこと
    1. 構成
      1. 要約
        1. 特徴
          1. 制限事項
            1. マルチインスタンス構成の例
              1. クロードデスクトップの使用例
                1. インストール
                  1. Smithery経由でインストール
                  2. pipの使用
                2. 利用可能なツール
                  1. {プレフィックス}\_api\_request\_schema
                  2. {プレフィックス}\_make\_request
                3. Docker サポート
                  1. マルチアーキテクチャビルド
                  2. 柔軟なツール命名
                  3. サポートされているプラットフォーム
                  4. オプション 1: ビルド済みイメージを使用する (Docker Hub)
                  5. オプション2: ローカル開発ビルド
                  6. コンテナの実行
                  7. 主要コンポーネント
                  8. ソースから実行
                4. Claude Desktopとの統合
                  1. 貢献
                    1. ライセンス
                      1. 実装ノート

                        Related MCP Servers

                        • -
                          security
                          A
                          license
                          -
                          quality
                          An MCP server that exposes HTTP methods defined in an OpenAPI specification as tools, enabling interaction with APIs via the Model Context Protocol.
                          Last updated -
                          2
                          Python
                          MIT License
                        • -
                          security
                          F
                          license
                          -
                          quality
                          This server acts as a Message Communication Protocol (MCP) service for integrating Apifox and Cursor, enabling OpenAPI interface implementation through AI-driven interaction.
                          Last updated -
                          7
                          TypeScript
                        • -
                          security
                          A
                          license
                          -
                          quality
                          A server that enables Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the Model Context Protocol.
                          Last updated -
                          378
                          96
                          TypeScript
                          MIT License
                          • Apple
                        • A
                          security
                          A
                          license
                          A
                          quality
                          A Model Context Protocol server that loads multiple OpenAPI specifications and exposes them to LLM-powered IDE integrations, enabling AI to understand and work with your APIs directly in development tools like Cursor.
                          Last updated -
                          7
                          292
                          7
                          TypeScript
                          MIT License

                        View all related MCP servers

                        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/baryhuang/mcp-server-any-openapi'

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