Repository navigation
fix(mcp): tell ChatGPT the tools need OAuth and which scopes to request - #21
Merged
Merged
Conversation
A ChatGPT plugin pointed at /mcp installed with no Connect button. The OAuth flow itself works (registration, sign-in, consent, token, search); what was missing is everything ChatGPT reads to decide to offer sign-in: - tools/list now carries securitySchemes (oauth2) on every tool, as a top-level field and in _meta (the SDK only passes _meta through) - the 401 challenge names the scopes to request - the protected resource metadata lists scopes_supported; the mcp plugin leaves identity and refresh scopes out, so a client had no hint to ask for offline_access README documents the plugin mcp.json auth block (oauth + dcr), which the plugin package needs for the button to appear. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A ChatGPT plugin pointed at
https://brain.cutdacord.app/mcpinstalls with no Connect button, so there is no way to sign in.What was wrong
The OAuth flow itself works. Checked against production (read-only) and end to end against a local copy:
<base>/mcp, the issuer is consistent, PKCE S256 is supportedPOST /mcpreturns 401 withWWW-Authenticate: Bearer resource_metadata=…initialize→tools/list→kb_searchall passSince the 2026-10-05 migration the production auth DB has 0 registered OAuth clients, so ChatGPT never started the flow. The signals ChatGPT reads before offering sign-in were missing:
securitySchemes(0 of 12).scopes_supported, and those are the only scopes this server has.mcp.jsonhas noextensions["com.openai"].authblock (outside this repo; the README now documents it).Change
tools/listcarriessecuritySchemes: [{ type: "oauth2", scopes: ["openid", "offline_access"] }]on every tool, top-level and in_meta(the SDK only passes_metathrough).scope="openid offline_access"./.well-known/oauth-protected-resource[/mcp]addsscopes_supported.mcp.jsonauth block (oauth+dcr).Nothing is exposed anonymously. Every MCP request still needs an API key or a token bound to the MCP resource. API-key clients are untouched.
Tests
tests/mcp-http.test.js(3 tests) and 3 tests intests/auth-oauth.test.js. All 6 failed before the change.initialize,tools/list,kb_search,kb_context,kb_read, refresh, bad-token and code-replay rejection): passes both when the client requests every scope and when it requests only the advertised ones.resourceparameter gets an unbound token and is refused with 401. That is intended.Deploy
Merge, then
sudo systemctl restart kb-server. No schema or data change.🤖 Generated with Claude Code