Skip to main content
Glama
wanzunz
by wanzunz

call_github_graphql

Execute GraphQL queries to retrieve data from GitHub repositories, users, and projects 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

Implementation Reference

  • The handler function for the 'call_github_graphql' tool. It executes a GraphQL query against GitHub's API using the requests library, handles authentication with a Bearer token from GITHUB_TOKEN environment variable, parses the JSON response, and returns it 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}."

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