Skip to content

Add service tokens for unattended MCP clients - #52

Merged
nicosuave merged 1 commit into
mainfrom
mcp-service-tokens
Oct 13, 2026
Merged

nicosuave merged 1 commit into
mainfrom
mcp-service-tokens

Conversation

@nicosuave

Copy link
Copy Markdown
Member

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_TOKENS maps service names to the SHA-256 digests of their tokens. Deployment vars are stored with the deployment record, so only digests are configured. A matching Authorization: Bearer <token> on /mcp authenticates as that service account.

  • /mcp only. Gallery, /api/*, and private app/script URLs still need a signed-in person.
  • Team library only. Requests without library=team get a 403. The account has no personal library, so app_move to private can't strand an item where no person can open it.
  • Plugins see { subject: <name>, authority: "service-token" }.
  • A malformed table returns 503 on /mcp instead 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.

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.
@nicosuave
nicosuave merged commit 0d1f9c2 into main Oct 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant