Skip to content

Conversation

joshrutkowski
Copy link
Contributor

@joshrutkowski joshrutkowski commented Oct 8, 2025

Add support for custom redirect URI to support multiple remote MCP servers and requirement where an MCP server may require a hardcoded port. When not assigned in the mcp configuration, the current experience is preserved (randomly assigned port)

Issue #, if available: Request to be able to specify port/have dedicated port for redirect_uri since currently it was randomly assigned and this cannot be supported by the OAuth provider.

Description of changes:

Adds ability to specify a default OAuth redirect uri, per mcp server (similar to Gemini CLI)

Example configuration


{

  "mcpServers": {

    "stripe": {

      "type": "http",

      "url": "https://mcp.stripe.com",

      "oauth": {

        "redirectUri": "127.0.0.1:7777"

      }

    },

    "vercel": {

      "type": "http",

      "url": "https://mcp.vercel.com",

      "oauth": {

        "redirectUri": "127.0.0.1:7778"

      }

    }

  }

}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add chat.oauthRedirectPort setting to configure the OAuth callback
server port. Replaces random port with configurable default of 7777.
@joshrutkowski joshrutkowski marked this pull request as ready for review October 8, 2025 11:30
@joshrutkowski
Copy link
Contributor Author

Another commit incoming - need to rework this in the event of multiple remote MCPs, I see this

- Mcp error: -32002: Address already in use (os error 48)

@joshrutkowski joshrutkowski changed the title feat: add configurable OAuth redirect port (default: 7777) feat: add configurable OAuth redirect uri Oct 8, 2025
pub timeout: u64,
pub scopes: &'a [String],
pub headers: &'a HashMap<String, String>,
pub oauth_config: &'a Option<crate::cli::chat::tools::custom_tool::OAuthConfig>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - import OAuthConfig


#[derive(Clone, Serialize, Deserialize, Debug, Eq, PartialEq, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct OAuthConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we want this to more or less match what you linked w/ gemini - https://github.com/google-gemini/gemini-cli/blob/main/docs/tools/mcp-server.md#oauth-configuration-properties

There's already a top-level oauth_scopes unfortunately which could've been included in here, but I think it does make sense to add any and all future OAuth related config items here going forward

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i have some time this week, I can refactor oauth_scopes to be inside this config to consolidate this going forward

@brandonskiser
Copy link
Contributor

Thank you!

@brandonskiser brandonskiser merged commit eb1c8a8 into aws:main Oct 10, 2025
1 check passed
@joshrutkowski joshrutkowski deleted the mcp-port branch October 13, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants