This document describes the GraphQL tools added to the GitHub MCP server that provide direct access to GitHub's GraphQL API.
Executes a GraphQL query against GitHub's API and returns the results.
query(required): The GraphQL query string to executevariables(optional): Variables for the GraphQL query as a JSON object
Returns a JSON object with:
query: The original query stringvariables: The variables passed to the querysuccess: Boolean indicating if the query executed successfullydata: The GraphQL response data (if successful)error: Error message if execution failederror_type: Type of execution error (rate_limit, authentication, permission, not_found, execution_error)graphql_errors: Any GraphQL-specific errors from the response
{
"query": "query { viewer { login } }",
"variables": {},
"success": true,
"data": {
"viewer": {
"login": "username"
}
}
}The execution tool uses GitHub's REST client to make raw HTTP requests to the GraphQL endpoint (/graphql), allowing for arbitrary GraphQL query execution while maintaining proper authentication and error handling.
The tool provides comprehensive error categorization:
- Syntax errors: Malformed GraphQL syntax
- Field errors: References to non-existent fields
- Type errors: Type-related validation issues
- Client errors: Authentication or connectivity issues
- Rate limit errors: API rate limiting
- Permission errors: Access denied to resources
- Not found errors: Referenced resources don't exist
This tool is part of the "graphql" toolset and can be enabled through the dynamic toolset system:
- Enable the graphql toolset:
enable_toolsetwith name "graphql" - Use
execute_graphql_queryto run queries and get results
The tool includes comprehensive tests covering:
- Tool definition validation
- Required parameter checking
- Response format validation
- Variable handling
- Error categorization
Run tests with: go test -v ./pkg/github -run GraphQL