Skip to main content
Glama
wanzunz

GitHub GraphQL API MCP

by wanzunz

call_github_graphql

Execute GraphQL queries to retrieve data from GitHub repositories, users, and organizations through the GitHub GraphQL API.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graphqlYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function for the 'call_github_graphql' tool. It executes the GraphQL query against GitHub's API using the requests library, handles authentication via GITHUB_TOKEN environment variable, and returns the JSON response as a formatted string or an error message.
    @mcp.tool()
    def call_github_graphql(graphql: str) -> str:
        """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
        """
        try:
            # Set request headers including authorization
            headers = {
                "Content-Type": "application/json",
                "Accept": "application/json",
            }
            if GITHUB_TOKEN:
                headers["Authorization"] = f"Bearer {GITHUB_TOKEN}"
            # Send POST request
            response = requests.post(GITHUB_API_URL, headers=headers, json={'query': graphql})
    
            # Check response status
            if response.status_code == 200:
                # MCP tool output is expected to be a string; serialize JSON response.
                return json.dumps(response.json(), ensure_ascii=False)
            else:
                raise Exception(f"request failed: {response.status_code} - {response.text}")
        except Exception as e:
            return f"{e}."

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wanzunz/github_graphql_api_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server