Skip to main content
Glama
England Golf MCP

England Golf MCP

by mpvii
README.md
# england-golf-mcp

An MCP server for **My England Golf** — your WHS handicap index, score history and
competition results — so an agent can answer "how am I playing lately?" without
you opening the portal.

> **Unofficial.** England Golf publishes no API for individual golfers. This uses
> the member portal's *own* JSON API with a session you create yourself by logging
> in normally. It is fine for your own data; it is not an integration and is not
> endorsed by England Golf or DotGolf.

## Why it works this way

There are two things that look like an API, and only one is usable:

| Thing | What it is | Why |
| --- | --- | --- |
| `members.whsplatform.englandgolf.org` | The member portal | Login is an ASP.NET WebForms form (membership number + password). No OAuth/OIDC — `/.well-known/openid-configuration` is a 404. **But** its pages are Vue shells over its own JSON API (`/api/...`), and that API is what the tools call. |
| `isvapi.whsplatform.englandgolf.org` | DotGolf **ISV API** | Real JSON, incl. `club/members/{uid}/handicap`, but credentials are per **club** (JWT, `aud: isv-api`) and only issued to accredited software vendors. Not an individual's account. |

So the MCP:
- opens a **real browser** for you to sign in, and stores only the resulting cookies;
- never receives your password in this process;
- keeps the session in the **macOS Keychain**, not in a file;
- reads the portal's JSON, so there is no HTML scraping.

## Endpoints used

Found in the portal's Vue services (`/controls-vue/services/*.js`) and viewmodels
(`/controls/*/viewmodel.js`). All are relative to `members.whsplatform.englandgolf.org`.

| Endpoint | Method | Gives |
| --- | --- | --- |
| `/api/Member/GetSelf` | GET | profile, home club, `MemberUid` |
| `/api/Score/GetMemberHandicapIndex` | POST `{"memberUID": ...}` | Handicap Index, Low Index, calculation detail |
| `/api/Score/GetMyScores` | POST `{pageNumber, pageSize, ...}` | score history, newest first |
| `/api/competitions/GetMemberCompetitions` | GET (full param set) | competitions played |

`GetMemberCompetitions` only selects its action when **every** parameter is present
(`memberUid`, `clubId`, `competitionsPerPage`, `pageNumber`, `sortKey`, `sortAsc`,
`fromDate`, `memberCompetitionsOnly`, `otherPassportId`); without them it answers
404 "no resource matches".

## Install

```sh
git clone https://github.com/mpvii/england-golf-mcp.git
cd england-golf-mcp

uv sync --extra login
uv run playwright install chromium   # one-time browser download
```

Clone it anywhere — nothing in the code assumes a location. `--extra login` is
only needed to sign in; reading works with the base install once a session
exists.

Works for any England Golf member: there is no shared account, key or club
credential. Each person signs in as themselves.

## Sign in

```sh
uv run england-golf-mcp login
```

A Chromium window opens at the My England Golf login. Enter your WHS membership
number and password there (and clear any check England Golf asks for). When the
member area loads, the window closes and the session is saved.

```sh
uv run england-golf-mcp status      # is the session still live?
uv run england-golf-mcp logout      # forget it
```

If an endpoint changes, capture the raw responses:

```sh
uv run england-golf-mcp discover --out samples
```

## Use it as an MCP server

It speaks stdio by default (no arguments is `serve`).

**OpenCode / Claude Code** — add to your MCP config:

```json
{
  "mcp": {
    "servers": {
      "eg": {
        "type": "local",
        "command": ["/absolute/path/to/england-golf-mcp/.venv/bin/england-golf-mcp", "serve"],
        "environment": { "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin" }
      }
    }
  }
}
```

Replace `/absolute/path/to/england-golf-mcp` with the clone from above.

## Tools

| Tool | Returns |
| --- | --- |
| `eg_status` | Whether a live session is stored, with its save time and the member name |
| `eg_login` / `eg_logout` | Start the browser sign-in / remove the stored session |
| `eg_profile` | Name, membership number, home club, region, percentiles |
| `eg_handicap` | Handicap Index, Low Index, scores counted/used; `include_explanation` adds the WHS breakdown |
| `eg_scores` | Score history: date, course, tee, gross, differential, points, competition flag; `include_casual` adds general-play rounds |
| `eg_competitions` | Competitions played: name, club, date, round, holes |

All tools except login/logout are read-only.

## Notes and limits

- **Session lifetime is England Golf's call.** When the portal expires the
  cookies, `eg_*` tools return a `not signed in` error — run `login` again.
- **This is an internal API.** It is stable enough in practice but undocumented;
  if a field disappears, `discover` shows the current payload and `shape.py` is
  the one place to adjust.
- **Keychain item** is service `england-golf-mcp`, account `session`. It holds
  bearer cookies — treat it like a password.
- **One golfer per machine.** The session is a single Keychain slot, not a
  multi-user store.

## Privacy

- The only credential stored is the portal session cookie, in the macOS Keychain.
- Traffic goes to `members.whsplatform.englandgolf.org` and nowhere else. There
  is no telemetry, no server component, and no shared account.
- `samples/` holds raw API responses from *your* account; it is git-ignored.
  Never commit it.
- Tests use a made-up member and club.

## Development

```sh
uv sync --extra login
uv run pytest
uv run ruff check .
```

Layout:

```
src/england_golf_mcp/pages.py     page URLs + the four API paths
src/england_golf_mcp/keychain.py  macOS Keychain session storage
src/england_golf_mcp/session.py   browser login + status
src/england_golf_mcp/client.py    httpx portal client, 403 -> not signed in
src/england_golf_mcp/shape.py     JSON -> small, stable tool dicts
src/england_golf_mcp/service.py   endpoint calls per tool
src/england_golf_mcp/server.py    MCP tools + CLI
scripts/discover.py               save raw API responses for inspection
```

## Licence

MIT.

TDQS

B3.4/5.0

Scored across 7 tools

Disambiguation4/5

Session lifecycle (status/login/logout) and data retrieval (profile/handicap/scores/competitions) are clearly separated. Minor overlap: eg_profile also returns handicaps, which could be confused with eg_handicap, though the latter is clearly the detailed index tool.

Naming Consistency5/5

All tools use a consistent eg_ prefix with snake_case, and the verb/noun distinction is semantically meaningful: actions (login/logout/status) are verbs, data resources (profile/handicap/scores/competitions) are nouns.

Tool Count5/5

Seven tools is well-scoped for a read-only golf portal client: three for session management and four for distinct data views. Nothing is redundant or bloated.

Completeness4/5

Covers the core read path (session, profile, handicap, scores, competitions) with useful optional parameters. It is read-only with no score posting or certificate tool, but these are minor gaps for a portal viewer.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues