Skip to content

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.

Terminal window
git clone https://github.com/mattoddie/starling-mcp.git
cd starling-mcp
make 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.

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 bundles
mcpb/ # the MCP Bundle manifest and icon for Claude Desktop
internal/
├── 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, raw

The 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.

  1. An MCP client calls a tool, for example starling_spending_summary {period: "last-month", group_by: "category"}.
  2. 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.
  3. 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.Cache serves what it has and fetches only the missing days.
  4. ledger classifies every transaction (spending, income, internal, owner pay, refund or ignored) using the holder’s own accounts, the other holders, STARLING_OWN_ACCOUNTS and STARLING_COMPANY_ACCOUNTS.
  5. analysis totals, groups or detects over the classified ledger, and records what it left out.
  6. The handler returns a compact summary. add() serialises it to indented JSON text. A returned error becomes isError: true with 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.

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 is the tool’s argument schema:

  • The json tag names the argument. Use snake_case.
  • omitempty makes it optional. Without it, the argument is required.
  • The jsonschema tag 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, or HolderOnly for tools that don’t need an account.
  • Period arguments are strings parsed by analysis.ParsePeriod, which understands last-month, 2026-03, tax-year, ranges and more.
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.
  1. Put it in the right internal/tools/<toolset>.go. If it needs a new toolset, add it to Toolsets in internal/config/config.go, describe it in toolsetInfo in cmd/gen-tool-docs/main.go, and register it in NewServer().
  2. It must only read. Add an endpoint to internal/starling/endpoints.go using the client’s Get. Nothing that sends another method will be accepted.
  3. Return a compact summary, with money as a decimal string and currency. Never return the token. Mask identifiers unless STARLING_SHOW_IDENTIFIERS is on.
  4. Write descriptions for the model: what the tool does, when to use it, units, what it assumes and Starling’s own limits.
  5. Add tests in internal/tools/<toolset>_test.go using the mock and synthetic data.
  6. Run make docs and commit the updated docs/tools.md and mcpb/manifest.json. Add a line to CHANGELOG.
  • 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.

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/starlingtest is an httptest server that imitates the parts of the Starling API the server reads, serving a Fixture in the API’s real JSON shapes. It records the requests it receives, so tests can check that only GETs are sent.
  • internal/synth generates fictional histories (the person is J SMITH, the company SMITH 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/ledger have hand-checked tests of edge cases: a monthly payment on the 31st, annual renewals, weekly payments, amount drift, missed months.
  • internal/starling/hardening_test.go checks the safety properties: no redirects, the response cap, the token never appearing in output or errors, and only GET.
  • internal/tools tests 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.

Use a read-only token. With the MCP Inspector:

Terminal window
make build
export STARLING_ACCESS_TOKEN=<your-token>
npx @modelcontextprotocol/inspector ./bin/starling-mcp

Starling’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:

Terminal window
make image
docker run --rm -p 8080:8080 --env-file .env starling-mcp:0.0.0-dev
claude 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.

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.

  1. At developer.starlingbank.com, create a sandbox customer and a sandbox personal access token with read scopes.
  2. Run it:
Terminal window
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/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 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:

Terminal window
cd website
npm ci
npm run dev