Repository navigation
feat(platform): add the sign-in server for coding agents - #4898
Merged
Merged
Conversation
The scopes an agent connection can hold (tale:mcp and the five beyond it, plus offline_access), the three cumulative access levels the consent page offers, the access that needs a fresh sign-in, and the most a role may grant — derived from the abilities the app already checks, so the consent page, the authorization server and the MCP door read one rule.
The MCP endpoint becomes an OAuth resource on every address the deployment answers on, and the Better Auth provider learns to sign in coding agents beside the organizations' own applications: - RFC 9728 resource metadata at /.well-known/oauth-protected-resource (at the endpoint's own path and at the root), and the issuer's RFC 8414 metadata at the issuer's path, base path included; the edge and the dev proxy route both from the host root; - the agent scopes and offline_access, the refresh grant (30 days, sliding, rotated, a 10-second replay grace), and the endpoint's resource rows written after the boot migrations: the provider's own start-up seeding would read the database before the boot waits out an unavailable one, and stay failed for the life of the process; - clients identified by a client metadata document (@better-auth/cimd 1.7.5 on its pinned-address transport, never from the deployment's own host), and open self-registration restricted to the agent scopes, loopback or app redirects and known agents' web hosts, native apps inferred, ten an hour per source, 500 a day, 5,000 at most, never owned by the caller's session; - an agent's authorization request bound to the MCP endpoint when it names no resource, and a failed token request charged to its source. An organization's own application keeps its behaviour: it holds no agent scope, so the MCP resource's scope allowlist refuses it, and registering it links no resource. The dead validAudiences option is gone. The four TALE_MCP_* sign-in variables are in .env.example and the environment reference (EN/DE/FR).
A coding agent can register itself or name a client metadata document, but no token it earns can be used yet: the organization a grant is for, the door that accepts the token and the page that asks the person all follow. Both ways in therefore default to off, and the MCP endpoint's resource metadata answers 404 until the operator opens one, so nothing advertises a sign-in that cannot finish. The environment reference and .env.example say so in English, German and French. The sign-in server is proved against real Postgres and HTTP: discovery, the endpoint seeded as a resource, self-registration accepted, refused and slowed down, an authorization request bound to the endpoint, a client created from its metadata document, and an organization's own application kept off the endpoint. The identity lane runs beside it unchanged.
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.
What
The first step of OAuth sign-in for coding agents on the MCP endpoint: the sign-in server. Better Auth's OAuth provider, which already signs people in to the organizations' own applications, learns to sign in agents beside them. It is off by default — nothing is advertised or opened until an operator turns a way in on, because no token it earns can be used yet (the organization a grant is for, the door that accepts the token and the page that asks the person are the next steps).
lib/shared/agent-access.ts):tale:mcpand the five beyond it,offline_access, the three cumulative access levels, and the most a role may grant — derived from the abilities the app already checks, so the consent page, the server and the MCP door will read one rule.@better-auth/cimd1.7.5, pinned-address transport, never from the deployment's own host) or self-registered (restricted to the agent scopes, loopback/app redirects and known agents' web hosts, native apps inferred, ten an hour per source, 500 a day, 5,000 at most, never owned by the caller's session).invalid_scope), and registering it links no resource. The deadvalidAudiencesoption is gone; the provider's consent endpoints are closed (Tale's own routes will own a connection's lifecycle).TALE_MCP_CLIENT_METADATA_DOCUMENTSandTALE_MCP_DYNAMIC_CLIENT_REGISTRATIONdefault tofalseandTALE_MCP_CLIENT_METADATA_HOSTS/TALE_MCP_DCR_WEB_REDIRECT_HOSTSnarrow them; in.env.exampleand the environment reference in English, German and French. While both are off the resource metadata answers 404.Proof
checkAgentOAuthbeside the unchanged identity lanecheckNativeIdentity(150/150): discovery, the endpoint seeded as a resource, a CLI agent registered as a native app owned by nobody, a known agent host accepted and a foreign redirect / extra scope / own keys / other grant refused, an authorization request bound to the endpoint, a client created from its metadata document and none fetched from the deployment itself, an organization's application kept off the endpoint with nothing linked, and a source that keeps registering turned away withRetry-After.The two earlier agent commits (the scopes, then the server) are kept as they were written; the last commit is the default-off change and the lane.