Development
This page is for people working on starling-mcp itself. Start with CONTRIBUTING.md for the workflow, and use this page for how the code fits together.
You need Go 1.26 or later, and Docker for building the image.
git clone https://github.com/mattoddie/starling-mcp.gitcd starling-mcpmake test # runs all tests against a mock Starling API| Target | What it does |
|---|---|
make build |
Build a static binary to bin/starling-mcp. Pass VERSION=1.2.3 to stamp a version. |
make test |
go test ./... |
make lint |
Fail if any file needs gofmt, then run go vet ./... |
make docs |
Regenerate docs/tools.md and the tools and prompts in mcpb/manifest.json from the tool definitions |
make docs-check |
Fail if docs/tools.md or the manifest is out of date (CI runs this) |
make image |
Build the Docker image as starling-mcp:$(VERSION) |
make mcpb |
Build the Claude Desktop bundles, one per OS and architecture, in dist/. See Releasing. |
make server-json |
After make mcpb, write dist/server.json: the MCP Registry entry with VERSION and the bundles’ SHA-256s |
make registry-validate |
Check server.json (or SERVER_JSON=dist/server.json) with the registry’s validator, using the pinned mcp-publisher |
The project deliberately has only two direct dependencies: the official MCP Go SDK, github.com/modelcontextprotocol/go-sdk, and github.com/google/jsonschema-go, which the SDK uses for input schemas. Everything else, including the Starling client, is the standard library. Please discuss before adding a dependency.
Project layout
Section titled “Project layout”cmd/├── starling-mcp/ # the binary: serve, healthcheck and version commands├── gen-tool-docs/ # writes docs/tools.md from the registered tools and prompts└── mcpb/ # keeps mcpb/manifest.json's tools and prompts current, and packs the .mcpb bundlesmcpb/ # the MCP Bundle manifest and icon for Claude Desktopinternal/├── config/ # environment variables → typed Config (validation lives here)├── starling/│ ├── client.go # Client: Bearer auth, GET only, retries, error mapping, token redaction│ ├── endpoints.go # typed reads of each endpoint used│ ├── models.go # the API's JSON shapes│ ├── money.go # {currency, minorUnits} and its display│ └── starlingtest/ # an in-process fake of the Starling API for tests├── feed/ # the in-memory transaction cache (STARLING_CACHE_SECONDS)├── ledger/ # classifies every transaction: spending, income, internal, owner pay, refund, ignored├── analysis/ # pure calculations: periods, summaries, recurring detection, income, forecasts, unusual payments├── synth/ # the synthetic account generator, with an answer key of what it planted├── httpserver/ # stateless Streamable HTTP, bearer auth, Host allow-list, /health└── tools/ ├── tools.go # the registration framework: Def, Gate, add[In](), schemas ├── holders.go # the configured account holders, their clients and caches ├── audit.go # the audit log (STARLING_AUDIT_LOG) ├── server.go # NewServer(): server instructions, registers every toolset and the prompts ├── prompts.go # the built-in MCP prompts └── <toolset>.go # one file per toolset: accounts, transactions, insights, bills, spaces, rawThe layers only point one way: tools use analysis, ledger and feed, which use starling and config. analysis and ledger never touch the network, which is what makes them easy to test exactly.
How a request flows
Section titled “How a request flows”- An MCP client calls a tool, for example
starling_spending_summary {period: "last-month", group_by: "category"}. - The MCP SDK validates the arguments against the tool’s JSON Schema, which was inferred from its Go input struct, and decodes them into that struct.
- The handler registered by
add()runs. It picks the holder, loads its accounts and, for an insight, the transaction feed for the period, in chunks.feed.Cacheserves what it has and fetches only the missing days. ledgerclassifies every transaction (spending, income, internal, owner pay, refund or ignored) using the holder’s own accounts, the other holders,STARLING_OWN_ACCOUNTSandSTARLING_COMPANY_ACCOUNTS.analysistotals, groups or detects over the classified ledger, and records what it left out.- The handler returns a compact summary.
add()serialises it to indented JSON text. A returned error becomesisError: truewith the message, so the model can see what went wrong and adjust. Error text is scrubbed of the token.
starling.Client sends every request with the token as a Bearer header. It has no method for anything but GET, it never follows a redirect, caps responses at 64 MiB, retries 429 and 503 with a back-off, and maps 401 and 403 to messages that say what to do.
Adding a tool
Section titled “Adding a tool”Tools are defined with the generic add[In]() in the file for their toolset. A complete example, starling_list_spaces from spaces.go:
add(c, Def{Toolset: "spaces", Name: "starling_list_spaces", Title: "Starling Spaces", Idempotent: true, Gate: Read, Description: "Savings goals and spending spaces of each account, with balance, target and how much of the target is saved."}, func(ctx context.Context, in HolderArgs) (any, error) { h, err := c.Holders.Get(in.Holder) if err != nil { return nil, err } accts, err := h.Select(ctx, in.Account) if err != nil { return nil, err } // ... read each account's spaces and build a compact summary })The input struct
Section titled “The input struct”The input struct is the tool’s argument schema:
- The
jsontag names the argument. Usesnake_case. omitemptymakes it optional. Without it, the argument is required.- The
jsonschematag is the argument’s description, which the model reads. Every argument needs one. - Use pointers for optional values where zero means something.
- Embed
HolderArgs(holder and account) for tools that work on a holder’s accounts, orHolderOnlyfor tools that don’t need an account. - Period arguments are strings parsed by
analysis.ParsePeriod, which understandslast-month,2026-03,tax-year, ranges and more.
The Def
Section titled “The Def”| Field | Effect |
|---|---|
Toolset |
Required. The tool is only registered when this toolset is enabled. |
Name, Title, Description |
The tool’s name (starling_<verb>_<thing>), a short human title, and the description the model reads. |
Gate |
Always Read. starling-mcp is read-only, and the gate is kept so a test can check every tool is. |
Idempotent |
Repeating the call has no further effect. Sets idempotentHint. |
Enums |
Restricts string arguments to fixed values, keyed by argument name. |
Audit |
Returns whether a call goes in the audit log. Only the raw tool uses it. |
Checklist for a new tool
Section titled “Checklist for a new tool”- Put it in the right
internal/tools/<toolset>.go. If it needs a new toolset, add it toToolsetsininternal/config/config.go, describe it intoolsetInfoincmd/gen-tool-docs/main.go, and register it inNewServer(). - It must only read. Add an endpoint to
internal/starling/endpoints.gousing the client’sGet. Nothing that sends another method will be accepted. - Return a compact summary, with money as a decimal string and currency. Never return the token. Mask identifiers unless
STARLING_SHOW_IDENTIFIERSis on. - Write descriptions for the model: what the tool does, when to use it, units, what it assumes and Starling’s own limits.
- Add tests in
internal/tools/<toolset>_test.gousing the mock and synthetic data. - Run
make docsand commit the updateddocs/tools.mdandmcpb/manifest.json. Add a line to CHANGELOG.
Tool design guidelines
Section titled “Tool design guidelines”- The server does the sums. Never return hundreds of raw rows and leave the model to add them up. Return totals, groups and evidence.
- Say what was left out. Every insight reports what it excluded (internal moves, owner pay, pending items) and how much.
- Never add across currencies. Group by currency.
- Be honest about assumptions. Say what a forecast leaves out, and give a confidence and the evidence for a detection.
- Use UK time. Customers think in local days. Send the API UTC times.
- Errors should teach. Return messages that tell the model, or the user, how to fix the call.
- Respect Starling’s limits. Keep requests few, cache, and don’t poll.
Testing
Section titled “Testing”Tests use Go’s testing package. No test needs a Starling account, a token or network access, and no real account data is ever used: not in tests, not in fixtures, not to tune the detectors.
internal/starling/starlingtestis anhttptestserver that imitates the parts of the Starling API the server reads, serving aFixturein the API’s real JSON shapes. It records the requests it receives, so tests can check that onlyGETs are sent.internal/synthgenerates fictional histories (the person isJ SMITH, the companySMITH CONSULTING LTD) for personal and business profiles: salaries and owner pay on irregular days, subscriptions with price rises, annual renewals, cancelled and new subscriptions, refunds, pending items that settle later, foreign currency payments with fees, duplicate charges, round-ups, Space moves, bank-holiday shifts and transfers to other accounts. It also returns an answer key (Truth) of everything it planted, so the detectors can be scored against it.internal/analysis,internal/ledgerhave hand-checked tests of edge cases: a monthly payment on the 31st, annual renewals, weekly payments, amount drift, missed months.internal/starling/hardening_test.gochecks the safety properties: no redirects, the response cap, the token never appearing in output or errors, and onlyGET.internal/toolstests run each tool over an in-memory MCP session against the mock.
Run one package or test with go test ./internal/analysis -run TestRecurring -v. CI runs the tests with -race, make lint, govulncheck and the generated-docs check.
Running against a real account
Section titled “Running against a real account”Use a read-only token. With the MCP Inspector:
make buildexport STARLING_ACCESS_TOKEN=<your-token>npx @modelcontextprotocol/inspector ./bin/starling-mcpStarling’s sandbox (STARLING_API_URL=https://api-sandbox.starlingbank.com) serves simulated transactions and is a good way to see real API behaviour without real data.
Or build the image and point Claude Code at it:
make imagedocker run --rm -p 8080:8080 --env-file .env starling-mcp:0.0.0-devclaude mcp add --transport http starling-dev http://localhost:8080/mcp --header "Authorization: Bearer $MCP_AUTH_TOKEN".env is in .gitignore. Keep it that way, and never paste a real token, account number, sort code, name or real transaction into issues, tests or fixtures.
The sandbox smoke test
Section titled “The sandbox smoke test”internal/starling/sandbox_test.go calls every typed endpoint on Starling’s sandbox and runs the analysis functions over what comes back. It also checks assumptions the code makes about the real API (a space’s UID works as a feed categoryUid, whether a feed export’s end day is inclusive, which fields standing orders, scheduled payments, mandates and feed items carry) and logs what it finds. It is behind the sandbox build tag, so go test ./... never runs it.
- At developer.starlingbank.com, create a sandbox customer and a sandbox personal access token with read scopes.
- Run it:
STARLING_SANDBOX_TOKEN=... go test -tags sandbox -v ./internal/starling/Without the token the test skips with a message. Only a failure of the calls everything else needs (the token’s identity, the accounts and their balances) stops the test. Any other endpoint that errors, and any wrong assumption, is reported as a failure with the endpoint path, and the test carries on, so one run lists every finding. Lines starting FINDING record what it learnt about the API, such as whether a feed export’s end day is inclusive. The payee endpoints are called once for each of a payee’s accounts, with the payee’s account UID (payeeAccountUid), as the real API requires. Errors and CSV snippets are passed through the client’s redaction before they are logged.
Never commit the token, and don’t paste it into issues or logs. It is a credential even though the sandbox holds fake data.
Docs that are generated
Section titled “Docs that are generated”docs/tools.md is generated by cmd/gen-tool-docs. The program builds the server with every tool enabled, records each tool’s toolset and gate as it’s registered, reads the tools and prompts back over MCP, and writes the reference. Don’t edit docs/tools.md by hand. Change the tool’s title, description or jsonschema tags and run make docs. CI runs make docs-check and fails if the committed file is stale.
make docs also regenerates the tools and prompts lists in mcpb/manifest.json, the Claude Desktop bundle’s manifest, with cmd/mcpb. It starts the server the way the manifest’s default settings do (every toolset except raw), so the list matches what a fresh install shows. The rest of the manifest is edited by hand. If you add a setting there, map it to its variable in server.mcp_config.env and give it a default ("" for optional text), because Claude Desktop passes an unfilled setting without a default through as the literal ${user_config.<key>}. The config package treats that, and an empty value, as unset.
The website
Section titled “The website”The site at starling-mcp.mattoddie.dev lives in website/. It has a hand-built landing page plus these docs rendered with Astro Starlight. It has its own package.json, so its dependencies never reach the server or the Docker image.
The Markdown in docs/ is the single source: the site copies it in at build time. It turns each page’s first # Heading into the page title, drops hand-written “Contents” lists, rewrites links between .md files to site URLs and converts GitHub alerts (> [!NOTE]) to Starlight asides. So write docs as normal GitHub Markdown, start each page with a # Title, and link between pages with relative .md links.
To preview the site locally:
cd websitenpm cinpm run dev