Skip to content

Add dynamic OAuth discovery for community MCP servers#410

Merged
jchangx merged 5 commits intodocker:mainfrom
jchangx:jchangx/community-oauth-flow-v039
Feb 26, 2026
Merged

Add dynamic OAuth discovery for community MCP servers#410
jchangx merged 5 commits intodocker:mainfrom
jchangx:jchangx/community-oauth-flow-v039

Conversation

@jchangx
Copy link
Contributor

@jchangx jchangx commented Feb 14, 2026

Summary

  • Community MCP servers from third-party registries (e.g., Kubit) require OAuth but have no oauth.providers metadata in their catalog entry, so the existing IsRemoteOAuthServer() gate prevents DCR entries from being created
  • Adds RegisterProviderForDynamicDiscovery() which probes remote servers using DiscoverOAuthRequirements() and creates pending DCR entries when OAuth is detected
  • Integrates the fallback into all three callsites: working set sync, docker mcp server enable, and gateway mcpadd
  • Expands the gateway OAuth condition to also match remote servers without oauth.providers

Test plan

  • docker mcp catalog-next pull mcp/community-registry
  • docker mcp profile server add default --server catalog://mcp/community-registry/com-notion-mcp
  • Verify DCR entry is created: docker mcp oauth ls
  • Authorize the server: docker mcp oauth authorize com-notion-mcp
  • Verify authorization: docker mcp oauth ls
  • Revoke and re-authorize: docker mcp oauth revoke com-notion-mcp
  • Verify existing servers with oauth.providers still work (no regression)
  • Verify servers that don't require OAuth are not affected (probe returns no OAuth)

Confirming com-notion-mcp from community registry successfully authorized via oauth:

❯ docker mcp oauth ls
ai-kubit-mcp-server | not authorized
com-notion-mcp      | authorized
github              | authorized
miro-remote         | not authorized

Confirming oauth flow for com-notion-mcp from community registry:

❯ docker mcp oauth authorize com-notion-mcp
Opening your browser for authentication. If it doesn't open automatically, please visit: ...

@jchangx jchangx requested a review from a team as a code owner February 14, 2026 06:21
@jchangx jchangx force-pushed the jchangx/community-oauth-flow-v039 branch from abc55ea to cf09171 Compare February 14, 2026 06:26
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: abc55eabac

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jchangx jchangx force-pushed the jchangx/community-oauth-flow-v039 branch 5 times, most recently from 9c15228 to 4adff41 Compare February 14, 2026 07:00
@jchangx
Copy link
Contributor Author

jchangx commented Feb 14, 2026

@codex review

@jchangx jchangx marked this pull request as draft February 14, 2026 07:12
@jchangx jchangx marked this pull request as ready for review February 14, 2026 07:12
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4adff415d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jchangx jchangx force-pushed the jchangx/community-oauth-flow-v039 branch 8 times, most recently from d7031f4 to 921ad1f Compare February 19, 2026 02:52
jchangx and others added 2 commits February 25, 2026 10:28
Community servers from third-party registries lack oauth.providers metadata,
so the existing IsRemoteOAuthServer() gate prevents DCR entries from being
created and OAuth tokens from being consumed. This adds support for the full
dynamic OAuth lifecycle: discovery, token attachment, provider refresh, and
connection invalidation.

Discovery (DCR registration):
- Add RegisterProviderForDynamicDiscovery() in pkg/oauth/dcr_registration.go
- Add fallback branch in workingset, server enable, and gateway mcpadd

Token consumption:
- Attach stored OAuth tokens for community servers during Initialize
  (fallback when Spec.OAuth is nil but Remote.URL is set)
- Start OAuth provider refresh loop for community servers with stored tokens
- Fix InvalidateOAuthClients to match remote servers by name, not Spec.OAuth
Pass only the names that were actually removed from the profile to
CleanupOrphanedDCREntries, instead of the full user-supplied list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jchangx jchangx force-pushed the jchangx/community-oauth-flow-v039 branch from 921ad1f to 4f4219c Compare February 25, 2026 18:29
jchangx and others added 2 commits February 25, 2026 11:04
- Guard against nil discovery response in registerProviderForDynamicDiscovery
- Distinguish HTTP 404 from transient errors in DCR verification
- Consolidate duplicate OAuth credential helper in remote.go
- Simplify mcpadd OAuth condition to use serverConfig.IsRemote()
- Remove extra blank line in server.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The consolidated check called GetOAuthToken for all remote servers,
which logs errors for servers without stored tokens. Restore the
two-branch structure so catalog servers (explicit OAuth metadata)
log errors while community servers silently ignore missing tokens.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jchangx jchangx requested review from cmrigney and saucow February 25, 2026 19:59
saucow
saucow previously approved these changes Feb 25, 2026
Copy link
Contributor

@saucow saucow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, mostly some suggestions to help with debugging and timeout values.

Not a blocker, but wondering if we should rename: IsRemoteOAuthServer -> something like: HasCatalogOAuthMetadata() or: HasExplicitOAuthProviders() since the criteria of remote OAuth servers is now being expanded.

- Remove redundant 10s probe timeout (discovery library uses 30s internally)
- Log dynamic OAuth discovery failures instead of silently returning nil
- Rename IsRemoteOAuthServer to HasExplicitOAuthProviders for clarity
- Log TokenExists errors during community server provider startup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jchangx jchangx merged commit 705a801 into docker:main Feb 26, 2026
5 checks passed
@jchangx jchangx deleted the jchangx/community-oauth-flow-v039 branch February 26, 2026 00:24
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.

2 participants