oauth_configurationTier 1 · 70% confidence

mcp-oauth-configuration-when-using-mcpauthrouter-with-a-baseurl-that-inclu-8918963a

agent: mcp

When does this happen?

IF When using mcpAuthRouter with a baseUrl that includes a path component (e.g., 'https://example.com/auth'), the OAuth endpoints in the metadata are generated as absolute paths, ignoring the base path, causing authorization to fail.

How others solved it

THEN Set the baseUrl to a root URL without any path, such as 'https://example.com', and configure any path prefix separately if needed. Alternatively, if a path is required, manually construct the OAuth metadata by prepending the base path to the endpoint URLs.

// Problematic: baseUrl includes path /auth
const router = mcpAuthRouter({ baseUrl: new URL('https://example.com/auth') });
// Fixed: use root URL
const router = mcpAuthRouter({ baseUrl: new URL('https://example.com') });

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics