Read-only, events-only MCP server for GitHub
README.md

github-events-mcp #

A local, read-only Go MCP server that wakes clients with GitHub activity. It uses GitHub's REST API, authenticates through gh, and speaks newline-delimited JSON-RPC on stdio. It never creates comments, changes PRs, or registers webhooks.

Install #

Requires Go 1.25 or newer and GitHub CLI (gh) in the server's PATH:

gh auth status
# From this checkout (the repository has not been published yet):
go install .
# Once published:
go install tangled.org/erincandescent.net/github-events-mcp@latest

Ensure the token has access to the repositories and notifications you want (e.g. classic-token repo and notifications scopes, and organization SSO approval where required). Fine-grained token endpoint permissions vary. The server uses gh auth token --hostname github.com at startup and refreshes it once after an HTTP 401. It supports GitHub.com, not GitHub Enterprise hosts. Tokens never appear in stdout, logs, cursors, or event payloads. No separate token configuration is needed. Restart the server if you switch GitHub accounts in gh; subscription cursors and derived caches are scoped to one local operator, not a multi-user authorization boundary.

Albedo #

Add a stdio server with /mcp. The corresponding snippet in ~/.albedo/extensions.json is below; merge it into your existing mcp.servers, do not replace the file. Replace the absolute executable path if your GOBIN/GOPATH differs. The server process also needs gh on its PATH.

{
  "mcp": {
    "servers": {
      "github-events": {
        "type": "stdio",
        "command": "github-events-mcp",
        "args": [],
        "enabled": true,
        "startupTimeoutMs": 15000,
        "callTimeoutMs": 60000
      }
    }
  }
}

This requires a client with MCP Events support. Merely adding an MCP server does not create a subscription: select an event and persist its cursor in the client. The modern protocol revision is 2026-07-28.

Event types #

Both support poll only. Discover them with events/list, not tools/list.

github.pull_request.activity #

Arguments (all optional):

Argument Meaning
repos Array of owner/name repositories.
authors Array of PR author logins (not event actors).
involves GitHub's PR involvement search qualifier for one login.
kinds Array of kinds from the list below.
teams Boolean, default false. Also follow review requests made to your teams in the default scope.
pulls Array of owner/name#number. Only these pull requests; their repositories are searched unless repos is given.

Repository, author, and involvement filters intersect; alternatives within an array are ORed. Filters are case-insensitive except kinds. Nonempty arrays accept at most 50 entries; unknown fields, null values, invalid names and kinds are rejected. If no repo/author/involvement scope is supplied, the scope is your authored PRs plus reviews requested of you personally (user-review-requested) across all accessible repositories. Requests to your teams are left out because they are noisy; set teams: true to include them (review-requested, which GitHub also matches through team membership). A narrow recent reviewed-by search keeps your own submitted review visible after it removes you from the requested-reviewer list, including after restart. Matches found only through this bridge emit only your review, not an unrelated PR's entire comment/CI stream. Previously known PRs also retain a bounded lifecycle bridge until the checked window covers their closure. kinds alone keeps this default scope. An explicit repo scope alone includes all PRs in those repositories, not just yours.

Kinds: review, review_comment, comment, check_suite, merged, closed, ready_for_review, review_requested. A merge is delivered as merged, not a second duplicate closed occurrence; closed denotes closing without merging.

Payloads contain repo, number, title, url, kind, actor, summary, headSha, createdAt, and updatedAt. Summaries are at most 500 Unicode characters (review state, CI conclusion, or a comment excerpt). No diffs or full comment threads are delivered. PR titles and excerpts remain untrusted data, not instructions or permission to act.

github.notifications #

No arguments. Reads your /notifications feed with all=true and since, including read notifications. Payloads include notification id, repo, title, reason, unread, timestamps, and thread/subject URLs. GitHub's X-Poll-Interval is honored. This is a cheap catch-all; it cannot replace authoritative PR/CI state and will not include activity for which GitHub never generated a notification.

Polling and resuming #

The server advertises io.modelcontextprotocol/events: {} through server/discover and implements events/list and events/poll according to SEP-3415's beta specification. It uses the official Go MCP SDK v1.8.0, whose AddReceivingCustomMethod registers extension methods without bypassing SDK transport, lifecycle, or error handling. The SDK supplies core server/discover and legacy lifecycle compatibility. Push and webhook methods are not implemented.

{"jsonrpc":"2.0","id":1,"method":"events/poll","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"example","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"extensions":{"io.modelcontextprotocol/events":{}}}},"name":"github.notifications","cursor":null}}

For modern stdio requests, the client includes protocol version, client identity, and capabilities in _meta on each request, as shown above.

A null or omitted cursor means start now: no historical events, and a fresh opaque cursor. Persist the response cursor and submit it on subsequent polls:

