Skip to main content
Glama
Custom GitHub Issues MCP Server

Custom GitHub Issues MCP Server

by Vedika21K

Custom GitHub Issues MCP Server (Python / stdio)

A modular Model Context Protocol (MCP) server built from scratch in Python using the official mcp 2.x SDK (MCPServer), httpx, pydantic, and python-dotenv. It runs locally over stdio (no Docker required) and authenticates with your GitHub Personal Access Token (PAT) to inspect and manage issues across both public and private repositories.

Architecture

MCP Host / AI Client (Claude Desktop, Cursor, VS Code, Antigravity)
        │
        │  JSON-RPC over stdin / stdout (no Docker, no HTTP port)
        ▼
  server.py  (MCPServer tool definitions & stderr-only logging)
        │
        │  Pydantic v2 validation + async calls
        ▼
github_client.py  (httpx.AsyncClient + PAT auth + pagination + error handling)
        │
        │  HTTPS (Authorization: Bearer <GITHUB_TOKEN>)
        ▼
GitHub REST API (https://api.github.com)

Related MCP server: github-commits-mcp

Key Engineering Decisions

  • Pure stdio Transport Discipline: Logs and diagnostics write strictly to stderr so stdout carries only valid MCP JSON-RPC frames.

  • Pull Request Filtering & Accurate Pagination: GitHub's /repos/{owner}/{repo}/issues endpoint returns Pull Requests alongside Issues. list_repo_issues filters out items containing "pull_request" and paginates until the requested number of actual issues is collected.

  • Concurrent Cross-Repo Scanning: get_all_open_issues_across_repos queries /user/repos?visibility=all, skips repos with issues disabled or zero open items, and scans remaining repos concurrently with asyncio.Semaphore(5) to stay fast without triggering secondary rate limits.

  • Agent-Friendly Error Translation: Missing/placeholder tokens, invalid owner/repo formats, 401 auth failures, 403/429 rate limits (with UTC reset timestamps), 404 missing resources, and 422 validation errors are converted into structured, readable JSON error messages.

  • Testability Without Live Credentials: GitHubClient supports an injectable httpx.AsyncBaseTransport so the entire pytest suite runs offline against httpx.MockTransport.

Project Structure

  • server.py — MCPServer (mcp 2.x) exposing @mcp.tool() endpoints over stdio

  • github_client.py — Async GitHub REST API wrapper, Pydantic input validators, pagination, and error handling

  • tests/ — Offline pytest unit tests for validation, pagination, PR filtering, error mapping, and MCP tool outputs

  • verify_github.py — Standalone live check for PAT authentication (/user), repo access, and cross-repo scanning

  • test_mcp_stdio.py — End-to-end live MCP stdio client test harness

  • .github/workflows/ci.yml — GitHub Actions CI running ruff check . and pytest -v on Python 3.11 & 3.12

  • pyproject.toml — Project metadata, pytest, and ruff configuration

  • requirements.txt & requirements-dev.txt — Runtime and dev/test dependencies

  • .env.example & .gitignore — Environment template and ignore rules for .env and .venv/

  • LICENSE — MIT License

Implemented MCP Tools

Tool

Purpose

verify_github_auth

Confirms PAT authentication via GET /user and reports scopes & rate limit

list_repo_issues

Lists open, closed, or all issues in owner/repo (filters out PRs)

get_all_open_issues_across_repos

Scans all accessible public & private repos and groups open issues by repo

create_issue

Creates a new issue with title, optional body, labels, and assignees

update_issue

Updates title, body, state, labels/add_labels/remove_labels, assignees, and/or posts a comment

close_issue

Closes an issue with an optional closing comment and state_reason

Quick Start

1. Create a Virtual Environment & Install Dependencies (Python 3.11+)

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

2. Configure Your GitHub Personal Access Token

  1. Copy .env.example to .env:

    Copy-Item .env.example .env
  2. Generate a GitHub Personal Access Token:

    • Fine-grained PAT (recommended): GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens → select target repositories (or All repositories) → Repository permissions → Issues: Read and write and Metadata: Read-only.

    • Classic PAT: GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic) → select the repo scope (needed for private repositories).

  3. Paste the token into .env:

    GITHUB_TOKEN=your_real_token_here

3. Run Offline Unit Tests & Linter (CI Suite)

pip install -r requirements-dev.txt
ruff check .
pytest -v

4. Verify Live GitHub & MCP stdio Integration

# Verify PAT authentication and repo scan
python verify_github.py

# Run end-to-end stdio MCP client check (read-only)
python test_mcp_stdio.py --repo your-username/your-test-repo

# Optional: full create -> update -> close lifecycle test on a scratch repo
python test_mcp_stdio.py --repo your-username/your-test-repo --write-test

Launch the interactive MCP Inspector directly with your .venv Python (requires Node.js + npx, no uv needed):

npx @modelcontextprotocol/inspector .\.venv\Scripts\python.exe server.py

5. Connect to an MCP Client

Point your MCP client configuration to .venv\Scripts\python.exe and server.py:

{
  "mcpServers": {
    "github-issues": {
      "command": "E:\\Projects mysekf\\MCP server\\.venv\\Scripts\\python.exe",
      "args": ["E:\\Projects mysekf\\MCP server\\server.py"]
    }
  }
}

Example natural-language prompts once connected:

  • "Verify my GitHub MCP authentication."

  • "Which issues are still open across all my repos?"

  • "Create an issue in owner/repo titled 'Fix pagination edge case' with label 'bug'."

  • "Close issue #12 in owner/repo with a comment explaining it was resolved in v0.1.0."

Security Notes

  • GITHUB_TOKEN is loaded from .env (gitignored) and never hardcoded.

  • server.py logs strictly to stderr so stdout remains clean for MCP JSON-RPC frames.

  • Error handlers translate 401, 403/429 rate-limit resets, 404, and 422 responses into human-readable messages without leaking credentials.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers