Skip to main content

Integrate a company

SDK status

The Python SDK ships a reference company, personal_agent_protocol.company: a framework-neutral PAP company over plain ASGI, assembled from Reactor contributions. It is the counterpart the SDK's own end-to-end tests and demo worlds run against, and a starting point for a real integration. The TypeScript SDK ships the same company in @datalayer/personal-agent-protocol/server.

Start with discovery​

Publish https://your-domain.example/.well-known/poppy.json. Advertise only interfaces that are deployed and authorized consistently.

{
"protocol_version": "0.4",
"organization": {
"name": "Example Company",
"domain": "example.com"
},
"auth": {
"issuer": "https://auth.example.com",
"scopes": {
"orders:read": "See your orders and returns",
"orders:write": "Return items in your orders"
},
"scope_hints": {
"orders:read": {"changes": "none", "personal_data": true},
"orders:write": {"changes": "reversible", "personal_data": true}
}
},
"tasks": {
"endpoint": "https://api.example.com/poppy/tasks"
},
"apis": [
{
"type": "openapi",
"url": "https://api.example.com/openapi.json",
"description": "Orders and returns"
}
]
}

The domain's protected resource metadata, at /.well-known/oauth-protected-resource, names the issuer: its resource is exactly https://{domain}, and authorization_servers lists the issuer. The issuer's OAuth metadata (RFC 8414) must list https://{domain} in protected_resources, alongside the other resources its tokens are for (an MCP server's URL, say), and grant_types_supported must include the refresh_token grant. Which sign-in modes the company offers comes from that metadata too: Direct Sign-In when it has an authorization_endpoint and the authorization code grant, and Device Sign-In when it has a device_authorization_endpoint and the device code grant. The mediated-sign-in extension in poppy.json, with its grant type in grant_types_supported, offers Mediated Sign-In. A company that offers sign-in should offer Direct Sign-In, the preferred type (§4): CompanyConfig does by default (direct=True), and one guarding high-value resources, which RFC 10027 §6.2.1.5 advises against the device grant for, sets device=False and offers Direct Sign-In only.

Scopes are the company's own: name them for what they allow (orders:read, payments:write). A company should describe each in auth.scopes (or in an OpenAPI description it lists), and list them in the metadata's scopes_supported; neither is required, and that list is discovery, not enforcement: agents can request scopes documented by an API or sign-in extension too. auth.scope_hints says, per scope, what its most consequential operation changes (none, reversible, irreversible) and whether it touches personal_data, so a personal agent can choose the narrowest scopes a task needs. Tasks the company chose not to offer through the protocol, the skills it publishes and its feedback endpoint are not in poppy.json: it names one tasks.endpoint, which answers each Session with them (§9), each excluded task with an optional alternative.

Keep endpoint authorization in application code or a gateway; never ask a model to enforce scopes. A request whose token lacks a scope gets insufficient_scope with the scope it needs, on APIs (WWW-Authenticate), in a conversation's authorization event, and on Operations. A signed-out request for account data gets a 401 challenge with the same scope.

Signed-out support without OAuth​

A company offers signed-out Sessions, APIs, conversations, feedback and browser join without running an authorization server (§3.2). Return 404 from the domain's protected resource metadata, or publish it with no authorization servers, and leave out auth.issuer, sign-in extensions and access: signed_in. Its identifier is then https://{organization.domain}, lowercase with no trailing slash: verify Session JWTs against it. Each such domain is a separate Company. When an issuer is added and the identifier changes, Users get new IDs and Sessions; the protocol doesn't link them. The reference companies do this with oauth=False (oauth: false): no OAuth server, no auth, a 404 at the protected resource metadata, and no Mediated Sign-In, Operations, aliases or DPoP, which each need an issuer.

Serving several versions​

A company can serve several protocol versions at once (§3.4), so personal agents move at their own pace. poppy.json is the document of the version the company prefers, and supported_versions maps each other version it serves to that version's document, an HTTPS URL on the same host. Every document has the same organization.domain and selects the same issuer, so a new version never changes the company's identifier, User IDs or refresh tokens.

CompanyConfig.protocol_versions (protocolVersions) lists the versions the reference company serves, the first the preferred one. Each other version's document is served at /poppy/{version}.json, with that protocol_version and no supported_versions. A request whose Poppy-Version is missing or names no served version is refused with version_unsupported (HTTP 400, JSON body) where the Session header is verified, and is never handled under another version. The reference company speaks 1.0 (DEFAULT_PROTOCOL_VERSION) by default; another entry lets a personal agent's choice be exercised and is answered the same way.

0.4 as published (PROTOCOL_PROFILE) is opt-in on this side too: a company that adds "0.4" to protocol_versions, such as ("1.0", "0.4"), keeps poppy.json at 1.0, lists /poppy/0.4.json in supported_versions, and serves a Session at either version; an agent that implements both chooses 1.0, one that implements 0.4 only keeps 0.4. ("0.4", "1.0") makes 0.4 the preferred document and keeps 1.0 for the others.

To retire a version, name it in deprecated_versions (deprecatedVersions) with when it was deprecated and when it goes away: responses to requests in that version then carry Deprecation (RFC 9745) and Sunset (RFC 8594). Remove it from protocol_versions afterwards; a personal agent with a cached document gets version_unsupported, reads poppy.json again and moves. A company that serves one version checks Poppy-Version where it verifies the Session header, and that is all. Conversations can outlast a version: the reference company records the protocol and extension versions each conversation started in, carries it over to other versions by default, and with conversation_carry_over=False (conversationCarryOver) refuses messages, handoffs and cancels on it from other versions with version_mismatch (409), naming the version it started in, while reads stay allowed (§8.2).

Implement in this order​

  1. Publish discovery and OAuth metadata with ordinary signed-out access.
  2. Verify personal-agent client metadata, public keys, delegations, Session JWTs, and replay IDs, and keep Sessions by client_id and sid.
  3. Add Direct Sign-In with client assertions, issuing short-lived access tokens and refresh tokens.
  4. Add central scope enforcement.
  5. Expose structured APIs or a company-agent conversation endpoint.
  6. Add Operations when actions require exact, durable approval.

Required operational controls​

  • One distributed replay cache for assertion and Session JWT identifiers: the default keeps them in the company store, so a store shared by every replica is enough.
  • Rate limits by personal-agent client, user, session, and account as relevant. The reference company limits Mediated Sign-In attempts (max_sign_in_failures failures per account identifier, agent's user, and Session, and wrong codes per account across sign-ins, then 429 rate_limited with Retry-After, the lockout doubling from sign_in_lockout); the account directory must also throttle its own checks, and is told which agent and Session each attempt comes from (SignInContext).
  • Cache-Control: no-store on responses carrying credentials or codes.
  • Immediate sign-out propagation, or very short token lifetimes when that is not possible.
  • Every sign-in ended when the account's password is reset, or the account is locked or recovered: a directory that also answers signed_out_before(account_id) (AccountSignOuts; TypeScript: signedOutBefore) is asked on each signed-in request, and a sign-in from before that moment is refused and revoked whole — its refresh tokens, and the Sessions that used them continuing signed out — while a sign-in after it works.
  • Identical authorization semantics across APIs, conversations, browser sessions, company-agent tools, and human-support tools.
  • Generic external errors that do not disclose whether another user's resource exists.

The reference company​

from personal_agent_protocol.company import CompanyConfig, build_company, company_app

config = CompanyConfig(
name="Manzanita Outfitters",
domain="manzanita.example",
scopes=("orders:read", "orders:write"),
# What the Company Agent can help with, in plain language (spec 3.1, 8.1).
agent_description="Anything about your orders, returns, and our outdoor gear",
write_scopes=("orders:write",),
mediated_fields=(("email", "Email", False), ("password", "Password", True)),
# Every scope described, in words a user and a model understand (`auth.scopes`).
scope_descriptions={
"orders:read": "See your orders, returns and exchanges",
"orders:write": "Exchange or return items in your orders",
},
# What each scope's most consequential operation changes, and whether it touches
# personal data (`auth.scope_hints`).
scope_hints={"orders:read": ("none", True), "orders:write": ("reversible", True)},
# Tasks not offered through the protocol, served per Session at /poppy/tasks.
excluded_tasks=({"task": "Change the size of an item after it has shipped"},),
)
service = build_company(config, http_client=http, plugins=[(manifest, my_company_plugin)])
app = company_app(service) # any ASGI server, or httpx.ASGITransport in tests

CompanyService.handle() takes a neutral request and returns a neutral response, so any web framework can serve it; company_app() serves it over plain ASGI and rebuilds each request URL on the company's published origin so Session JWT htu checks compare against what the personal agent signed. It implements, of version 0.4 and Operations version 3:

  • discovery (/.well-known/poppy.json) and OAuth metadata on one issuer, with protected_resources, grant_types_supported, scopes_supported, auth.scopes and auth.scope_hints;
  • Sessions kept by client_id and sid: the Session header on every request, verified in the specification's order (delegation, delegated key, claims, access token). An unknown sid starts a signed-out Session, a known one must keep its User ID and Agent ID, and an ended one is remembered (ended_session_memory) and answered session_ended (HTTP 400). Any failed check is invalid_session (HTTP 400), and so is a JWT signed directly by a jwks_uri key, with no delegation. An access token without the Session header is refused;
  • Direct Sign-In, with loopback redirect URIs matched whatever their port;
  • Device Sign-In with authorization_pending and slow_down (await approve_device() stands for the company's own approval page);
  • Mediated Sign-In with a one-time code, an attempt limit, and uniform failures;
  • Sign-in turned off with sign_in_disabled (signInDisabled): auth.disabled in poppy.json, the issuer kept as the identifier and its grants listed for its other clients, no Mediated Sign-In, and unauthorized_client from each grant's endpoint (spec 3.2). Until it has issued a refresh token (it holds no sign-in), it answers every refresh with invalid_grant and every revocation with success without verifying the client assertion: it has no tokens to protect. Sign-in, or one type of it, refused to a particular agent by the client policy's allows_sign_in(client_id, grant_type) (allowsSignIn), the same error from the grant's endpoint, the agent served signed out (spec 4.1). Fewer scopes than asked with agent_scopes (agentScopes), the token response's scope saying which; only missing or unknown scopes are invalid_scope (spec 4.7);
  • logo_uri (logoUri) published as organization.logo_uri, and skills (skills), each a name, a description and the text of its SKILL.md, served at /poppy/skills/{name}/SKILL.md and listed in the tasks response's skill_index at the pinned Agent Skills revision with its SHA-256 digest (spec 9, 9.4);
  • with conversation_resource (conversationResource), the conversation endpoint as a service of its own, as a company whose company agent runs at another provider has (spec 4.5, guides A conversation endpoint at another provider): it publishes RFC 9728 metadata at /.well-known/oauth-protected-resource/poppy/conversations naming the endpoint URL, path included, as resource with the company's issuer; the issuer lists it in protected_resources and issues tokens for it (RFC 8707 resource); the endpoint takes only those, answering the default token with invalid_token and resource_metadata, and a signed-out request with the Session header alone. Session JWT audiences and User IDs stay the company's;
  • with resource_servers (resourceServers), the company's services at URLs of their own, such as an MCP server on another host than the issuer's (https://mcp.example.com/mcp): see A service at a URL of its own;
  • Bearer access tokens, or tokens bound with DPoP (dpop_binding, in TypeScript dpopBinding: off by default, optional binds when a proof comes, required refuses a token request with none; dpop_nonces, dpopNonces, asks for server nonces), at every API, conversation, feedback, MCP and browser /authorize request; a bad proof is invalid_dpop_proof, HTTP 400 at the token endpoint and 401 at a resource. At MCP, Bearer stays the baseline, so ordinary MCP clients stay supported: with binding on, the server's own metadata lists ES256, its challenges name Bearer then DPoP, and required still gives a Bearer token, without a proof, to a request whose resource is the MCP server's URL, which works at that server alone;
  • refresh tokens, never bound, rotated on every refresh, narrower scopes only, invalid_grant for expired, revoked, or rotated-away tokens, and revocation that ends the whole sign-in: its refresh and access tokens stop working;
  • tokens for one service: a refresh with resource set to the MCP server's URL gives an access token for that server alone, a resource the company doesn't serve is invalid_target, and a token not issued for the server is invalid_token with resource_metadata;
  • Operations version 3: every approval's approver (user, or agent for one the personal agent gave on the user's instruction), with any approved_at, input_type and reference, is kept with the operation's record (StoredOperation.approval); an approval without approver approves nothing; CompanyConfig.decline (decline) lets the company decline an approval that passed its checks, for its own reasons: return a Decline with a short reason for the user and, when there is one, an alternative, and nothing is performed, recorded or proposed anew (approval_declined: HTTP 403 with a JSON body at an API, an error result at a tool, a later message in a conversation). Operations on the website, with website_operations (websiteOperations) and web: contribute pap.company.website (CompanyWebsite.handle(WebCall) -> WebResult); a form whose action needs approval returns WebResult(operation=...), and a joined browser whose join declared Operations 3 gets 403 with Poppy-Operation (a page, or {"error": "approval_required"} for a script asking for JSON), the operations endpoint (POST /poppy/operations, listed in the operations entry) gives the agent the operation and records its approval (204, nothing performed), and the browser's next request for that revision performs it once; a website's operation is approved only there, and no other interface's is; with browser_control (browserControl) the company lists the Browser Control extension and marks the steps it leaves to the User with data-poppy-user-step, never relying on the controller value a page sends as proof;
  • sign-in pages that say who asks: the built-in consent page starts with "agent wants to connect to your company account" and tells the person to continue only if they just asked that agent; a hosted consent or device page gets the same words from authorization_request() and device_request() (heading, caution) (spec 10.8). Let people sign in there with a passkey or another phishing-resistant method, as on your website: Direct and Device Sign-In happen on your own pages, so passkeys work, which they cannot with Mediated Sign-In;
  • a Session found by client_id, sid and User ID (spec 5.3): end_session(client_id, sid, pairwise_user_id); and page_session(request) for the company's own website pages, which verifies the Session header a personal agent sends when it fetches a page without a browser and reads the request as signed out (spec 5.2);
  • task coverage per Session: GET /poppy/tasks (tasks.endpoint in poppy.json) answers a request with the Session header with the excluded tasks, the skill index and the feedback endpoint, marked private; feedback, answering a report about a task that can be done after all with its alternative (feedback_answers); personal agents send feedback to the tasks response's feedback.endpoint only, so an API that keeps a feedback operation for clients that don't read poppy.json says in its description that personal agents use feedback.endpoint, ideally feeding the same place;
  • conversations with idempotent messages, cursor events, waited replies, SSE, handoff, Direct Conversations, authorization events, and closing; a conversation that is not yours is conversation_not_found;
  • a company agent's reply with user_requested (userRequested in TypeScript) adds the invitation to the parent; when the user accepts it, the company agent is asked an opening turn (Turn.opening, with no text) for the company's first message, and the same acceptance returns the same Direct Conversation again, even once it closed; each parent problem has its own error (conversation_not_found, conversation_closed, invalid_request, direct_conversation_open), and direct_conversation_inactivity (directConversationInactivitySeconds) closes an open Direct Conversation left alone that long, when it is next asked about;
  • with humans_available (humansAvailable in TypeScript), a handoff gives the conversation to the company's people, and one of them answers in it with await staff_reply(conversation_id, after=..., text=...) (staffReply(conversationId, { after, text })): after is the last event they read (conversation_record() reads it), so an answer written over a message they have not seen is refused (StaleConversationError) and they read again; their message is role: company with author {type: human}, plus id, name, and image when author_id, author_name, and author_image are given, and a closed conversation, one not handed to people, or one with a Direct Conversation open takes none;
  • Operations returned by an API, an MCP tool or the company agent, approved through Poppy-Approval, _meta or a message's extensions.operations.approval, checked in the extension's order and performed at most once, a new revision answering a failed check, and revise() for new terms;
  • with web (web=True, web: true in TypeScript), the website (§6), and with it the protocol's one scope, poppy:browser-sign-in, offered beside the company's own (offered_scopes, offeredScopes), described by describe(), listed in scopes_supported and auth.scopes, and required of a signed-in join (insufficient_scope otherwise); web_unscoped (webUnscoped) says the website gives the account's full access to that scope, describing it so and hinting it as irreversible, and web_disabled (webDisabled), with web off, publishes web.disabled to ask personal agents not to browse at all. The guides' four levels of website access, none to signed in with the company's scopes, are these settings. A GET of the browser-session endpoint answers a form with a one-time code (at least 128 random bits, at most 60 seconds), tied to that browser by a __Host-poppy_join cookie (SameSite=Strict, HttpOnly, Secure), never cached, framed, or kept by its opener. The agent authorizes the code at {endpoint}/authorize with the Session header and, signed in, the access token (204). The browser then posts the code; the company checks cookie and code (used once, whatever the result) and that the agent authorized it, then answers 303 with its __Host-poppy_session cookie. web_session(cookie) tells the company's own pages which Session a browser stands for. Each join replaces the cookie, which stops working, so a join without an access token ends the sign-in of the one before. The reference companies have no website login beyond this cookie. A company with its own login cookie keeps it separate and checks the Session's cookie first: a signed-out join leaves that login alone, a signed-in join clears it, and an earlier login doesn't come back (§6 has a table of each case).

A Session header is verified on every request that carries it. The draft requires that only before relying on Session claims, so a stateless endpoint may skip it; the reference companies don't.

  • Operator signatures (spec 5.3, RFC 9421, Web Bot Auth), the company's choice, with operator_signatures (in TypeScript operatorSignatures). Each request's Session JWT is verified first, and a signature is checked after it:

    off (default)optionalrequired
    None, or another tagservedserved403
    Verifiedservedservedserved
    Unverified: the directory can't be read, doesn't list the key, or it isn't Ed25519servedserved403
    Invalid: it doesn't verify, is out of date, or doesn't cover poppy-session, authorization when present, the authority and its Signature-Agent memberserved403403

    A refusal is 403 with {"error": "operator_signature_refused"} and Accept-Signature, and never invalid_session: its absence doesn't make a Session JWT invalid, so the agent has no Session to start again. The spec names no code for it; this one is the SDKs'. A verified signature authenticates its key source, not the client_id. A real deployment usually verifies at its edge instead: see the guides.

Reactor points​

Every part a company replaces is a Reactor contribution. The company's own plugins contribute with a lower order to replace a default.

PointContractDefault
pap.company.storeCompanyStore: versioned JSON records by kind and key (below)MemoryCompanyStore (one process)
pap.company.accountsAccountDirectory: authenticate(credentials, context) and check_code for Mediated Sign-In; context (SignInContext) names the agent and Session, and the directory must throttle its own checks too; optionally AccountSignOuts.signed_out_before(account_id), since when the account's earlier sign-ins are over (a password reset)None: the company contributes it
pap.company.agentCompanyAgent.respond(turn): replies, authorization requests, operations to approveNone: the company contributes it
pap.company.operationExecutorOperationExecutor.perform(operation, account_id), one per action; operation_id is the idempotency keyNone: an unperformable operation stays performing
pap.company.clientPolicyClientPolicy.allows(client_id)AllowEveryAgent
pap.company.clientResolverVerified client metadata and JWKS for a client_idIdentityClientResolver over HTTPS
pap.company.operatorDirectoryOperatorDirectory.keys(url, keyid): the Ed25519 keys published at a Signature-Agent URLIdentityOperatorDirectory over HTTPS, with no redirect
pap.company.replayCachemark_once(key) for assertion and Session JWT IDsStoreReplayCache: an atomic create in pap.company.store, so a shared store is a shared cache

The PAP core points (pap.clock, pap.randomSource, and the rest) apply on the company side too.

The store​

Everything the company remembers — Sessions, access tokens, refresh tokens and the sign-ins they rotate from, pending device, Direct, and Mediated sign-ins, one-use codes, conversations and their events, message IDs, operations — is a JSON record in the pap.company.store contribution, by kind and key. The contract is seven async methods:

MethodDoes
get(kind, key)The record (value, version, expires_at), or None when absent or expired
put(kind, key, value, *, expires_at=None)Write it unconditionally: a new version
create(kind, key, value, *, expires_at=None)Write it only if absent (or expired): True when written
replace(kind, key, version, value, *, expires_at=None)Compare-and-set: write it only if its version is still version
take(kind, key)Read and delete at once: exactly one caller gets it
delete(kind, key)Remove it, if present
records(kind)Every live record of one kind (value, version, expires_at), in no particular order — values only, never keys, so a backend may keep keys as digests

In TypeScript the methods are the same, with { expiresAt } options and undefined for absent.

The service never changes a record in place: every change is an explicit write, so a database, a key-value service, or any store shared by several replicas sees all of it. Every transition that must not race goes through one of the atomic methods:

  • authorization codes, Direct Sign-In decisions, completed Mediated sign-ins, and approved device sign-ins are taken once (take);
  • message IDs are recorded with create, so a retried message is answered once however many replicas receive it;
  • an API write's Idempotency-Key is held with create before the API runs, so a repeated key is answered once with the original response (idempotency keys);
  • device approval and polling, refresh token rotation (the presented token is claimed by exactly one refresh; reusing it is invalid_grant), revocation of a whole sign-in, Mediated attempt counting, conversation events and status, and operation approval (one compare-and-set from open to performing, whose winner alone calls the executor) use replace.

A company restarted, replaced, or rolled back over the same store continues every flow: a pending device sign-in can be approved, a rotated-away refresh token stays refused, an operation returned before is performed once after, and an event cursor resumes where it was.

A version that no longer offers a scope — rolled back to one without it, or narrowed — does not honour what was granted for it: an access token holding that scope is refused as invalid_token, so the personal agent gets a new one within what is offered, and a refresh token refreshed for it is invalid_scope (the agent's client says re_consent_required), while a refresh asking only for scopes still offered succeeds with the same token.

Taking a company down, its owner first settles and ends what is under way, so no personal agent waits for an operation for ever or keeps a sign-in to a company that is gone: open_work() lists the operations that can still be approved or are being performed, and the agents and accounts with a sign-in not ended (read with records); settle_open_operations(reason) withdraws each one not yet approved, and settles each one being performed saying it was stopped before it finished and that whatever it changed until then stands, followed by the reason; and end_sign_ins() ends every sign-in as each agent's disconnect does. Operations already performed are left as they are. In TypeScript: openWork, settleOpenOperations, endSignIns.

Refresh tokens rotate on every refresh. With refresh_reuse_revokes (refreshReuseRevokes), a refresh token used again after it was rotated ends its whole sign-in, as RFC 9700 §4.14.2 describes: if a refresh token was copied, the grant ends as soon as both copies have been used. It is off by default, so an agent whose refresh response was lost and retries with the old token keeps its sign-in. When an agent's signing key may have leaked, revoke_client(client_id) (revokeClient) revokes every refresh token issued to it, whatever the account: its refresh tokens are tied to the client_id, not to a DPoP key.

approve_device, deny_device, approve_authorization, deny_authorization, authorization_request, revise, settle, forget_events, disconnect, revoke_client, operation_record, open_work, settle_open_operations and end_sign_ins read and write the store, so they are coroutines (promises in TypeScript).

A backend checks itself with the conformance kit, which runs the same checks in both languages: absent and present records, expiry, take once under concurrency, create only if absent, compare-and-set conflicts, values copied rather than shared, every live record of a kind read at once, and a round trip of every record kind.

from personal_agent_protocol.company.testing import check_store


async def test_my_store_conforms() -> None:
await check_store(lambda: MyDatabaseStore(url))
import { checkStore } from "@datalayer/personal-agent-protocol/server";

test("my store conforms", () => checkStore(() => new MyDatabaseStore(url)));

MemoryCompanyStore judges expiry by the company's own pap.clock (build_company binds it); a backend uses its own time source and passes it to the kit as now.

What stays in the company​

  • Credentials sent to the mediated endpoint go to the account directory as SecretStr and are cleared after the check.
  • Refresh tokens and device codes are stored as digests.
  • A company agent receives a Turn with the account, scopes, and whether the conversation is direct; it never sees tokens.
  • Errors are generic codes that do not disclose whether another user's conversation or operation exists.

Every page the company serves (the consent page) is sent with X-Frame-Options: DENY, Content-Security-Policy: frame-ancestors 'none', and Cache-Control: no-store.

The built-in consent page binds the sign-in request to the browser it is shown to: it sets a __Host-poppy_consent cookie (Secure, HttpOnly, SameSite=Strict; a browser that has one keeps it), stores its digest with the request, and puts a CSRF token derived from the cookie and the request in the form, which posts to /oauth/authorize. The company's web layer, which knows who is signed in, hands that POST to service.consent_decision(request) (consentDecision) and then calls approve_authorization or deny_authorization. It is refused (PermissionError; a rejected promise in TypeScript) when:

  • Sec-Fetch-Site is anything but same-origin, or Origin is another origin (or null);
  • the consent cookie is missing, or is not the one the request was bound to: a form replayed from another browser does not match;
  • the CSRF token is missing or was made for another cookie or request;
  • the request is unknown, expired, or already decided.

A hosted consent page (consent_page) gets no binding: it protects its own form, and consent_decision refuses every POST for its requests.

Every user of a personal agent shares its client_id, so the page lists every scope the sign-in would grant and is shown for every request, prompt=consent or not, and for every Device Sign-In, even when the account granted every scope before (§4.2, §4.3, §10.8). A hosted page reads the request with authorization_request(request_id, account_id=...) or device_request(user_code, account_id=...) ({ accountId }): given the account signed in on the page, each scope says granted_before, which the page may mark as already granted, never hide. The request's prompt is there too.

Pushed Authorization Requests and bound refresh tokens​

pushed_authorization_requests="offered" (pushedAuthorizationRequests) lists pushed_authorization_request_endpoint (/oauth/par) in the issuer's metadata, and "required" also sets require_pushed_authorization_requests: the authorization endpoint then takes only a request_uri the agent pushed with its client assertion (RFC 9126, §4.2). A push with a DPoP proof binds the code to its key. bind_refresh_tokens=True (bindRefreshTokens, with dpop_binding) binds each refresh token, and those rotated from it, to the DPoP key of the request that issued it: a copied refresh token is useless with another key (§4.4). Both are off by default. A client policy may leave a service out for an agent with allows_resource(client_id, resource) (allowsResource): its token requests are invalid_target (§4.5).

Describing the agent and the scopes​

agent_description (agentDescription) is required: what the Company Agent can help with, in plain language, published as agent.protocols[].description at 1.0 (§3.1, §8.1). It may say the agent can help with anything. Each scope's description (scope_descriptions) is most useful when it says what the scope unlocks, which tasks need it, and whether a task can be done without it, such as "See your orders, returns, and bookings. Needed to track an order or find one to change", or "Personalized search results. Not needed to search the catalog" (§4.7; upstream guides, Describing scopes).

test_guide_security.py and guide-security.test.mjs test each case.

Hosted sign-in pages​

By default the reference company serves its own Device Sign-In and consent pages. A company whose sign-in lives elsewhere sets two URL templates:

config = CompanyConfig(
name="Orders helper",
domain="orders.example",
scopes=("orders:read",),
agent_description="Your orders",
scope_descriptions={"orders:read": "See your orders"},
operations=False,
device_page="https://pap.orders.example/device?slug=orders-helper",
consent_page="https://datalayer.ai/pap/consent?slug=orders-helper&request={request_id}",
)
  • device_page (devicePage in TypeScript) becomes the device authorization response's verification_uri; verification_uri_complete adds &code=<user_code>.
  • consent_page (consentPage) must contain {request_id}. GET /oauth/authorize runs every check first — the agent's metadata, its registered redirect_uri, the response type, PKCE, and the scopes — and creates the pending request exactly as before; it then answers 303 to the consent page instead of HTML. A request with an unverified redirect_uri gets the company's own error page and is never redirected anywhere.
  • The consent page reads the request with service.authorization_request(request_id) (authorizationRequest): the agent's client_name, its client_id domain, each requested scope with its scope_descriptions words, and expires_at. Reading does not consume the request, and the summary carries no state, PKCE challenge, or redirect. The user's decision then goes to approve_authorization or deny_authorization as before.

Both templates must be HTTPS URLs without a fragment.

Other domains of the same company​

A company known by more than one domain — its own and a shorter one its owner bought, say — names the others as aliases (both languages):

config = CompanyConfig(
name="Orders helper",
domain="orders-helper.apps.datalayer.ai",
scopes=("orders:read",),
agent_description="Your orders",
scope_descriptions={"orders:read": "See your orders"},
operations=False,
aliases=("orders.example.com",),
)

Each alias publishes the company's discovery document, naming itself as the organization's domain (§3), and the issuer's OAuth metadata lists https://{alias} in protected_resources, so a personal agent that discovers the alias verifies the same issuer: one company, never a second identity. Every endpoint stays on domain; on an alias, which the request's Host names, anything but /.well-known/poppy.json answers 404 not_found. An alias is a DNS name in small letters, another than domain, named once.

A service at a URL of its own​

The reference company serves its MCP server at https://{domain}/mcp, on the issuer's own host. A company whose MCP server answers elsewhere, such as https://mcp.example.com/mcp beside an issuer at https://example.com, names it in resource_servers (resourceServers):

from personal_agent_protocol.company import resource_metadata_url

config = CompanyConfig(
name="Example",
domain="example.com",
scopes=("orders:read",),
agent_description="Your orders",
scope_descriptions={"orders:read": "See your orders"},
operations=False,
resource_servers=("https://mcp.example.com/mcp",),
)
print(resource_metadata_url(config.resource_servers[0]))

The URL is the server's url as poppy.json lists it in apis, since that is the resource a Personal Agent asks a token for (§7). For each one:

  • the issuer's metadata lists it in protected_resources, after https://{domain} (§3.2: it MAY list other resources, such as the Company's MCP servers);
  • the token endpoint issues a token for it when a request names it as resource, the request that completes a sign-in or a refresh (§4.5, RFC 8707). A sign-in that named no resource covers it, a service added after the sign-in too. Any other resource is still invalid_target, and the client policy's allows_resource can leave a service out for an agent;
  • the token is a Bearer token, even when the issuer binds its own with DPoP (§7: a Company whose MCP server doesn't accept DPoP returns Bearer tokens for it).

The service does its own half (§7). It publishes protected resource metadata whose resource equals its url and whose authorization_servers includes the company's issuer, at resource_metadata_url(url) (resourceMetadataUrl, RFC 9728 §3.1), which the example prints. It verifies each token it is sent with await service.access_token_for(token, url) (accessTokenFor), which answers the token's record only when it was issued for that service, is unexpired, its sign-in has not ended and its scopes are still offered. The default token and a token for another service answer None (undefined): the Company accepts a token issued for a resource only at that service (§4.5), and a service that gets a token not issued for it returns invalid_token with resource_metadata in its challenge. The record's account_id, client_id and scopes are what the service acts on, and it enforces the scopes on every call.

A company that names no resource server behaves as before.

Other clients than personal agents​

An MCP client that is no personal agent, such as a desktop assistant or an IDE, has no key and no Session: it signs in with MCP's own OAuth flow, the authorization code grant with PKCE and nothing else. The protocol leaves such clients outside (§7), and the reference company refuses them unless it is told otherwise:

config = CompanyConfig(
name="Example",
domain="example.com",
scopes=("orders:read", "orders:write"),
agent_description="Your orders",
scope_descriptions={"orders:read": "See your orders", "orders:write": "Change your orders"},
write_scopes=("orders:write",),
resource_servers=("https://mcp.example.com/mcp",),
public_clients=True,
client_registration=True,
public_client_scopes=("orders:read",),
)
print(config.registration_endpoint)

public_clients (publicClients) lets public clients sign in at Direct Sign-In's authorization endpoint, so it needs direct. Everything below is off without it, and a company that leaves it off behaves exactly as before.

Two ways to be a public client. Which one a client is, is never the request's to say.

  • Verified by its domain. Its client_id is the URL of a client ID metadata document that says token_endpoint_auth_method is none and names no jwks_uri, jwks or client_secret. A document that names a key is a personal agent's, and no document is both: a personal agent can't present itself as a public client to skip its assertion. The document is read by the pap.company.clientResolver contribution's resolve_public (resolvePublic), as a personal agent's is: HTTPS, no redirect, bounded, and never at a private address. A resolver without the method verifies none. The redirect URIs used from it are the loopback ones and the HTTPS ones on the client_id's own host.
  • Registered itself, with client_registration (clientRegistration): POST /oauth/register (RFC 7591) gives it a client_id that is no URL, and no secret. Every client registered is a public client, whatever it asked for: token_endpoint_auth_method left out, none, client_secret_post or client_secret_basic is registered the same way, and the response says "token_endpoint_auth_method": "none" with no client_secret (RFC 7591 §3.2.1: the server may replace what was requested, and the client uses what is returned). A registration that names a client_secret, jwks or jwks_uri of its own, or any other method (private_key_jwt among them), is invalid_client_metadata, with an error_description saying what to send: a personal agent can't register as a public client. A token or revocation request that carries a client_secret, in its form or as HTTP Basic, is invalid_client: no secret is ever issued, checked or ignored. That includes a library that sends a public client's client_id as HTTP Basic with an empty password: the client_id goes in the form, and no Authorization header. Nothing verifies what a registered client says of itself, its name least of all.

Redirect URIs of a public client are http to the loopback (127.0.0.1, [::1], localhost) or HTTPS to a host written in small letters, with no user information, fragment, backslash or space, and are compared as text. A request's redirect_uri matches a registered one exactly; only a loopback one may differ by its port (RFC 8252 §7.3). Any other scheme is refused.

The consent page is shown for every request. authorization_request says who asks: client_class is public_client (personal_agent otherwise), verified is false for a client that registered itself, redirect_host is where the browser goes back to and resource the service the sign-in is for. A hosted consent page shows the return host prominently, marks an unverified client as such, keeps caution (§10.8), and is never framed (frame-ancestors 'none'), as the company's own page does. An error of a request from an unverified client is a page, never a redirect: anyone can register any HTTPS redirect, and answering it without anyone's consent would make the endpoint an open redirector. Every answer carries iss (RFC 9207) and the request's state.

What a public client gets, and what it never gets:

  • a Bearer token for one service, which every request names as resource: the authorization request, the code exchange and each refresh, always the same one. The services are resource_servers and the company's own MCP server. Never the default token, never the conversation endpoint;
  • the scopes of public_client_scopes (publicClientScopes), or every scope of the company's own when it names none; never poppy:browser-sign-in;
  • the code and refresh grants only. The device and mediated grants answer unauthorized_client, and it can't push an authorization request;
  • no Session. Its token is refused at every endpoint of the protocol (conversations, operations, tasks, feedback, the browser session, the APIs), with or without a Session header, and at the MCP server once a Session header comes with it;
  • no operation. At the company's own MCP server a tool that needs the person's approval answers an error and returns no operation: only a personal agent approves one.

Refresh tokens of a public client are rotated at every use, and one used twice ends the whole sign-in, whatever refresh_reuse_revokes says for personal agents. A sign-in lasts public_client_refresh_lifetime (publicClientRefreshLifetimeSeconds, 30 days) from the moment the person allowed it, however often it refreshes; then they sign in again. No token outlives it: an access token issued near the end expires with the sign-in (expires_in says so), and a public client's token whose sign-in is over, ended or no longer on record is refused wherever it is read. A public client ends its own sign-in at the revocation endpoint with its client_id and the refresh token.

The client policy is asked as for a personal agent: allows before anything is fetched or read for a client_id, allows_sign_in at the authorization endpoint and again when the code is exchanged, allows_resource for the service, at each token request and each time access_token_for reads a token. A service at a URL of its own reads public on the record access_token_for returns: true for a public client's token, to which it gives no Session and from which it takes no approval.

A policy may answer for public clients apart, with allows_public(client_id) (allowsPublic): a company that lists the personal agents it serves takes public clients all the same, or none. Without the method, allows answers for both classes. sign_in_disabled is about personal agents only: it neither stops nor allows public clients, which public_clients alone decides.

A client verified by its domain is read again at each token request, so a document that went away or became a personal agent's gets nothing more. The resolver's cache decides how often that is a fetch: the default one keeps a document as its Cache-Control says, and remembers for 30 seconds that one could not be read.

Registration is bounded. The host's pap.company.rateLimit is asked first, with registration:{address} where it is asked a client_id; then the company counts client_registrations_per_hour (clientRegistrationsPerHour, 10) for each address. The address is the request's client_address (clientAddress): the peer's, which the ASGI and Node adapters fill in. Behind a proxy that is the proxy's, one count for everyone, unless the host passes the address its proxy vouches for. A registration is at most 16 KiB, names at most 10 redirect URIs and a name of at most 100 characters with no control or direction mark. A client that never signs in is forgotten an hour after it registered; one that signs in is kept client_registration_lifetime (90 days) from its last sign-in. A token or revocation request without a client assertion asks the host's rate limit too, with public:{address}, before the client it names is looked at.

For the company's owner. await service.public_client_sign_ins() (publicClientSignIns) lists the sign-ins that have not ended: the client, its name, whether it is verified, the return host, the service, the account, the scopes, when it signed in and last got tokens, and when it ends. revoke_public_client_sign_in(sign_in_id) (revokePublicClientSignIn) ends one: its refresh and access tokens stop working at once.

The issuer's metadata says none in token_endpoint_auth_methods_supported and authorization_response_iss_parameter_supported only with public_clients, and registration_endpoint only with client_registration.

Before production​

The defaults keep state in one process. A deployment contributes a durable store that passes check_store, a distributed replay cache, its real account directory and agent, an executor per action that is idempotent downstream, and a client policy. It also needs TLS, rate limits, and the operational controls above.

Demo worlds​

personal_agent_protocol.demo assembles fictional companies from these points, on an in-process network with real keys: Manzanita Outfitters (one user with a company), and Northwind Bank with Ledgerly (two companies, composed). See A user with a company and Two companies. The company-service Pydantic AI example builds a company of its own from a CompanyConfig, a store checked with check_store, a company agent, and one executor, serves it with company_app, and runs a personal agent's journey against it; the company-apis example reads and proposes through Manzanita's OpenAPI API and MCP server.

Use the upstream company implementation guidance alongside the normative specification.