[PR #29039] fix(mcp): add root-level OAuth metadata discovery fallback #32273

Open
opened 2026-02-21 20:51:05 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/29039

State: open
Merged: No


Summary

  • Add root-level OAuth Authorization Server Metadata discovery fallback for MCP servers that don't follow RFC 8414 path suffix convention

Problem

When connecting to MCP servers like Atlassian (https://mcp.atlassian.com/v1/sse), OAuth metadata discovery fails with "Failed to discover OAuth metadata from server".

This happens because:

  1. RFC 8414 specifies that when the issuer URL has a path, metadata should be at /.well-known/oauth-authorization-server{path}
  2. Dify tries /.well-known/oauth-authorization-server/v1/sse which returns 404
  3. Atlassian places metadata at root-level /.well-known/oauth-authorization-server without the path suffix

Solution

Add root-level /.well-known/oauth-authorization-server as a fallback URL when the path-suffixed discovery fails.

Test plan

  • Tested with Atlassian MCP server (https://mcp.atlassian.com/v1/sse)
  • OAuth authorization flow completes successfully
**Original Pull Request:** https://github.com/langgenius/dify/pull/29039 **State:** open **Merged:** No --- ## Summary - Add root-level OAuth Authorization Server Metadata discovery fallback for MCP servers that don't follow RFC 8414 path suffix convention ## Problem When connecting to MCP servers like Atlassian (`https://mcp.atlassian.com/v1/sse`), OAuth metadata discovery fails with "Failed to discover OAuth metadata from server". This happens because: 1. RFC 8414 specifies that when the issuer URL has a path, metadata should be at `/.well-known/oauth-authorization-server{path}` 2. Dify tries `/.well-known/oauth-authorization-server/v1/sse` which returns 404 3. Atlassian places metadata at root-level `/.well-known/oauth-authorization-server` without the path suffix ## Solution Add root-level `/.well-known/oauth-authorization-server` as a fallback URL when the path-suffixed discovery fails. ## Test plan - [x] Tested with Atlassian MCP server (`https://mcp.atlassian.com/v1/sse`) - [x] OAuth authorization flow completes successfully
yindo added the pull-request label 2026-02-21 20:51:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32273