Skip to content

Conversation

@Dumbris
Copy link
Contributor

@Dumbris Dumbris commented Jan 18, 2026

Summary

Fixes #251 - OAuth discovery fails for Smithery servers due to non-standard metadata path.

Smithery.ai servers use RFC 8414 compliant OAuth metadata paths, but mcpproxy was using a non-compliant path. Per RFC 8414 Section 3.1, when the authorization server URL contains a path, the well-known path should be inserted between host and path:

URL Format Standard (RFC 8414) mcpproxy (before)
https://auth.smithery.ai/googledrive https://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive https://auth.smithery.ai/googledrive/.well-known/oauth-authorization-server

Changes

  • New function buildRFC8414MetadataURLs(): Constructs compliant metadata URLs per RFC 8414 Section 3.1
  • New function discoverAuthServerMetadataWithFallback(): Tries multiple discovery paths with fallback
  • Multi-path discovery: Tries RFC 8414 path first, falls back to legacy path for backward compatibility
  • Better error messages: Includes all attempted URLs in error messages for easier debugging
  • Comprehensive tests: Unit tests for both Smithery-style and legacy server paths

Test plan

  • Unit tests pass for buildRFC8414MetadataURLs() with various URL formats
  • Unit tests pass for discoverAuthServerMetadataWithFallback() with both path styles
  • All existing OAuth tests continue to pass
  • API E2E tests pass
  • Linter passes
  • Manual test with Smithery server (Note: separate DCR panic issue exists - see below)

Note on DCR panic

During testing, I discovered a separate issue where the manual auth login command fails with a nil pointer dereference during Dynamic Client Registration (DCR). This is a pre-existing bug unrelated to the OAuth discovery path fix. The background OAuth flow works correctly - the DCR panic only affects the CLI login command. This should be tracked as a separate issue.

🤖 Generated with Claude Code

Smithery.ai servers use non-standard OAuth metadata paths that don't
match the current implementation. Per RFC 8414 Section 3.1, when the
authorization server URL contains a path, the well-known path should
be inserted between host and path, not appended after.

Changes:
- Add buildRFC8414MetadataURLs() to construct compliant metadata URLs
- Add discoverAuthServerMetadataWithFallback() to try multiple paths
- Try RFC 8414 path first, fall back to legacy path for compatibility
- Include all attempted URLs in error messages for debugging
- Add comprehensive unit tests for both Smithery and legacy servers

Example URL transformations:
- https://auth.smithery.ai/googledrivehttps://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive

Fixes #251

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 18, 2026

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: caffe5e
Status: ✅  Deploy successful!
Preview URL: https://ce1e47eb.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-251-smithery-oauth-disco.mcpproxy-docs.pages.dev

View logs

@github-actions
Copy link

github-actions bot commented Jan 18, 2026

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/251-smithery-oauth-discovery

Available Artifacts

  • archive-darwin-amd64 (23 MB)
  • archive-darwin-arm64 (21 MB)
  • archive-linux-amd64 (12 MB)
  • archive-linux-arm64 (11 MB)
  • archive-windows-amd64 (23 MB)
  • archive-windows-arm64 (20 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (26 MB)
  • installer-dmg-darwin-arm64 (23 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 21112333005 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

Smithery and similar servers use separate domains for MCP and OAuth:
- MCP Server: server.smithery.ai/googledrive
- Auth Server: auth.smithery.ai/googledrive

Previously, OAuth metadata discovery used the MCP server URL directly,
causing DCR to fail with 404 because metadata is on the auth server.

Changes:
- Add DiscoverAuthServerURL() to get auth server from Protected Resource
  Metadata (RFC 9728)
- Add FindWorkingMetadataURL() to validate which metadata URL works
- Add base URL fallback to BuildRFC8414MetadataURLs() for Cloudflare-style
  servers that host metadata at root level
- Update createOAuthConfigInternal() to discover auth server before
  constructing OAuth metadata URLs
- Update mcp-go to v0.44.0-beta.2

Fixes #251

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Dumbris Dumbris merged commit 028e799 into main Jan 18, 2026
23 checks passed
@Dumbris Dumbris deleted the fix/251-smithery-oauth-discovery branch January 18, 2026 13:26
technicalpickles pushed a commit to technicalpickles/mcpproxy-go that referenced this pull request Jan 21, 2026
…-proxy#262)

* fix: implement RFC 8414 compliant OAuth metadata discovery (smart-mcp-proxy#251)

Smithery.ai servers use non-standard OAuth metadata paths that don't
match the current implementation. Per RFC 8414 Section 3.1, when the
authorization server URL contains a path, the well-known path should
be inserted between host and path, not appended after.

Changes:
- Add buildRFC8414MetadataURLs() to construct compliant metadata URLs
- Add discoverAuthServerMetadataWithFallback() to try multiple paths
- Try RFC 8414 path first, fall back to legacy path for compatibility
- Include all attempted URLs in error messages for debugging
- Add comprehensive unit tests for both Smithery and legacy servers

Example URL transformations:
- https://auth.smithery.ai/googledrivehttps://auth.smithery.ai/.well-known/oauth-authorization-server/googledrive

Fixes smart-mcp-proxy#251

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: discover auth server from PRM for separate domain OAuth servers

Smithery and similar servers use separate domains for MCP and OAuth:
- MCP Server: server.smithery.ai/googledrive
- Auth Server: auth.smithery.ai/googledrive

Previously, OAuth metadata discovery used the MCP server URL directly,
causing DCR to fail with 404 because metadata is on the auth server.

Changes:
- Add DiscoverAuthServerURL() to get auth server from Protected Resource
  Metadata (RFC 9728)
- Add FindWorkingMetadataURL() to validate which metadata URL works
- Add base URL fallback to BuildRFC8414MetadataURLs() for Cloudflare-style
  servers that host metadata at root level
- Update createOAuthConfigInternal() to discover auth server before
  constructing OAuth metadata URLs
- Update mcp-go to v0.44.0-beta.2

Fixes smart-mcp-proxy#251

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

OAuth discovery fails for Smithery servers due to non-standard metadata path

2 participants