0013 · Integrations: other software may read the fund and send it ideas, and nothing more
Status: accepted, 2026-09-25. Built for issue #4. The server side is src/integrations/ and src/mcp/, plus the
extra channels in src/notify/channels.ts. Tests: test/integrations.test.ts, test/integrations-openapi.test.ts,
test/mcp.test.ts. The page is web/views/connections.js with web/connections.css. Reference:
docs/integrations.md.
Context
Until now the fund had one credential, the owner token, and one client, the dashboard. The owner wants the book in a spreadsheet, alerts in Slack or on a phone, a calendar of rituals and cooling-off ends, a Grafana panel, Portfolio Performance and Ghostfolio kept in step, automations in n8n or Home Assistant, and an assistant (Claude Desktop, Claude Code) that can read the book and pass along an idea.
Every one of those is a new way in. The fund's discipline depends on one person signing every order after the checks and the cooling-off. So the question was not which integrations to build but what each one is allowed to reach.
Decision
- Scoped tokens, separate from the owner token. Eight scopes, seven read-only and one write,
ideas:write. A scoped token reaches only/api/v1/*,/api/openapi.json,/metricsand/mcp; on every dashboard route it is refused with 401. The owner token, the host check and the CSP are unchanged. Tokens are shown once and kept as a SHA-256 hash plus the last four characters and the last-use time (written at most once a minute). Rotation issues a new token with a new id and revokes the old one in the same step. - One route table.
src/integrations/routes.tsdeclares each route's method, path, scope, parameters, media type and handler. The server dispatches from it,openapi.tsgenerates the OpenAPI 3.1 description from it, and the MCP tools are thin names over its entries. A test asserts all three agree and that the committeddocs/openapi/openapi.jsonmatches. A route cannot exist undocumented. - The only write is an idea.
POST /api/v1/ideascalls the samesubmitIdeapath as the dashboard, with producerowner: the same checks, seats and cooling-off. The text is data, kept verbatim as a thesis to test. A per-token daily limit (INTEGRATIONS_IDEAS_PER_DAY, default 10) is spent only after the body validates, and its refusal says why: more ideas is not more edge. No route or tool signs, sizes, places, cancels, changes the mandate or touches the kill switch. - MCP without an SDK. JSON-RPC 2.0 with
initialize,ping,tools/listandtools/call, about a hundred lines. Two transports: stdio (npm run mcp), a stateless bridge to the HTTP API holding a scoped token; and streamable HTTP atPOST /mcpwith JSON responses. The tool list is filtered by the caller's scopes, so an assistant withoutideas:writedoes not seesend_ideaat all. Cross-origin/mcprequests are refused. - Webhooks through the jobs runner. A Record subscriber enqueues one job per matching endpoint and event, keyed
webhook:<endpoint>:<event>so a delivery is never repeated. Retries use the runner's exponential backoff (five retries from 10 s, capped at 300 s). A delivery that uses them up becomesjob.deadwith stagewebhook, which Operations already shows and notifies. Signatures are Stripe-style:t=<unix>,v1=<HMAC-SHA256("t.body")>, with a five-minute tolerance. Payloads are opt-in per endpoint. - Deliveries and settings stay out of the Record. The delivery log, tokens, endpoints and the watchlist live in
their own tables. A failing receiver retrying all night must not fill the fund's history, and creating a token is a
setting, not a fund event. The one Record trace is
job.dead, because an alert that could not be delivered is an operational fact. - Webhook secrets are sealed, not hashed. The owner-facing rule is that secrets are hashed at rest and never sent
back. That works for API tokens, which the server only verifies. A webhook secret must be used to sign each
delivery, so a hash is useless. It is sealed with AES-256-GCM under
<data dir>/integrations.key(created 0600) and the browser sees only a fingerprint. Webhook URLs are masked in the browser, because Slack-style URLs are secrets. - Channels from the environment. Slack, Discord, Teams, Pushover, Signal and a generic signed webhook join ntfy, Telegram and email in the notifier's channel index when their variables are set. They are not configurable from the page, so a stolen browser session cannot redirect alerts. Failure messages are scrubbed of the channel's secrets before they are recorded.
- Feeds and exports carry the token in the URL where they must. Calendar apps, feed readers, Prometheus and
IMPORTDATAoften cannot set a header. Only routes markedurlKeyaccept?key=; the page says that a URL leaks more easily than a header and suggests a single-scope token. The Atom feed shows titles unless the token also holdsrecord:payloads. CSV cells that could run as formulas are neutralised. Every money figure in an export comes from the fund's server code; the page never computes one.
Consequences
- There is now a second kind of credential to leak. The blast radius of a leaked scoped token is reading, plus at most ten ideas a day that still meet every check and wait for a signature.
- MCP is a small hand-written subset. Server-initiated messages, resources, prompts and SSE streams are not offered. If a client needs them, this is the place to revisit.
?async=1idea tickets are held in memory and vanish on restart. The idea itself is in the Record either way.- Google Sheets and Zapier fetch from their own servers. They need the fund on a public host listed in the server's allowed hosts; the default local setup does not offer that, on purpose.
- The Operations page's channel table (not part of this change) still lists only ntfy, Telegram and email. The Connections page shows all nine.
Rejected
- The owner token for everything, or OAuth. One token for all tools makes any leak total. OAuth needs an authorisation server for a single user.
- Webhook events in the Record. They would double the Record's size on a bad night and make the history about plumbing.
- The official MCP SDK. A dependency tree for four methods, on a fund that vendors what it ships.
- Write tools beyond ideas (acknowledge a proposal, snooze a halt). Each is a step an assistant could be talked into by a page it read. The owner does these in the dashboard.