GitHub GraphQL API
STDIOA tool for querying and using GitHub GraphQL API through MCP client tools.
A tool for querying and using GitHub GraphQL API through MCP client tools.
English | 中文 | 日本語 | Español | Français
A tool based on MCP (Model Control Protocol) for querying and using the GitHub GraphQL API. This project provides a server that allows you to explore the GitHub GraphQL schema and execute GraphQL queries through MCP client tools (such as Claude AI).
GitHub GraphQL API offers significant advantages over traditional REST APIs:
This project leverages these advantages to provide tools that help you effectively explore the GitHub GraphQL API schema and execute optimized queries, providing AI assistants with efficient GitHub data retrieval capabilities.
This tool easily implements the following common operations:
With GraphQL's flexible query capabilities, you can also try to implement the following advanced analysis functions:
git clone https://github.com/wanzunz/github_graphql_api_mcp.git cd github_graphql_api_mcp
# 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
If you don't use Poetry, you can use the traditional method:
# 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 .
Create a .env
file and add your GitHub personal access token:
GITHUB_TOKEN="your_github_token_here"
You can create it by copying the .env.example
file:
cp .env.example .env
Then edit the .env
file, replacing your_github_token_here
with your actual GitHub token.
Make sure you have activated the Poetry virtual environment (poetry shell
), then:
python github_graphql_api_mcp_server.py
After the server starts, you can connect to it via an MCP client (such as Claude AI).
You can configure this MCP server in the Claude desktop app for one-click startup:
{ "mcpServers": { "github_mcp": { "command": "<your Python interpreter path>", "args": [ "--directory", "<project path>", "run", "github_graphql_api_mcp_server.py" ] } } }
Configuration example:
{ "mcpServers": { "github_mcp": { "command": "/usr/bin/python3", "args": [ "--directory", "/home/user/projects/github_graphql_api_mcp/", "run", "github_graphql_api_mcp_server.py" ] } } }
If you use conda or other environment management tools:
{ "mcpServers": { "github_mcp": { "command": "/opt/miniconda3/bin/python", "args": [ "--directory", "/Users/username/github/github_graphql_api_mcp/", "run", "github_graphql_api_mcp_server.py" ] } } }
After configuration, you can start the MCP server directly from the Claude desktop app without having to start it manually.
The server provides the following tools:
After connecting to the server with an MCP client, you can:
Query root type documentation:
Use the graphql_schema_root_type tool, parameter type_name="QUERY"
Query fields of specific types:
Use the print_type_field tool, parameters type_name="QUERY", type_fields_name="repository"
Query documentation for specific types:
Use the graphql_schema_type tool, parameter type_name="Repository"
Execute GraphQL queries:
Use the call_github_graphql tool, parameter:
graphql="""
query {
viewer {
login
name
}
}
"""
Below is an example of using the GitHub GraphQL API MCP with Claude:
.env
file, which should not be committed to version control systemsThis project is licensed under the MIT License - a very permissive license that allows users to freely use, modify, distribute, and commercialize this software, as long as they retain the copyright notice and license statement.
See MIT License for detailed terms.