Repository navigation
feat(platform): connect coding agents to an organization - #4899
Merged
Merged
Conversation
A coding agent connected by signing in on the MCP endpoint gets one record for each person, organization and app, which the MCP door will read on every call, so ending a connection ends its access at once. - app.agent_connections (0203): the app, its verified or unverified origin, the access allowed, last use, and when and why it ended; one live row per person, organization and app, enforced by a partial unique index and a lock, so allowing again changes the access instead of adding a second. - The organization's list (a person's own; an owner or admin may ask for everyone's and the ended ones) and the disconnect, which a person or an admin may do and anyone else is told does not exist. - Ending a connection deletes the consent and every refresh token the sign-in server holds for this person's grant to this organization, and none of another's. They are deleted, never stamped revoked: the provider reads a refused token still on file as one used twice and ends the person's tokens for the app in every organization. - A removed member's agents end with the seat; an organization's teardown removes its connections and the grants the sign-in server holds for it. - One audit row for connecting, for a change of access and for each disconnect, with who ended it and why, labelled in English, German and French; a hint to the organization for each.
…hooses The consent step of the sign-in server now makes an agent's grant for one organization, chosen by the person, and records the connection before the agent's code is handed over. - The consent endpoint is reached through a gate for agent access. The person names an organization they are an active member of and may connect an agent to (the rule of holding a personal API key, read for that organization alone), with a verified address and no two-factor enrollment due; reading and testing are always allowed, nothing beyond what the role there allows, and anything beyond reading and reading settings needs a session from the last day. Each refusal has its own code and stores no consent. - The organization rides the consent as the provider's reference, carried by an async context while the provider makes the consent, so two consents at once stay apart. A request around the gate is tied to a reference no consent ever has, is sent back to the consent page and gets no code. - An access token for the MCP endpoint names the organization the person chose, at the code exchange and at every refresh. A refresh by a person who left the organization is an invalid grant, which an agent reads as "sign in again"; a code exchange keeps the refusal it had. - The connection is recorded before the code is handed over; if it cannot be, the agent gets none. - Tale's single sign-on clients are untouched: they ask for no agent scope and have no reference.
This was referenced Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A person can now connect a coding agent to the organization they choose, and the organization keeps a record of it: who connected which app, with which access, when it was last called, and when and why it ended. This is the grants half of agent sign-in; the MCP door that honours the tokens comes next, and sign-in stays off by default until then, so nothing changes for a deployment today.
app.agent_connections(migration 0203): one live connection per person, organization and app (a partial unique index plus an advisory lock, so eight consents at once leave one); ended ones stay as history. "Last used" is not stored: it is read from the MCP endpoint's own call counters (app.mcp_client_activity, kindoauth).GET /api/app/agent-connections(a person's own; an owner or admin can ask for everyone's and the ended ones) andDELETE /api/app/agent-connections/:id. A connection that is someone else's, another organization's or already ended is not found, never forbidden.agent_connection.created/.updated/.revokedaudit row each, naming the person (or the platform) and the access before and after, and a hint to the organization.invalid_grant, not a 403.Rules are in
backend/domains/agent_connections/spec.md(AGCONN-R1–R10); the manual reference rows and error codes are added.Checklist
bun run checkpasses — gate run locally on the committed tree: tsc, oxlint, server + pii (88,666), UI (7,685), docs (713), format, links, manual, knip. One timing-bound test in a file this change does not touch (lib/engine/core/record/travels.test.ts, "two million reads", < 250 ms) failed under the full-suite load and passed three times alone.bun run lint:sast— runs in the commit hook, clean.settings.ymlen/de/fr: the disconnect confirmation and notice strings).Test plan
checkAgentConnectionsandcheckAgentConsent(91/91 with the rest of the shared checks): the consent drives the real endpoint, the code earns a token that names the organization, a refresh keeps naming it; each refusal (no right, a stranger, no organization, access beyond the role, no reading, a stale session asking for more) has its code and stores nothing; disconnecting and removing a seat end the agent at once; another organization's grant survives; the unique index holds under eight concurrent consents; a teardown removes the provider's rows.