Repository navigation
Add service tokens for unattended MCP clients - #52
Merged
Merged
Conversation
A bot or scheduled job cannot complete the browser OAuth flow, and MCP access tokens stop working when the Better Auth session behind them expires. ARTIFACTS_SERVICE_TOKENS maps service names to SHA-256 token digests; a matching bearer token on /mcp authenticates as that service account. Service tokens work on /mcp only and manage the team library only.
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.
Unattended clients like a Slack bot or a scheduled job can't complete the browser OAuth flow. Even if a person authorizes once, the MCP access tokens stop working when the Better Auth session behind them expires (7 days), and refreshing doesn't extend it. So there was no credential a bot could hold.
ARTIFACTS_SERVICE_TOKENSmaps service names to the SHA-256 digests of their tokens. Deployment vars are stored with the deployment record, so only digests are configured. A matchingAuthorization: Bearer <token>on/mcpauthenticates as that service account./mcponly. Gallery,/api/*, and private app/script URLs still need a signed-in person.library=teamget a 403. The account has no personal library, soapp_moveto private can't strand an item where no person can open it.{ subject: <name>, authority: "service-token" }./mcpinstead of being ignored.Unit tests cover parsing and matching. A new auth-flow integration test passes on both Miniflare and celld 0.6.1. It has a service account write and link an artifact in the team library, then checks that a signed-in teammate can see and open it, and that the token is rejected on
/api/*, private URLs, and personal-library requests.