Fix Claude Desktop MCP handshake on /mcp.

GET holds a short SSE stream, auth failures return JSON-RPC 401, and OAuth discovery advertises bearer-only.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-11-02 22:00:29 -06:00
co-authored by Cursor
parent 96776ed493
commit 1834ac4af9
6 changed files with 105 additions and 30 deletions
+12 -1
View File
@@ -75,17 +75,28 @@ test('aigen routes exist, stay on the studio-2 enqueue path, and 404 on xAIGen',
assert.match(job, /stillAbsoluteUrl/)
assert.match(middleware, /aigenBearerAuthorized/)
assert.match(middleware, /aigenApiPathAllowed/)
assert.match(middleware, /\/\.well-known\/oauth-protected-resource/)
assert.match(authPaths, /path === '\/mcp'/)
assert.match(mcp, /assertAigenApiAccess/)
assert.match(mcp, /mcpBearerOk/)
assert.match(mcp, /text\/event-stream/)
assert.match(mcp, /tools\/list/)
assert.match(mcp, /tools\/call/)
assert.match(mcp, /resolveMcpProtocolVersion/)
assert.doesNotMatch(mcp, /405.*GET|Method Not Allowed[\s\S]*GET/)
assert.match(mcpUtil, /aigen_engines/)
assert.match(mcpUtil, /aigen_generate/)
assert.match(mcpUtil, /aigen_job/)
assert.match(mcpUtil, /queueAigenGenerate/)
assert.match(mcpUtil, /readAigenJob/)
assert.match(mcpUtil, /authorization_servers/)
assert.match(mcpUtil, /2025-06-18/)
assert.match(nuxt, /aigenApiKey:\s*process\.env\.AIGEN_API_KEY/)
assert.match(bench, /studio2EngineDefaults/)
const oauthRoot = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource.get.ts'), 'utf8')
const oauthMcp = readFileSync(join(root, 'server/routes/.well-known/oauth-protected-resource/mcp.get.ts'), 'utf8')
assert.match(oauthRoot, /mcpOauthProtectedResource/)
assert.match(oauthMcp, /mcpOauthProtectedResource/)
})
test('defaultLibraryFolderId prefers Inbox then the first folder', () => {