MCP GraphQLのロゴ

MCP GraphQL

コミュニティ
drestrepom

An MCP (Model Context Protocol) server that enables interaction with GraphQL APIs.

公開者drestrepom
リポジトリmcp_graphql
言語Python
フォーク
3
スター
19
利用可能なツール
0
通信方式stdio
カテゴリ
リンク
  • ツールをAIワークフローに接続

    MCP GraphQLは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには19件のスターと3件のフォークがあります。

MCP GraphQL

An MCP (Model Context Protocol) server that enables interaction with GraphQL APIs.

Description

MCP GraphQL is a tool that implements the Model Context Protocol (MCP) to provide a standardized interface for interacting with GraphQL APIs. It automatically exposes each GraphQL query as a separate MCP tool, allowing MCP-compatible clients to seamlessly communicate with GraphQL services.

Features

  • Each GraphQL query is exposed as a distinct MCP tool
  • Tool parameters automatically match the corresponding GraphQL query parameters
  • JSON schema for tool inputs is dynamically generated from GraphQL query parameters
  • No schema definition required - simply provide the API URL and credentials
  • Currently supports GraphQL queries (mutations support planned for future releases)
  • Configurable authentication (Bearer, Basic, custom headers)
  • Automatic handling of complex GraphQL types

Requirements

  • Python 3.11 or higher

Installation

Using uv (recommended)

When using uv no specific installation is needed. We will use uvx to directly run mcp-graphql.

Using pip

Alternatively you can install mcp-graphql via pip:

bash
pip install mcp-graphql

Installation from source code

bash
git clone https://github.com/your-username/mcp_graphql.git
cd mcp_graphql
pip install .

Usage

As a command line tool

Using uvx:

bash
uvx mcp-graphql --api-url="https://api.example.com/graphql" --auth-token="your-token"

Using pip installation:

bash
mcp-graphql --api-url="https://api.example.com/graphql" --auth-token="your-token"

or

bash
python -m mcp_graphql --api-url="https://api.example.com/graphql" --auth-token="your-token"

Available options

  • --api-url: GraphQL API URL (required)
  • --auth-token: Authentication token (optional, can also be set via MCP_AUTH_TOKEN environment variable)
  • --auth-type: Authentication type, default is "Bearer" (optional)
  • --auth-headers: Custom authentication headers in JSON format (optional)
  • --queries-file: Path to a .gql file containing predefined GraphQL queries (optional)
  • --queries: Predefined GraphQL queries passed directly as a string (optional)
  • --max-depth: Maximum depth when auto-generating queries (default: 5)

Example with custom headers:

bash
mcp-graphql --api-url="https://api.example.com/graphql" --auth-headers='{"Authorization": "Bearer token", "X-API-Key": "key"}'

Example with predefined queries file:

bash
mcp-graphql --api-url="https://api.example.com/graphql" --queries-file="./queries.gql"

Example passing queries directly as a string (use single quotes to avoid shell conflicts):

bash
mcp-graphql --api-url="https://api.example.com/graphql" --queries='query Hello { hello }'

About automatic query generation

If neither --queries-file nor --queries is supplied, mcp-graphql will automatically build a query by introspecting the GraphQL schema and selecting all scalar fields up to a configurable depth. This is convenient for quickly exploring an API, but it has two main drawbacks:

  1. Too much depth – drilling deep into nested objects (especially lists) can return a large amount of data and overflow the LLM context window.
  2. Lack of control – you cannot precisely choose which fields are included, so tokens may be wasted on irrelevant information.

The --max-depth option mitigates the first issue by limiting the recursion depth (default = 5). Even so, the best practice is to define the exact queries you need through --queries-file or --queries. In doing so:

  • You control exactly which fields are returned and avoid unnecessary lists.
  • Every named operation in your file/string is automatically exposed as an MCP tool with no manual boilerplate.

Example using --max-depth to limit the auto-generated query to depth 2:

bash
mcp-graphql --api-url="https://api.example.com/graphql" --max-depth 2

For production workloads you should supply your own queries:

bash
# Using a file
mcp-graphql --api-url="https://api.example.com/graphql" \
            --queries-file="./queries.gql"

# Or as a string
mcp-graphql --api-url="https://api.example.com/graphql" \
            --queries='query UserMini { viewer { id name } }'

The queries.gql file should contain one or more named operations, e.g.:

graphql
# queries.gql
query GetUser($id: ID!) {
  user(id: $id) {
    id
    name
    email
  }
}

query ListPosts {
  posts {
    id
    title
  }
}

As a library

python
import asyncio
from pathlib import Path
from mcp_graphql import make_server, serve

auth_headers = {"Authorization": "Bearer your-token"}
api_url = "https://api.example.com/graphql"
queries_file = Path("queries.gql")  # optional, set to None to expose all queries

asyncio.run(serve(api_url, auth_headers, queries_file=queries_file))

Passing the queries directly as a string from code:

python
queries_str = """
query Hello($name: String!) {
  hello(name: $name)
}
"""

asyncio.run(serve(api_url, auth_headers, queries=queries_str, max_depth=3))

Create low level MCP server:

python
server = make_server(api_url, auth_headers, queries=queries_str, max_depth=3)

For low level server with Streamable HTTP implementations, see:

Configuration

Configure for Claude.app

Add to your Claude settings:

json
"mcpServers": {
  "graphql": {
    "command": "uvx",
    "args": ["mcp-graphql", "--api-url", "https://api.example.com/graphql"]
  }
}
json
"mcpServers": {
  "graphql": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/graphql", "--api-url", "https://api.example.com/graphql"]
  }
}
json
"mcpServers": {
  "graphql": {
    "command": "python",
    "args": ["-m", "mcp_graphql", "--api-url", "https://api.example.com/graphql"]
  }
}

How It Works

MCP GraphQL automatically:

  1. Introspects the provided GraphQL API
  2. Creates an MCP tool for each available GraphQL query
  3. Generates JSON schema for tool inputs based on query parameters
  4. Handles type conversions between GraphQL and JSON

When a tool is called, the server:

  1. Converts the tool call parameters to a GraphQL query
  2. Executes the query against the API
  3. Returns the results to the MCP client

Planned Features

  • Support for GraphQL mutations (with appropriate safeguards)
  • Improved error handling and validation
  • Additional optimizations based on specific GraphQL API implementations

Development

Setting up the development environment

bash
# Create virtual environment using uv
uv venv

# Install dependencies
uv sync

Linting

bash
ruff check .

Running the server in development mode

When working locally you can start the MCP GraphQL server with hot-reloading and inspect its tools using the Model Context Protocol Inspector:

bash
npx "@modelcontextprotocol/inspector" uv run -n --project $PWD mcp-graphql --api-url http://localhost:3010/graphql

Replace http://localhost:3010/graphql with the URL of your local GraphQL endpoint if it differs.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome. Please feel free to submit a Pull Request or open an Issue.

インストール

TypingMind
前提条件:

Node.js 18+

{
  "mcpServers": {
    "drestrepom-mcp_graphql": {
      "command": "",
      "args": []
    }
  }
}

MCP GraphQLのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度MCP GraphQLに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

MCP GraphQLをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. MCP GraphQLのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "drestrepom-mcp_graphql": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-graphql"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてMCP GraphQLのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. MCP GraphQLのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
MCP GraphQLを使ってこのタスクを手伝ってもらえますか?
MCP GraphQL
はい、読みました。
MCP GraphQLで調べた結果をお伝えします。

よくある質問

MCP GraphQL MCPサーバーは何に使いますか?

MCP GraphQLは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでMCP GraphQL MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでMCP GraphQLを利用できます。

TypingMindでMCP GraphQL MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。MCP GraphQLを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

MCP GraphQL MCPをTypingMindに接続するにはどうすればよいですか?

MCP GraphQLはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでMCP GraphQL MCPのどのようなツールを利用できますか?

MCP GraphQLはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

MCP GraphQL MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。MCP GraphQLで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