Skip to main content
Glama
mcp-github-portfolio

mcp-github-portfolio

README.md
# mcp-github-portfolio

A read-only [Model Context Protocol](https://modelcontextprotocol.io) server (stdio) for public GitHub data. It lets an MCP client (Claude Desktop, Claude Code, an agent) do three things:

- list the public repositories of a user or organization,
- find open, unassigned "good first issue" issues,
- summarize the metadata of a pull request (size, age, time to merge, staleness).

## Problem

Maintainers and contributors keep asking the same three questions about a GitHub account: what is public there, where can I help, and how healthy is this PR. This server answers them with small JSON results an agent can reason over, without giving the agent any write access.

It does not audit repositories (licence, CI, README checks and so on). That is out of scope on purpose.

## Safety model

- Only `GET` requests are sent. There is no tool that writes.
- Private, disabled, fork and archived repositories are filtered out by default. Private ones are never returned.
- `GITHUB_TOKEN` is optional. It only raises the rate limit (60/h anonymous, 5000/h with a token). A token with no scopes is enough.
- The token is only sent to the configured API origin. A `Link` header pointing at another origin is refused.
- Rate limits are reported as tool errors. The server never sleeps or retries.

## Install

Requires Node 20 or newer.

```sh
npm ci
npm run build
```

## Run

```sh
node dist/index.js
```

The server speaks MCP over stdio. Add it to a client, for example in an MCP config file:

```json
{
  "mcpServers": {
    "github-portfolio": {
      "command": "node",
      "args": ["/path/to/mcp-github-portfolio/dist/index.js"],
      "env": { "GITHUB_TOKEN": "optional" }
    }
  }
}
```

Environment variables (see `.env.example`, fictitious values only):

- `GITHUB_TOKEN`: optional, raises the rate limit.
- `MCP_GITHUB_PORTFOLIO_OFFLINE=1`: serve the bundled fixtures instead of calling api.github.com.

## Tools

- `list_public_repos` (`owner`, `limit`, `sort`, `include_forks`, `include_archived`)
- `find_good_first_issues` (`owner`, `repo`, `label`, `include_assigned`, `limit`)
- `summarize_pull_request` (`owner`, `repo`, `number`)
- `get_rate_limit` (no arguments, does not consume quota)

## Try it with bundled sample data

`npm run demo` builds the project, starts the real stdio server as a child process in offline mode, and talks to it with the official SDK client. No network, no token.

Real output of `npm run demo` (only the `npm` banner lines are removed):

```text
tools: list_public_repos, find_good_first_issues, summarize_pull_request, get_rate_limit

$ list_public_repos {"owner":"example-org","sort":"stars","limit":5}
   412 stars  widget-kit   TypeScript
   233 stars  log-tail     Go
    96 stars  data-sketch  Python
    12 stars  docs-site    -
  count=4 truncated=false pagesFetched=2

$ find_good_first_issues {"owner":"example-org","limit":3}
  example-org/widget-kit#131  Button focus ring is clipped inside overflow containers
  example-org/log-tail#58  Add --since flag parsing tests
  example-org/data-sketch#9  Document the false positive rate of the Bloom filter

$ summarize_pull_request {"owner":"example-org","repo":"widget-kit","number":42}
{
  "repo": "example-org/widget-kit",
  "number": 42,
  "title": "Add keyboard navigation to the Tabs widget",
  "url": "https://github.com/example-org/widget-kit/pull/42",
  "state": "merged",
  "author": "alice-dev",
  "labels": [
    "enhancement",
    "a11y"
  ],
  "baseBranch": "main",
  "headBranch": "feature/pr-42",
  "commits": 5,
  "changedFiles": 6,
  "additions": 187,
  "deletions": 24,
  "size": "M",
  "comments": 4,
  "reviewComments": 7,
  "hasDescription": true,
  "createdAt": "2026-11-10T09:00:00Z",
  "updatedAt": "2026-11-12T10:30:00Z",
  "ageDays": 20.1,
  "hoursToMerge": 49.5,
  "staleDays": null
}
```

The fixtures are hand-written and fictitious. `docs-site` has no language, and the fixtures also contain a private repo, a fork and an archived repo that the output hides.

## Tests

```sh
npm run lint
npm run typecheck
npm test        # builds, then runs vitest
```

53 tests, no network, no token. They cover:

- pagination via `Link` headers, limits, `maxPages`, truncation,
- rate limits (403 with remaining 0, 429, `Retry-After`, mid-pagination),
- empty responses and unexpected body shapes,
- read-only behaviour, token handling, cross-origin `Link` refusal,
- the in-memory MCP transport and a real stdio end-to-end run through the SDK client.

## What was tested with mocks only

All GitHub traffic in tests and in the demo goes through an injected fetcher backed by fixtures. The real `fetch` against api.github.com is not exercised by the test suite. The shape of real GitHub responses is assumed from the REST API documentation, so a live smoke test is the first thing to do before relying on it.

## Limitations

- Listing uses `/users/{owner}/repos`, capped at 1000 repos (10 pages).
- Issue search uses the GitHub search API, which has its own tighter rate limit (10/min anonymous) and may return incomplete results.
- PR summaries read metadata only. They do not read the diff or the description text.
- No caching and no retries.
- Not published to npm. Run it from a clone.

## License

MIT. See `LICENSE`.