Github demo: Show an interstitital for new clients but existing users #99
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.
This should resolve #51. For the moment all the logic is in
workers-oauth-utils.ts, but will be moved to an NPM package soon.We can't stop GitHub from treating the MCP server as the "client" and therefore skipping the permissions dialog when the same user auths twice. So, instead, we show an interstitial approval screen:
If the user accepts, the client ID is stored in a cookie so future authentication requests will skip this screen too. But, importantly, if the same user tries a different MCP client (e.g. Claude Desktop using mcp-remote), they'll get prompted. This way the MCP Server doesn't auth you without at least showing you which client is asking for permission, which was the issue in #51.
Bit of tidying to do to make this more generic, but for the moment you use it with following API:
clientIdAlreadyApprovedchecks the cookie and skips the render if the user's already acceptedrenderApprovalDialogrenders a HTML form with the state encoded so context is preserved when you submitparseRedirectApprovalpulls the state out of the form submission and returns it along with theset-cookieheaders to attach to the redirect.You can test this out using my deployed version:
https://mcp-github-oauth.glen.workers.dev/sse