Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

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:

pip install mcp-graphql

Installation from source code

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

Usage

As a command line tool

Using uvx:

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

Using pip installation:

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

or

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)
  • --auth-type: Authentication type, default is "Bearer" (optional)
  • --auth-headers: Custom authentication headers in JSON format (optional)

Example with custom headers:

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

As a library

import asyncio
from mcp_graphql import serve

auth_headers = {"Authorization": "Bearer your-token"}
api_url = "https://api.example.com/graphql"

asyncio.run(serve(api_url, auth_headers))

Configuration

Configure for Claude.app

Add to your Claude settings:

Using uvx
"mcpServers": {
  "graphql": {
    "command": "uvx",
    "args": ["mcp-graphql", "--api-url", "https://api.example.com/graphql"]
  }
}
Using docker
"mcpServers": {
  "graphql": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/graphql", "--api-url", "https://api.example.com/graphql"]
  }
}
Using pip installation
"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

# Create virtual environment using uv
uv venv

# Install dependencies
uv sync

Linting

ruff check .

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.

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • Byaidu
  • PDF科学纸翻译带有保留格式的pdf -基于ai完整保留排版的pdf文档全文双语翻译

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • modelscope
  • 开始以更轻松的方式开始构建具有LLM授权的多代理应用程序。

    Reviews

    5 (2)
    Avatar
    user_7SK1outW
    2025-04-24

    As a loyal user of MCP applications, I have to say that mcp_graphql by drestrepom is an outstanding tool! It significantly simplifies the process of working with GraphQL APIs thanks to its intuitive interface and comprehensive documentation. The seamless integration and robust functionality make it an essential resource for any developer looking to enhance their workflow. Highly recommend!

    Avatar
    user_h5YDzAfM
    2025-04-24

    As a loyal user of mcp, I found mcp_graphql by drestrepom to be an outstanding product. It offers seamless integration and powerful functionality for managing GraphQL endpoints. Easy to set up and extremely user-friendly, this tool has significantly improved my development workflow. Highly recommend it to any developer looking to optimize their GraphQL handling.