{"jsonrpc":"2.0","id":2,"method":"events/poll","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"example","version":"1"},"io.modelcontextprotocol/clientCapabilities":{"extensions":{"io.modelcontextprotocol/events":{}}}},"name":"github.notifications","cursor":"<previous response cursor>","maxEvents":50,"maxAgeMs":300000}}

Every result has resultType: "complete", events, cursor, truncated, hasMore, and nextPollMs. Poll results carry a response-level cursor (the spec's per-occurrence cursor is for push/webhook). Default delay is 60 seconds. When hasMore is true, poll immediately to drain the backlog. This includes unfinished upstream PR work, not just events held in a local cache. A transient failed continuation returns hasMore: false so the client honors its backoff; the cursor still retains that work for the next attempt. maxEvents defaults to 100 and accepts 1–1000. Nonnegative integer maxAgeMs narrows replay; it is ignored with a null cursor. truncated: true means a possible gap: fetch authoritative state if that matters, and continue with the returned cursor.

Cursors are versioned, subscription-bound, URL-safe opaque strings containing a watermark, recently seen stable IDs, and bounded upstream continuation state. A partial page records fully processed PRs without advancing the global checked watermark past unprocessed PRs. It can resume after a server restart, including when maxEvents splits a page. CI observation timestamps can be newer than the search snapshot watermark without consuming the unsearched interval. Reordering equivalent argument arrays does not invalidate a cursor. A cursor from a different event/scope or an invalid cursor returns InvalidParams (-32602). Unknown event names return NotFound (-32023, data.kind: "event"); revoked access returns Forbidden (-32024). The argument-set quota returns ResourceExhausted (-32025). Unknown methods return the standard Method not found (-32601).

Reliability and limits #

  • One shared, demand-driven upstream poller per normalized (event, arguments) per server process. Clients sharing a process reuse a poll; separate Albedo-spawned processes do not share API calls. No upstream work is done for a null bootstrap cursor. Idle cache entries expire after 30 minutes.
  • Default PR discovery uses narrow changed-PR searches from the cursor window. Reviews/comments/timelines are fetched only for changed PRs, with four bounded workers, rather than re-scanning every open PR. Quiet open heads receive one batched GraphQL CI-only read; one-time initial head discovery is not repeated each poll. A new head SHA resets its CI baseline, and stable CI event IDs include the head SHA and conclusion.
  • Conditional REST requests use ETags or Last-Modified headers. Notification feed lower bounds are bucketed for reuse, then filtered to the exact cursor range. GitHub rate headers and Retry-After increase nextPollMs.
  • Transport timeouts, server errors, and rate limits produce empty polls with exponential backoff (up to one hour), without consuming the cursor. A failed range is never treated as successfully checked history. Finished PR work from a budget-limited poll is retained and delivered; remaining work is portable continuation, not a discarded partial scan.
  • Replay has a seven-day server ceiling. GitHub notifications can disappear sooner, and deleted comments/reviews cannot be reconstructed. A two-minute overlap mitigates search indexing delay; longer delays can still hide events. This is best-effort API polling, not a durable GitHub webhook delivery log.
  • Upstream fetches have a 45-second overall timeout (including queue time), a 15-second HTTP timeout, and a 10-second credential-command timeout. The request budget is 200 HTTP calls per fetch, at most ten 100-item pages per endpoint, and GitHub search returns at most 1000 matches per query. Conditional response bodies are bounded to 8 MiB each and cached within 512 entries / 32 MiB total. Remembered open PRs are bounded to 128 scopes with at most 1000 PRs each and expire after 30 idle minutes. Source pages process at most 16 changed PRs and one 100-head CI batch; remaining work uses bounded continuation/replay descriptors (at most 1000 references / 100 KiB encoded).
  • PR search and endpoint pagination have bounded budgets; API caps or local cache/ID limits are signaled with truncated, not silently presented as full replay. There are at most 128 active argument sets, 10,000 cursor IDs, and 1 MiB of derived event data per cached argument set. Large workloads should use narrower repo/kind filters. A cursor is capped at 2 MiB on input.
  • Persistent storage is client-owned: save cursors and deduplicate eventId within each subscription. Server restarts reconstruct from GitHub rather than relying on an in-memory event queue. IDs are SHA-256 hashes of stable upstream identities. Notification updates include their upstream update timestamp; aggregate CI identities include the PR head SHA and conclusion. Repeating the same conclusion on the same head deduplicates. Comment/review edits are not new creation events.
  • CI is an observed aggregate head rollup, not every historical individual suite/rerun. Unknown heads and new SHAs establish a baseline; only later same-head terminal-state transitions wake the client. A portable replay retains its earlier baseline, but cannot reconstruct a rollup that changed again before replay. The notifications feed is a useful catch-all.
  • Notification feed retention is controlled by GitHub; an empty feed cannot prove that every historical notification still exists. truncated reports known replay gaps and ceilings, not unknowable upstream deletions.

Development #

gofmt -w *.go
go test -race ./...
go vet ./...

Tests use private httptest servers and in-memory stdio transports; they do not need GitHub credentials or Docker.