MCP OAuth source doesn't send `resource` parameter required by RFC 9728 (breaks notfair.co and other resource-bound MCP servers)
Problem
When connecting an MCP source that uses RFC 9728 OAuth Protected Resource Metadata (e.g. https://notfair.co/api/mcp/notfair), Craft Agents successfully completes an OAuth flow and stores a token — but the MCP server rejects it with:
{"error":"Missing or invalid NotFair OAuth token","oauth":{"protocol":"oauth_2_1","preferred_flow":"authorization_code_pkce","resource_metadata":"https://notfair.co/.well-known/oauth-protected-resource/api/mcp/notfair"}}
The token is rejected because it was issued without the resource parameter in the authorization request. Per RFC 8707 (Resource Indicators for OAuth 2.0) — which RFC 9728 depends on — the client must include resource=<mcp_server_url> in the authorization and token requests so the server issues a token scoped to that specific resource.
Steps to Reproduce
- Create an MCP source pointing to
https://notfair.co/api/mcp/notfairwithauthType: "oauth"(no explicit OAuth credentials — relying on auto-discovery) - Trigger
source_oauth_trigger - Complete the OAuth consent flow
- The source reports
isAuthenticated: truebutsource_testfails with the error above - No MCP tools from this server appear in the session
Expected Behavior
The OAuth authorization request should include resource=https://notfair.co/api/mcp/notfair (the MCP server URL), so the issued token is properly scoped and accepted by the server.### Proposed FixWhen authType: "oauth" and no explicit OAuth credentials are provided, the OAuth client should:
- Fetch
/.well-known/oauth-protected-resource<path>to discover the authorization server - Include
resource=<mcp_server_url>in both the authorization request and token exchange (per RFC 8707 §2)This is part of the MCP authorization spec (2025-03-26+) and will be required by an increasing number of MCP servers.
Environment
- Craft Agents desktop app
- MCP server:
https://notfair.co/api/mcp/notfair
Source: craft-ai-agents/craft-agents-oss