Skip to main content

A Model Context Protocol (MCP) server that provides access to GitHub's GraphQL API

Project description

GitHub GraphQL MCP Server

QuentinCody/github-graphql-mcp-server context

A Model Context Protocol (MCP) server that provides access to GitHub's GraphQL API. This server exposes a single tool that allows executing arbitrary GraphQL queries and mutations against GitHub's API.

Features

  • Execute any GraphQL query against GitHub's API
  • Comprehensive error handling and reporting
  • Detailed documentation with example queries
  • Support for variables in GraphQL operations

Prerequisites

  • Python 3.10 or higher
  • A GitHub Personal Access Token (PAT)

Installation

  1. Clone this repository
  2. Set up a virtual environment (recommended):
    # On macOS/Linux
    python3 -m venv .venv
    source .venv/bin/activate
    
    # On Windows
    python -m venv .venv
    .venv\Scripts\activate
    
  3. Install dependencies:
    pip install -r requirements.txt
    

Usage

Running the Server

# If using a virtual environment, make sure it's activated
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Run the server with your GitHub token
GITHUB_TOKEN=your_github_token_here python github_graphql_mcp_server.py

Configuring with Claude for Desktop

Add the following to your Claude Desktop configuration file:

{
  "github-graphql": {
    "command": "/absolute/path/to/your/.venv/bin/python",
    "args": [
        "/absolute/path/to/github_graphql_mcp_server.py"
    ],
    "options": {
        "cwd": "/absolute/path/to/repository"
    },
    "env": {
        "GITHUB_TOKEN": "your_github_token_here"
    }
  }
}

Replace /absolute/path/to/ with the actual path to your server file and add your GitHub token.

Example Queries

Get Repository Information

query GetRepo($owner: String!, $name: String!) {
  repository(owner: $owner, name: $name) {
    name
    description
    stargazerCount
    url
    createdAt
    owner {
      login
      avatarUrl
    }
  }
}

Variables:

{
  "owner": "octocat",
  "name": "Hello-World"
}

Search Repositories

query SearchRepos($query: String!, $first: Int!) {
  search(query: $query, type: REPOSITORY, first: $first) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          name
          owner { login }
          description
          stargazerCount
          url
        }
      }
    }
  }
}

Variables:

{
  "query": "language:python stars:1000",
  "first": 5
}

Get User Information

query GetUserInfo($login: String!) {
  user(login: $login) {
    name
    login
    bio
    avatarUrl
    followers {
      totalCount
    }
    repositories(first: 5, orderBy: {field: STARGAZERS, direction: DESC}) {
      nodes {
        name
        description
        stargazerCount
      }
    }
  }
}

Variables:

{
  "login": "octocat"
}

GitHub API Rate Limits

Be aware of GitHub's API rate limits:

  • Authenticated requests: 5,000 requests per hour
  • Unauthenticated requests: 60 requests per hour

Troubleshooting

If you encounter issues:

  1. Check your GitHub token has the correct permissions
  2. Verify your virtual environment is properly set up and activated
  3. Ensure your token is correctly set in the environment variables
  4. If using Claude Desktop, ensure the path to Python is correct (use absolute path to the virtual environment Python)
  5. Look at the server logs for error messages
  6. Ensure your GraphQL query is valid for GitHub's schema
  7. Restart Claude for Desktop after making config changes

Common Errors

spawn python ENOENT

  • This error means the Python executable wasn't found
  • Solution: Use the full path to your Python executable in the virtual environment (e.g., /path/to/your/.venv/bin/python)

ModuleNotFoundError: No module named 'httpx' (or other packages)

  • The Python environment doesn't have the required dependencies installed
  • Solution: Make sure you've activated the virtual environment and run pip install -r requirements.txt

Error: GitHub token not found in environment variables

  • The server couldn't find your GitHub token

  • Solution: Make sure you've set the GITHUB_TOKEN environment variable

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1.tar.gz.

File metadata

  • Download URL: iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5ae1e5519acc9c8dea456705b5fbd31638457e339205eaa48212c1d41975da0d
MD5 f7605c22ba1719f0b071f2e61c691e1c
BLAKE2b-256 2b89a601701c1318fc3f4db95df89cf58cabe1a84d25fc5fc8a6eb3be2835267

See more details on using hashes here.

File details

Details for the file iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for iflow_mcp_quentincody_github_graphql_mcp_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a014845c3a5ba611bbba7269e80c95018a840d93db5fa74119effa7106e84e7
MD5 a2716ec63af0639fe76e553284e2a172
BLAKE2b-256 e0dce3dc63fc1763af6bdbc5666da20141e3356cf4735893601f75871d7c1709

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page