feat(mcp): give each account its own Forgejo instance #73
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/FJ-55-per-account-forgejo-instances"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Over the HTTP transport, every tool call now acts as the authenticated account's own Forgejo instance instead of one process-wide identity, and the single-identity credential path is deleted from the serve path.
A new consumer-owned
forgejo_instancestable (chained onto mcp-web's generic migrations at version 1000) keys one host plus one encrypted personal access token per account, one-to-one onaccounts(id)withON DELETE CASCADE. The account-to-client seam (client_for_account/ForgejoInstances) that FJ-54 stubbed is implemented for real: it looks up the calling account's row, decrypts the token, and builds aForgejoclient from that host and token.ForgejoServergains aClientSourcesplit soapi()/api_and_token()resolve per request over HTTP (from the injectedPrincipal) while stdio keeps its single identity; the ~150 tool methods thread the request context unchanged.A new
/instanceUI lets an account set, test, and disconnect its instance. Saving or testing probes the Forgejo user endpoint, reports the resolved login, and recordsverified_at; failures distinguish a rejected token, an unreachable host, and a non-Forgejo URL without leaking the upstream body. The token is write-only and never rendered back. Every handler is scoped to the signed-in account, so no account can read or modify another's instance, and deleting an account cascades to its instance row.On HTTP nothing degrades to unauthenticated or to a host-level identity:
FORGEJO_TOKEN, thekeys.jsonfallback,Auth::None,DEFAULT_HOST, and$FORGEJO_HOSTare no longer read on the serve path, and the inertFORGEJO_MCP_HTTP_TOKENstatic bearer is removed fromfj mcp service install(the unit bakes in no host and no token). An account with no instance gets an error naming where to add one.fj mcp stdiostill resolvesFORGEJO_TOKEN,keys.json, and$FORGEJO_HOSTexactly as before.#FJ-55