Skip to main content
Glama
intelligent-golf-mcp

intelligent-golf-mcp

by mpvii
README.md
# intelligent-golf-mcp

An MCP server for your **Intelligent Golf** club website — WHS handicap, the
handicap record, every round you have played with hole-by-hole scorecards, the
competitions you have entered (with tee times, partners and published results),
your own tee bookings, and the club's course status, news and diary — so an agent
can answer "how am I playing?", "who am I playing with?" and "what's on at the
club?" without you opening the member site.

> **Unofficial.** Intelligent Golf publishes no API for individual members. This
> uses the club's own website 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 Intelligent Golf.

## Why it works this way

Intelligent Golf runs a member website for each club on its own subdomain, and
those sites are server-rendered PHP. There is no OAuth and no JSON API for
members: the sign-in is a form asking for a **member id** and a **PIN**, and the
member pages are HTML.

So the MCP:

- opens a **real browser** for you to sign in, and stores only the resulting
  cookies;
- never receives your member id or PIN in this process;
- keeps the session in the **macOS Keychain**, not in a file;
- parses the member pages, and returns small, stable dictionaries.

One quirk matters: with no live session a member page still answers `200`, but
serves the login page. The **page title** is the only reliable signal —
`Login Required` means "sign in again", `Sorry, we couldn't find this page` means
the site moved. Status codes cannot tell them apart.

## Pages used

All relative to your club's host (`https://<club>.intelligentgolf.co.uk`).

| Page | Gives |
| --- | --- |
| `/hcaprecord.php` | name, club, CDH id, current and low Handicap Index, the WHS record |
| `/roundmgmt.php` | every round: competition, date, course, tee, gross, nett, Stableford points |
| `/competition2.php?time=future` | upcoming competitions, fee and whether you are entered |
| `/competition2.php?tab=details&compid=N` | one competition: entry, tee time, partners and team |
| `/competition.php?compid=N` | published results and your finishing position |
| `/viewround.php?roundid=N` | one round, hole by hole |
| `/memberbooking/?date=DD-MM-YYYY&course=1&group=1` | the tee sheet (`group=2` is the 10th tee) |
| `/course_status`, `/news.php`, `/diary.php` | course status, news and the club diary |

`handicap.php`, `teetimes.php` and `booking.php` are administrative pages and
answer `Access Denied` to ordinary members, so the member-facing routes above are
the ones used.

## Install

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

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

`--extra login` is only needed to sign in; reading works with the base install
once a session exists.

## Configure your club

Every club has its own host, so the club is configuration, not code — the
repository stays generic. Set `IG_CLUB` to the subdomain (or a full host/custom
domain):

```sh
export IG_CLUB=myclub                       # myclub.intelligentgolf.co.uk
export IG_CLUB=myclub.intelligentgolf.co.uk # the same host, explicitly
export IG_CLUB=https://golf.example.com     # a club on its own domain
```

Pass `--club` to override it for one command.

## Sign in

```sh
uv run intelligent-golf-mcp --club myclub login
```

A Chromium window opens at the club's login. Enter your member id and PIN there.
When the member area loads, the window closes and the session is saved.

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

If a page changes shape, capture the raw pages:

```sh
uv run intelligent-golf-mcp --club myclub 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": {
      "ig": {
        "type": "local",
        "command": ["/absolute/path/to/intelligent-golf-mcp/.venv/bin/intelligent-golf-mcp", "serve"],
        "environment": {
          "IG_CLUB": "myclub",
          "PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
        }
      }
    }
  }
}
```

Replace the path with your clone and `myclub` with your club's subdomain.

## Tools

| Tool | Returns |
| --- | --- |
| `ig_status` | Whether a live session is stored, for which club, and the member's name |
| `ig_login` / `ig_logout` | Start the browser sign-in / remove the stored session |
| `ig_profile` | Name, club, CDH id, current and low Handicap Index, member type |
| `ig_handicap` | Current and low index, scores in the record, last score date, best differential |
| `ig_scores` | The WHS record: date, course, tee, gross, PCC, differential |
| `ig_results` | Your round history: competition, date, course, gross, nett, Stableford |
| `ig_competitions` | Upcoming competitions with fee, entry status and signup opening/closing dates |
| `ig_competition` | One competition: entry status, fee, tee time, partners and team members |
| `ig_leaderboard` | Published results for one competition, with your own row |
| `ig_round` | Hole-by-hole scorecard: par, SI, score, points, front/back splits |
| `ig_bookings` | Your own tee reservations over the next N days, on both tees |
| `ig_course_status` | Course status, winter rules and the update date |
| `ig_news` | Club news: title, date, summary and link |
| `ig_diary` | The club diary for a month: events, times and competition links |
| `ig_tee_times` | Bookable tee slots for a date, by 1st or 10th tee |

Everything is read-only. The tools never book, cancel or enter anything: only
`ig_login`/`ig_logout` change local state.

`ig_tee_times` returns **counts** for taken slots, never other members' names.
The two honest exceptions: `ig_bookings` names the players in your own slot (so
you can see who you are playing with), and `ig_leaderboard` returns the club's
published results, which name entrants. There is deliberately no
member-directory tool.

## Notes and limits

- **Session lifetime is the club's call.** When the site expires the cookies,
  the tools return a `not signed in` error — run `login` again.
- **This is markup, not an API.** Intelligent Golf can change a page at any time;
  if a field disappears, `discover` shows the current markup and `parse.py` is
  the one place to adjust.
- **The round-history table is malformed.** Its rows are not closed with `</tr>`,
  so the parser uses `lxml` (libxml2), which repairs them the way a browser does.
- **Competition dates on the lists have no year.** They are placed in the next or
  previous year relative to today; the round history does print a full date.
- **`ig_bookings` scans the tee sheets.** There is no "my bookings" page, so it
  fetches one sheet per day per tee: 14 days is the default, 60 the maximum.
  `ig_tee_times` is the cheap way to look at a single date.
- **`ig_news` reads the front page.** Older items need the site's own archive;
  the tool does not page through it.
- **`ig_leaderboard` follows the field size.** `limit` trims the returned rows,
  but `mine` is always filled in from the full table.
- **Keychain item** is service `intelligent-golf-mcp`, account = your club's host,
  so sessions for different clubs can coexist. It holds bearer cookies — treat it
  like a password.
- **One member per machine.** A session belongs to you; there is no shared
  account.

## Privacy

- The only credential stored is the session cookie, in the macOS Keychain.
- Traffic goes to your club's Intelligent Golf host and nowhere else. There is no
  telemetry, no server component and no shared account.
- Other members' names appear only where they are part of your own golf: the
  players in your booking, and the club's published competition results.
- `samples/` holds raw pages 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/intelligent_golf_mcp/config.py    club host from IG_CLUB
src/intelligent_golf_mcp/keychain.py  macOS Keychain, one account per club
src/intelligent_golf_mcp/session.py   browser login + status
src/intelligent_golf_mcp/client.py    httpx client; login-page title -> not signed in
src/intelligent_golf_mcp/parse.py     HTML -> small, stable tool dicts
src/intelligent_golf_mcp/service.py   page fetch per tool
src/intelligent_golf_mcp/server.py    MCP tools + CLI
```

## Licence

MIT.

TDQS

B3.2/5.0

Scored across 16 tools

Disambiguation4/5

Most tools target clearly distinct resources, and the descriptions explicitly disambiguate the tricky pairs (ig_competitions list vs. ig_competition detail, ig_tee_times availability vs. ig_bookings own reservations). Minor overlaps remain: ig_scores vs. ig_results vs. ig_round all expose round data at different granularity, ig_handicap partially duplicates ig_profile, and ig_status vs. ig_course_status share a name stem.

Naming Consistency4/5

Every tool carries the same ig_ prefix in snake_case, and the singular/plural split (competition/competitions, score/result/round) is used meaningfully rather than randomly. The only deviation is that ig_login/ig_logout are verbs while the rest are resource nouns, which is conventional and harmless.

Tool Count4/5

16 tools is at the upper edge of comfortable, but each maps to a genuinely different data view in the member portal (session, profile, handicap, records, competitions, leaderboard, scorecard, bookings, course status, news, diary, tee times), so little feels padded.

Completeness3/5

Read coverage is strong, but the surface is almost entirely read-only: there is no tool to actually book a tee slot found via ig_tee_times, cancel a booking, or enter a competition whose status is shown by ig_competitions/ig_competition. These are core member actions, so an agent will hit a dead end at the point of acting.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues