Repository navigation
store every MCP credential in one shape, {auth: 'none' | 'token' | 'oauth', …} - #384
Merged
hkonsti merged 1 commit intoNov 25, 2026
Merged
Conversation
…auth', …}, built in and custom alike
* mcp/mcp-credential.ts holds the shapes: a built-in integration's key is {auth: 'token', token} rather than {auth: 'key', key}, and a sign-in's tokens are under {auth: 'oauth'} rather than bare; a custom server's credential is the same with its address beside it, as it already was
* the data migration unify-mcp-credentials rewrites every built-in MCP connection's credential, each only while it is still the one read, leaving whether the provider turned it down as it was; one changed meanwhile has it tried again on the next start
* the old shapes are still read, as they are now, until every instance has run it: an instance of the code before may still write them while a deploy rolls over
* mcp-session.ts reads credentials with a schema rather than letting unknown fields through: built-in integrations with theirs, a custom server's sign-in with its own (withMcpSignIn), which keeps its address and endpoints when its tokens are refreshed
* McpCredential, the tokens of a sign-in, is McpTokens
* the seed writes the new shape
hkonsti
force-pushed
the
hkonsti/unify-mcp-credentials
branch
from
November 25, 2026 22:48
c7be4fb to
37e64f0
Compare
hkonsti
added a commit
that referenced
this pull request
Nov 25, 2026
and #384 left (#390) * read MCP credentials only in the shape they have now; the old shapes only in the data migration, run again for what an instance from before wrote while #384 rolled over * the old shapes, a key as {auth: 'key', key} and a sign-in's tokens bare, move from mcp-credential.ts into unify-credentials.ts: the session reads a built-in integration's credential with builtInCredentialSchema alone * the migration runs again as unify-mcp-credentials-again: an instance from before #384 could still write the old shapes while its deploy rolled over, after the first run was noted as done * Sendable in mcp-session.ts was BuiltInCredential under another name * connect a custom server and move one on its page through one step; withMcpSignIn is withMcpCredential * connectServer in custom/route.ts asks the server for its tools and saves the connection, or begins the sign-in it asks for, for a new connection and for one moved on its page alike; what differs is its Destination * withMcpSignIn sends a token or key as well as a sign-in's access token, so it is withMcpCredential
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.
Stacked on #383.
An integration built on its MCP server stored a key as
{auth: 'key', key}and a sign-in's tokens bare, with noauthat all, while a custom server stored{auth: 'none' | 'token' | 'oauth', url, …}. The session code coped by letting any unknown field through (mcpCredentialSchema.loose()), so a custom server's address survived a token refresh. Every MCP credential now has the one shape.What changes
mcp/mcp-credential.tsholds the shapes:{auth: 'none'},{auth: 'token', token},{auth: 'oauth', clientId, accessToken, refreshToken, expiresAt}. A built-in integration's istokenoroauth; a custom server's is any of the three with itsurlbeside it (and the server's endpoints foroauth), as it already was, so custom credentials are untouched.tokenrather thanbearer: a custom server's token is sent as written when it starts with its scheme (Basic …), so it isn't always a bearer token, and keepingtokenleaves every custom credential as it is.mcp-session.tsreads with a schema instead of.loose():withMcpTokenwith the built-in one,withMcpSignInwith a custom server's sign-in schema, which keeps its address and endpoints when its tokens are refreshed.McpCredential, which was only a sign-in's tokens, isMcpTokens.mcp-connect.tsfor keys and sign-ins,take-over-custom.ts, the seed) write the new shape.Data migration
unify-mcp-credentialsrewriteConnectionCredential, compare-and-set on the encrypted value), so tokens refreshed meanwhile are never undone. Unlike a refresh it leavescredentialRejectedAtas it was.storedBuiltInCredentialSchema), mapped to the new ones. Data migrations run after an instance starts listening, and while a deploy rolls over an instance of the code before may still write them. Once every instance has run the migration, the legacy readers and the migration can go.{auth: 'token'}), so a call on an Exa, Parallel, Linear or Cloudflare key connection handled by it fails until it is replaced. Sign-ins are fine either way (the old code read them loosely).Testing
bun run typecheck,bun run lint,bun run testpass.unify-credentials.test.ts: rewrites keys and bare tokens over the one read, leaves current ones, retries on a change meanwhile or a database error, passes over one it can't decrypt.mcp-session.test.ts: bare tokens and{auth: 'key'}are still read, and saved in the new shape on refresh; a custom sign-in keeps its address.