From c205612e17b4582af490befb075131535e11da8a Mon Sep 17 00:00:00 2001 From: ReallyLiri Date: Sat, 3 May 2025 19:07:30 +0300 Subject: [PATCH 1/3] Support custom post-auth redirect uri --- README.md | 2 +- src/lib/utils.ts | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c36424c..9897959 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ To bypass authentication, or to emit custom headers on all requests to your remo ```json "command": "npx", "args": [ - "-y" + "-y", "mcp-remote", "https://remote.mcp.server/sse" ] diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 9e3e243..b1a7d39 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -300,7 +300,13 @@ export function setupOAuthCallbackServerWithLongPoll(options: OAuthCallbackServe log('Auth code received, resolving promise') authCompletedResolve(code) - res.send('Authorization successful! You may close this window and return to the CLI.') + const postAuthRedirectUri = req.query.postAuthRedirectUri as string | undefined + if (postAuthRedirectUri) { + log(`Redirecting to post-auth redirect URI: ${postAuthRedirectUri}`) + res.redirect(postAuthRedirectUri); + } else { + res.send('Authorization successful! You may close this window and return to the CLI.') + } // Notify main flow that auth code is available options.events.emit('auth-code-received', code) From b75795cac214c4d852e7bcdf6a113497f5ec4d67 Mon Sep 17 00:00:00 2001 From: ReallyLiri Date: Sat, 3 May 2025 19:08:27 +0300 Subject: [PATCH 2/3] ; --- src/lib/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index b1a7d39..28ef0e5 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -303,7 +303,7 @@ export function setupOAuthCallbackServerWithLongPoll(options: OAuthCallbackServe const postAuthRedirectUri = req.query.postAuthRedirectUri as string | undefined if (postAuthRedirectUri) { log(`Redirecting to post-auth redirect URI: ${postAuthRedirectUri}`) - res.redirect(postAuthRedirectUri); + res.redirect(postAuthRedirectUri) } else { res.send('Authorization successful! You may close this window and return to the CLI.') } From 833faa7440ad0781691177bd9a499d61ee9f0888 Mon Sep 17 00:00:00 2001 From: ReallyLiri Date: Mon, 12 May 2025 11:09:44 +0300 Subject: [PATCH 3/3] md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 9897959..2afc364 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,14 @@ npx mcp-remote https://example.remote/server --transport sse-only - `http-only`: Only uses HTTP transport, fails if the server doesn't support it - `sse-only`: Only uses SSE transport, fails if the server doesn't support it +### Post-Auth Redirect URI + +To customize the redirect behavior after an OAuth flow, include a `postAuthRedirectUri` query parameter in the request to the OAuth callback endpoint. This parameter specifies where users should be redirected after successful authentication. + +Ensure that your server appends `postAuthRedirectUri` as a query parameter when invoking the `redirectUri`. + +Once authentication is complete, users will be redirected to the specified URI instead of seeing the default "Authorization successful" message. This allows you to deliver a smoother user experience by guiding users to a custom post-authentication page. + ### Claude Desktop [Official Docs](https://modelcontextprotocol.io/quickstart/user)