Skip to main content

External account linking for messaging users

Status: available as a broker contract and explicit DM commands. A provider must implement this contract before users can link accounts. Linking alone does not authorize tool queries; a provider opts into linked-user queries separately. Formation owns verified messaging identity and delivery. The application owns login, consent, account/workspace selection, link custody and revocation. An application-specific workspace is opaque to Formation. This contract can be implemented by any operator; no particular application is built into the runtime.

Configure an agent’s MCP connection

The operator API accepts session or operator-token authentication and enforces access to the owning agent, like the existing MCP routes:
  • GET /api/agents/{slug}/mcp/providers/{provider}/account-linking
  • PUT /api/agents/{slug}/mcp/providers/{provider}/account-linking
  • DELETE /api/agents/{slug}/mcp/providers/{provider}/account-linking
PUT body:
version is the current MCP connection version from the provider list. A mutation increments that version; reload the list before another mutation. A stale version returns 409. DELETE accepts { "version": 8 }. GET and mutation responses contain account_linking: { endpoint, credential_present }, or null when absent, never the token. Omitting the token preserves it only at the same endpoint. Changing endpoint requires an explicitly supplied token. Configuration is API-only in this iteration; the settings UI does not yet expose a broker editor. Tokens are 32–256 non-space printable ASCII characters, authenticate one agent, and are encrypted in the existing agent-owned secrets store, including master-key rotation support. Never reuse a token to identify multiple agents. The application must bind its token to permitted agent and MCP connection identities. Removing the MCP connection removes the local broker configuration and its credential; the provider remains responsible for expiring/revoking external links and sessions.

DM interaction

  • /connections lists this agent’s enabled connections with account linking.
  • /connect opens sign-in or shows the active connection. Disconnect it before linking a different workspace.
  • /connection checks the current link.
  • /disconnect asks for confirmation before revoking access. The confirmation names the provider so a change to the configured connections cannot redirect it.
Commands use this agent’s sole enabled account-link provider automatically. When several are available, choose a provider from the reply. Explicit provider UUIDs remain supported. Personal Teams chats render connection details and actions in Adaptive Cards. Update the installed Teams app package to expose the commands in its bot menu. Commands run before inference and continuation handling, using persisted human message text. They use normal journaled replies/outbox delivery. Scheduled, follow-up and other anchored runs do not execute commands retained in an old human message. The broker is contacted only for an admitted live single-trigger DM with one verified reader, matching persisted sender and adapter-supplied account-subject evidence. Group/channel surfaces, unknown identities, foreign agent connections and ambiguous triggers are refused. The first adapter supplying account-subject evidence is Microsoft Teams. It records the verified tenant, sender ID and optional Entra object ID from the activity. See Microsoft’s activity fields. The generic contract does not switch on provider names. Other adapters can supply equivalent verified evidence later; they are not enabled by this change.

Broker protocol v1

Formation POSTs JSON to the exact configured public HTTPS endpoint, with Authorization: Bearer <agent broker token>. It refuses redirects, private IPs, ambient proxy credentials and non-HTTPS destinations. Requests time out after 20 seconds; JSON responses are bounded to 16 KiB. Upstream errors/bodies are not shown to users or models.
Actions: start, status, disconnect. No message body, display name, email, service URL, application user credential or model-selected identity is sent. The request ID hashes the versioned action and complete source/connection context and stays stable on recovery. Brokers must enforce idempotency across replicas and retries: a repeated start cannot create another independent session; a replayed disconnect cannot revoke a subsequent link. Retain mutation idempotency records for at least as long as the deployment can retry/recover a run. If a recovered start’s session has expired, return expired rather than silently mint another one. A fresh human command has a fresh message ID and can start a new operation. Authenticate the caller before trusting any fields. Match agent_id and provider_id against the credential’s configured authority. Key external links by agent, provider, connector installation/namespace/type, tenant and sender. Directory ID is additional evidence, not an implicit replacement for the sender key. Do not link by email or display name. Conversation/message context binds the linking session to its origin; it is not itself proof of application access. A start response may return:
Use a public HTTPS login URL without userinfo/fragment. It may be on a different origin from the broker because browser login may use a separate identity service. Formation never fetches this URL or sends its broker credential there. Expiry must be in the future and at most ten minutes away. The challenge must be unguessable, short-lived, single-use and bound server-side to the authenticated request context. Opening it is not authorization: authenticate the application user, show the intended integration, verify workspace access and obtain consent before completing the link. Do not put access/refresh tokens in the URL. Once the user finishes in the browser, they return to the DM and run /connection. There is no public Formation completion callback or background polling in v1. The broker reports authoritative current status:
status also accepts pending, disconnected or expired. start may return connected, disconnected or expired without a URL. A broker should return connected on start if an active link already exists. The optional display fields describe only the existing link for the verified identity. Provide a public HTTPS image without redirects for the logo. The runtime does not fetch it. disconnect succeeds only with { "state": "disconnected" }, after actual revocation. Other action/state combinations and unexpected login URLs produce a fixed invalid-response notice. Only the optional display fields are rendered alongside runtime-owned copy. Connection notices never claim the link grants data-query access.

Boundary with OAuth, memory and tool execution

Existing MCP OAuth connects an agent-owned acting account. This broker flow links a messaging user to additional application permission restrictions. It neither overwrites the MCP credential with a human token nor merges Formation actors/private-memory identities. No application identity mapping enters prompts. Login URLs are ordinary retained outbound DM content, not tool authority; never interpret historical notices or copied URLs as current connection status. Read delegated MCP contract separately. The existing generic-connector execution checks remain unchanged. The optional execution extension binds each tool execution to verified sender, application user, selected scope, conversation and command/run, enforces live membership/revocation, and retains restricted evidence. Account linking alone must never fall back to agent-wide human data authority. Shared-conversation disclosure policy requires its own design and acceptance.

Delegated tool execution is a separate capability

Providers can opt into the linked messaging execution extension described in delegated MCP queries. Account linking alone does not authorize data queries: the provider must implement identity proof, credential custody and live user/workspace permission checks. Tools without the extension continue to refuse messaging execution promptly as an unsupported context.

Broker admission lanes

Formation sends X-Formation-Account-Link-Action with the same action as the JSON body (start, status, disconnect or version-2 authorize-query). Brokers can use this authenticated request hint to budget work before reading a bounded body, reserving a separate lane for disconnect. Validate that the header matches the parsed action; the header is not an authorization grant. Existing brokers may ignore it. A broker accepting older runtimes without the header should document its legacy admission budget and cannot promise query-independent revocation capacity on that shared lane.