GitHub GraphQL API MCP
GitHub GraphQL API MCP
一个基于 MCP(模型控制协议)的工具,用于查询和使用 GitHub GraphQL API。该项目提供了一个服务器,允许您通过 MCP 客户端工具(例如 Claude AI)探索 GitHub GraphQL 模式并执行 GraphQL 查询。
为什么要使用 GitHub GraphQL API
GitHub GraphQL API 与传统 REST API 相比具有显著优势:
精确的数据检索:GraphQL 允许客户端精确指定他们需要的字段,避免多余的数据
减少令牌消耗:通过仅请求必要字段,API 响应大小显著减少,从而降低 AI 模型令牌消耗
相关数据的单次请求:一次查询可以检索多个相关资源,从而减少请求次数
自文档化:通过其内置的文档系统,您可以直接查询和了解 API 模式,而无需外部文档
强类型系统:提供类型检查,减少错误
该项目利用这些优势提供工具,帮助您有效地探索 GitHub GraphQL API 模式并执行优化查询,为 AI 助手提供高效的 GitHub 数据检索功能。
Related MCP server: @cloud9-labs/mcp-github
应用场景
基本功能
该工具可以轻松实现以下常见操作:
仓库基本信息查询:获取仓库名称、描述、star数、分支列表等基本信息
问题数据检索:查询特定存储库的问题列表、详细信息或评论内容
用户资料访问:检索用户的个人资料、贡献统计数据和其他公共信息
Pull Request Status View :获取PR基本状态、评论内容、合并信息
项目依赖查询:检索项目依赖包列表和版本信息
探索性高级功能
借助 GraphQL 灵活的查询能力,你还可以尝试实现以下高级分析功能:
存储库贡献趋势分析:通过汇总提交数据、评估项目活动来分析代码更新频率和贡献者参与度
问题管理与分类:根据自定义条件整理问题数据,发现需要优先处理的问题,提高项目管理效率
代码审查模式分析:分析 PR 评论和审查流程,识别常见问题模式,优化代码审查工作流程
贡献者网络可视化:建立项目贡献者之间的合作关系,发现关键贡献者和专业领域
依赖健康评估:评估项目依赖的更新频率和潜在的安全问题,提供依赖管理建议
特征
查询 GitHub GraphQL 模式根类型(查询/变异)
获取特定类型的详细文档
查询特定字段的文档和参数
直接执行 GitHub GraphQL API 查询,精确检索所需数据,减少令牌消耗
双语支持(英语/中文)
先决条件
Python 3.10 或更高版本
GitHub 个人访问令牌(用于访问 GitHub API)
Poetry(推荐的依赖管理工具)
安装
克隆存储库:
git clone https://github.com/wanzunz/github_graphql_api_mcp.git
cd github_graphql_api_mcp使用 Poetry 安装依赖项:
# If you haven't installed Poetry yet, install it first:
# curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies using Poetry
poetry install
# Activate the virtual environment
poetry shell如果你不使用 Poetry,你可以使用传统方法:
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Linux/MacOS
# or
.venv\Scripts\activate # Windows
# Install dependencies
pip install -e .配置环境变量:
创建一个.env文件并添加您的 GitHub 个人访问令牌:
GITHUB_TOKEN="your_github_token_here"您可以通过复制.env.example文件来创建它:
cp .env.example .env然后编辑.env文件,将your_github_token_here替换为你的实际 GitHub 令牌。
用法
启动服务器
确保你已经激活了 Poetry 虚拟环境( poetry shell ),然后:
跑步
python github_graphql_api_mcp_server.py服务器启动后,您可以通过 MCP 客户端(例如 Claude AI)连接到它。
在 Claude Desktop 中配置
您可以在 Claude 桌面应用中配置此 MCP 服务器,实现一键启动:
打开 Claude 桌面应用程序
进入设置,找到 MCP 服务器配置部分
添加如下配置(根据你的实际路径修改):
{
"mcpServers": {
"github_mcp": {
"command": "<your Python interpreter path>",
"args": [
"--directory",
"<project path>",
"run",
"github_graphql_api_mcp_server.py"
]
}
}
}配置示例:
{
"mcpServers": {
"github_mcp": {
"command": "/usr/bin/python3",
"args": [
"--directory",
"/home/user/projects/github_graphql_api_mcp/",
"run",
"github_graphql_api_mcp_server.py"
]
}
}
}如果您使用 conda 或其他环境管理工具:
{
"mcpServers": {
"github_mcp": {
"command": "/opt/miniconda3/bin/python",
"args": [
"--directory",
"/Users/username/github/github_graphql_api_mcp/",
"run",
"github_graphql_api_mcp_server.py"
]
}
}
}配置完成后,您可以直接从 Claude 桌面应用程序启动 MCP 服务器,而无需手动启动。
可用工具
该服务器提供以下工具:
print_type_field :查询 GitHub GraphQL 模式根类型的字段
graphql_schema_root_type :获取根类型的文档(查询/变异)
graphql_schema_type :查询特定类型的文档
call_github_graphql :执行 GitHub GraphQL API 查询
使用示例
使用 MCP 客户端连接到服务器后,您可以:
查询根类型文档:
Use the graphql_schema_root_type tool, parameter type_name="QUERY"查询特定类型的字段:
Use the print_type_field tool, parameters type_name="QUERY", type_fields_name="repository"查询特定类型的文档:
Use the graphql_schema_type tool, parameter type_name="Repository"执行 GraphQL 查询:
Use the call_github_graphql tool, parameter: graphql=""" query { viewer { login name } } """
示例截图
以下是使用 GitHub GraphQL API MCP 与 Claude 的示例:

笔记
使用前请确保你的 GitHub 令牌具有适当的权限
令牌存储在
.env文件中,该文件不应提交到版本控制系统查询应符合 GitHub API 使用限制
执照
该项目根据 MIT 许可证获得许可 - 这是一个非常宽松的许可证,允许用户自由使用、修改、分发和商业化该软件,只要他们保留版权声明和许可声明。
请参阅MIT 许可证以了解详细条款。
Available Tools
4 toolscall_github_graphqlB
A tool to execute GitHub GraphQL API queries. Before using, it's recommended to check the documentation first, and include ID fields in your queries for easier follow-up operations Args: graphql: The GraphQL query Returns: str: Execution result
| Name | Required | Description | Default |
|---|---|---|---|
| graphql | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions checking documentation and including ID fields, which adds some operational context, but fails to address critical traits like authentication requirements, rate limits, error handling, or mutation vs. query behavior. For a GraphQL API tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves in practice.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized and front-loaded, starting with the core purpose and usage recommendation in the first sentence. The Args and Returns sections are structured but could be more integrated. There's minimal waste, though the 'Returns: str: Execution result' is redundant given the output schema, slightly reducing efficiency.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (GraphQL API execution) and the presence of an output schema (which handles return values), the description is partially complete. It covers basic purpose and some usage tips but lacks details on authentication, error cases, or integration with sibling tools. Without annotations and with low schema coverage, it doesn't fully equip an agent for reliable tool invocation in a GitHub context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds minimal meaning beyond the input schema: it names the single parameter 'graphql' and states it's 'The GraphQL query', which the schema already indicates as a string type. With 0% schema description coverage, the description doesn't compensate by explaining query syntax, validation rules, or examples. The baseline is 3 because the schema covers the parameter's existence and type, but the description fails to enhance understanding significantly.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose as 'execute GitHub GraphQL API queries' with a specific verb (execute) and resource (GitHub GraphQL API queries). It distinguishes itself from sibling tools like graphql_schema_root_type and graphql_schema_type by focusing on query execution rather than schema exploration. However, it doesn't explicitly contrast with print_type_field, leaving some sibling differentiation incomplete.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides implied usage guidance by recommending checking documentation first and including ID fields for follow-up operations, which suggests context for when to use this tool effectively. However, it lacks explicit when/when-not criteria or named alternatives to sibling tools, leaving the agent to infer optimal usage scenarios without clear boundaries.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
graphql_schema_root_typeC
A tool to query GitHub GraphQL schema root types. You need to provide the root type name (QUERY/MUTATION) Args: type_name: root type (QUERY or MUTATION) Returns: str: Documentation content
| Name | Required | Description | Default |
|---|---|---|---|
| type_name | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden but offers minimal behavioral context. It states the tool returns documentation content as a string but doesn't disclose authentication requirements, rate limits, error handling, or what specific documentation format to expect. The 'query' verb implies read-only, but this isn't explicitly confirmed.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized with three sentences: purpose statement, parameter guidance, and return value. It's front-loaded with the core function. Minor improvements could include bullet points for Args/Returns, but overall it's efficient with minimal waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on authentication, error cases, the structure of returned documentation, or how this integrates with sibling tools. The return type 'str: Documentation content' is vague without examples or format specifications.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description compensates by explaining that 'type_name' should be 'QUERY or MUTATION' and represents the 'root type name.' This adds meaningful context beyond the schema's generic 'Type Name' title, though it doesn't detail format constraints or examples.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose as 'query GitHub GraphQL schema root types' with specific resource (GitHub GraphQL schema) and verb (query). It distinguishes from sibling 'graphql_schema_type' by focusing on root types only, though it doesn't explicitly contrast with 'call_github_graphql' or 'print_type_field'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'graphql_schema_type' for non-root types or 'call_github_graphql' for actual queries. The description mentions needing to provide root type name but doesn't explain use cases or prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
graphql_schema_typeB
A tool to query specific type documentation in GitHub GraphQL schema. You need to provide the type_name
Args:
type_name: Type name like SecurityAdvisoryConnection
Returns:
str: Documentation content
| Name | Required | Description | Default |
|---|---|---|---|
| type_name | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool queries documentation, implying a read-only operation, but doesn't specify if it's safe, requires authentication, has rate limits, or what happens on errors. For a query tool with zero annotation coverage, this leaves significant behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized and front-loaded: the first sentence states the purpose clearly. The 'Args:' and 'Returns:' sections are structured but slightly redundant with the schema. It's concise with no wasted words, though the formatting could be more integrated.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is somewhat complete but has gaps. It covers the basic purpose and parameter semantics but lacks usage guidelines, behavioral details, and output explanation. For a simple query tool, it's adequate but not fully comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 0%, so the description must compensate. It explains the single parameter 'type_name' as 'Type name like `SecurityAdvisoryConnection`,' adding meaning beyond the schema's basic 'string' type. This clarifies the parameter's purpose and provides an example, though it could be more detailed about valid type names or constraints.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'query specific type documentation in GitHub GraphQL schema.' It specifies the verb ('query'), resource ('type documentation'), and domain ('GitHub GraphQL schema'). However, it doesn't explicitly differentiate from sibling tools like 'graphql_schema_root_type' or 'print_type_field' beyond mentioning 'specific type' documentation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides minimal guidance: 'You need to provide the type_name' and gives an example ('SecurityAdvisoryConnection'). It doesn't explain when to use this tool versus alternatives like 'graphql_schema_root_type' or 'print_type_field,' nor does it mention prerequisites or exclusions. The guidance is basic and lacks context for tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
print_type_fieldB
A tool to query GitHub GraphQL schema root type fields. You need to provide root_type_name and type_fields_name
Args:
type_name: root type like QUERY or MUTATION
type_fields_name: field name like repository based on root type documentation
Returns:
str: Documentation content for the specified field
| Name | Required | Description | Default |
|---|---|---|---|
| type_name | Yes | ||
| type_fields_name | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It discloses that the tool returns documentation content as a string, which is useful behavioral information. However, it doesn't mention whether this is a read-only operation, what happens with invalid inputs, if there are rate limits, authentication requirements, or error behavior. For a query tool with zero annotation coverage, this leaves significant behavioral gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is reasonably concise but has structural issues. The first sentence clearly states the purpose, but the parameter explanations are formatted as 'Args:' and 'Returns:' sections which are somewhat redundant with the schema. The information is front-loaded but could be more efficiently integrated. It's not excessively verbose but has minor organizational inefficiencies.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 2 parameters with 0% schema coverage and no output schema, the description provides adequate parameter semantics and specifies the return type as a string. However, it doesn't explain the format of the returned documentation content, error conditions, or authentication requirements. For a query tool with no annotations, this is minimally complete but lacks depth about operational behavior and integration context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, so the description must compensate. It provides meaningful semantics for both parameters: 'type_name' is explained as 'root type like `QUERY` or `MUTATION`' and 'type_fields_name' as 'field name like `repository` based on root type documentation'. This adds substantial value beyond the bare schema, though it doesn't provide exhaustive examples or format details. With 2 parameters fully addressed, this exceeds the baseline expectation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'query GitHub GraphQL schema root type fields' with specific verbs ('query') and resources ('GitHub GraphQL schema root type fields'). It distinguishes from siblings like 'call_github_graphql' (which executes queries) and 'graphql_schema_type' (which might query non-root types), but doesn't explicitly contrast them. The purpose is specific but sibling differentiation is implied rather than explicit.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions 'based on root type documentation' but doesn't specify when this tool is appropriate compared to sibling tools like 'graphql_schema_root_type' or 'graphql_schema_type'. There are no explicit when/when-not instructions or named alternatives, leaving usage context unclear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
- First observed
call_github_graphql - First observed
graphql_schema_root_type - First observed
graphql_schema_type - First observed
print_type_field
TDQS
Scored across 4 tools
The tools have overlapping purposes focused on GitHub GraphQL schema exploration, which could cause confusion. call_github_graphql is distinct for executing queries, but graphql_schema_root_type, graphql_schema_type, and print_type_field all retrieve schema documentation with subtle differences in scope (root types vs. specific types vs. root type fields). Descriptions help clarify, but an agent might struggle to choose between them for schema inspection tasks.
Tool names follow a consistent snake_case pattern with clear verb_noun structure (e.g., call_github_graphql, graphql_schema_type). Minor deviations exist, such as graphql_schema_root_type using 'root_type' while print_type_field uses 'type_field', but overall the naming is predictable and readable across all tools.
With 4 tools, the count is reasonable for a GitHub GraphQL API server, providing a focused set for query execution and schema exploration. It's slightly thin for comprehensive API coverage but well-scoped for its intended purpose, avoiding bloat while supporting core workflows like querying and schema lookup.
The tool set covers query execution and schema documentation retrieval, but has notable gaps for a GitHub API surface. It lacks CRUD operations for resources like repositories, issues, or pull requests, and doesn't support mutations or advanced query building. Agents can work around this by crafting GraphQL queries, but the surface is incomplete for typical GitHub automation tasks.
Maintenance
Related MCP Connectors
The Grafbase MCP server sits in front of a GraphQL API and exposes an MCP protocol-compliant interface that allows AI agents and LLMs to explore and query GraphQL APIs using natural language. It provides tools to search schemas, introspect types and fields, and execute GraphQL queries while minimizing context bloat by returning only relevant schema subsets, with built-in support for authentication, authorization, and configurable access control.
Repository knowledge graph MCP server for codebase understanding and debugging.
An MCP server that gives your AI access to the source code and docs of all public github repos
The Cortex MCP server provides read-only access to real-time engineering context from the Cortex developer portal, allowing AI coding assistants to answer natural language questions about your organization's catalog (microservices, libraries, domains, teams, infrastructure), scorecards (engineering standards and best practices), initiatives (goals and deadlines), and Engineering Intelligence metrics. It includes tools for querying documentation, tracking personal entities, and accessing AI-assisted insights across the entire Cortex ecosystem.
Related MCP Servers
- FlicenseAqualityBmaintenanceRefined MCP server for GitHub GraphQL API. GitHub's official MCP Server exposes dozens of low-level tools that bloat token usage and are mostly impractical for LLMs. gh-mcp achieves the best of both worlds by providing a single, powerful interface: GitHub GraphQL, wrapped with smart abstractions.2-
- AlicenseBqualityDmaintenanceMCP (Model Context Protocol) server for GitHub API integration. This server provides comprehensive tools for interacting with GitHub repositories, issues, pull requests, branches, and code search through a unified interface.153 npmMIT
- AlicenseNot gradedqualityBmaintenanceMCP server providing maximum practical control over GitHub via REST and GraphQL APIs, exposing 22 tools for repository management, file operations, issues, PRs, Actions, and more.MIT
- AlicenseNot gradedqualityBmaintenanceA lightweight MCP server that exposes GitHub operations as tools over HTTP, enabling any MCP-compatible client to interact with GitHub repositories without a built-in connector.1MIT