Repository navigation
Accept OAuth and API-key callers on one HTTP endpoint - #10
Merged
Merged
Conversation
Add FMSG_MCP_AUTH_MODE=oauth+api-key for HTTP. It requires the full OAuth configuration and routes each request by its Authorization header: `Bearer fmsgk_...` uses the existing API-key path unchanged, and every other request (including unauthenticated ones) uses the OAuth path with its resource_metadata challenge and scope checks. The two mechanisms keep separate providers, caches and MCP handlers, so a caller is only resolved by the provider that authenticated it. Protected-resource metadata is served and attachment downloads accept either credential. A rejected API key is also challenged with the resource_metadata URL (without the internal API-key scope) so hosts can discover sign-in. api-key and oauth modes behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Adds
FMSG_MCP_AUTH_MODE=oauth+api-key(HTTP only) so a single public MCP URL can serve both API-key callers and MCP-authorization (OAuth) callers. It requires the same completeFMSG_MCP_OAUTH_*configuration asoauthmode. stdio is unchanged.Routing is per request, by the
Authorizationheader:Bearer fmsgk_...→ the existing API-key path, as inapi-keymode (key exchanged at the Web API, never sent to the authorization server; no OAuth scopes).oauthmode, including scope checks and the401challenge withresource_metadata.Design notes:
/mcp/attachments/...) accept either credential.401 error="invalid_token"with the sameresource_metadataparameter, so hosts can discover sign-in. The internal API-keyfmsgscope is left out of that challenge because it isn't an authorization-server scope, and a host that followed it would request an invalid scope.api-keyandoauthmodes behave as before. Inoauthmode anfmsgk_token still goes to OAuth validation and is rejected there.HttpServerHandlegainsproviders: { apiKey?, oauth? }.providerstays as the OAuth provider when OAuth is configured, and the API-key provider otherwise.Tests
New
HTTP OAuth combined with API keyssuite intest/oauth.test.ts, run against the local authorization server:401withresource_metadata, and the API-key verifier is never called/fmsg/tokenresource_metadataand noscope, and is never sent to the OAuth verifier403forsend_message)oauth+api-keyparsing, stdio refusal, required settings and the invalid-mode messagenpm run typecheck,npm run buildandnpm testpass (157 tests).🤖 Generated with Claude Code