Skip to content

Commit fe64521

Browse files
kwkrassclaude
andcommitted
Implement workaround for MCP Inspector OAuth URL construction bug
- Added dedicated oauthAuthorizationServer and oauthProtectedResource functions - Configured Firebase hosting rewrites for /.well-known/* paths - Addresses GitHub issue #545 in modelcontextprotocol/typescript-sdk - MCP Inspector incorrectly drops base paths when constructing OAuth metadata URLs - Now provides OAuth metadata at both root level (buggy behavior) and correct level References: - modelcontextprotocol/typescript-sdk#545 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e49754e commit fe64521

2 files changed

Lines changed: 68 additions & 2 deletions

File tree

‎firebase.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"rewrites": [
1717
{
1818
"source": "/.well-known/oauth-authorization-server",
19-
"function": "wellKnownOAuth"
19+
"function": "oauthAuthorizationServer"
2020
},
2121
{
2222
"source": "/.well-known/oauth-protected-resource",
23-
"function": "wellKnownOAuth"
23+
"function": "oauthProtectedResource"
2424
},
2525
{
2626
"source": "**",

‎functions/index.js‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,72 @@ exports.wellKnownOAuth = onRequest(
9090
}
9191
)
9292

93+
// WORKAROUND: Root-level OAuth metadata for MCP Inspector bug
94+
// See: https://github.com/modelcontextprotocol/typescript-sdk/issues/545
95+
// The MCP Inspector incorrectly drops base paths when constructing OAuth metadata URLs
96+
exports.oauthAuthorizationServer = onRequest(
97+
{
98+
timeoutSeconds: 60,
99+
memory: '256MB',
100+
region: 'europe-west1',
101+
cors: {
102+
origin: true,
103+
methods: ['GET', 'OPTIONS'],
104+
allowedHeaders: ['*'],
105+
credentials: false,
106+
},
107+
},
108+
async (req, res) => {
109+
console.log('Root-level OAuth authorization server metadata request')
110+
111+
const baseUrl = process.env.FUNCTIONS_EMULATOR
112+
? 'http://localhost:5001/alldonestaging/europe-west1/mcpServer'
113+
: 'https://europe-west1-alldonestaging.cloudfunctions.net/mcpServer'
114+
115+
res.json({
116+
issuer: baseUrl,
117+
authorization_endpoint: `${baseUrl}/auth/authorize`,
118+
token_endpoint: `${baseUrl}/auth/token`,
119+
registration_endpoint: `${baseUrl}/register`,
120+
scopes_supported: ['read', 'write', 'mcp:tools'],
121+
response_types_supported: ['code'],
122+
grant_types_supported: ['authorization_code'],
123+
subject_types_supported: ['public'],
124+
id_token_signing_alg_values_supported: ['RS256'],
125+
code_challenge_methods_supported: ['S256'],
126+
})
127+
}
128+
)
129+
130+
exports.oauthProtectedResource = onRequest(
131+
{
132+
timeoutSeconds: 60,
133+
memory: '256MB',
134+
region: 'europe-west1',
135+
cors: {
136+
origin: true,
137+
methods: ['GET', 'OPTIONS'],
138+
allowedHeaders: ['*'],
139+
credentials: false,
140+
},
141+
},
142+
async (req, res) => {
143+
console.log('Root-level OAuth protected resource metadata request')
144+
145+
const baseUrl = process.env.FUNCTIONS_EMULATOR
146+
? 'http://localhost:5001/alldonestaging/europe-west1/mcpServer'
147+
: 'https://europe-west1-alldonestaging.cloudfunctions.net/mcpServer'
148+
149+
res.json({
150+
resource: baseUrl,
151+
authorization_servers: [baseUrl],
152+
scopes_supported: ['read', 'write', 'mcp:tools'],
153+
bearer_methods_supported: ['header'],
154+
resource_documentation: 'https://modelcontextprotocol.io',
155+
})
156+
}
157+
)
158+
93159
//PAYMENT AND PREMIUM
94160

95161
exports.updateCreditCardNumberSecondGen = onCall(

0 commit comments

Comments
 (0)