MCP server connection with GitHub Copilot returns different ports on reauthentication Issue When re-authenticating to connect the ServiceNow MCP server to GitHub Copilot, different ports are returned each time. This behavior complicates successful re-authentication and affects the reliability of the integration. The issue was observed during both Visual Studio and Copilot CLI terminal usage. Release All Cause The issue arises because GitHub Copilot listens on a random (ephemeral) port for authentication redirects by default. This dynamic port assignment conflicts with the ServiceNow MCP server's expectation of a static redirect URI, leading to authentication failures when ports change between re-authentication attempts. Resolution 1. Add the `callbackPort` property inside the `oauth` configuration block of your `mcp.json` file to lock the port to a specific value, enabling pre-registration of a predictable redirect URI in the identity provider.2. Ensure the `callbackPort` is set to a fixed number (e.g., 8080) in the MCP server configuration to avoid dynamic port assignment during authentication.3. Verify the configuration aligns with the identity provider's requirements for redirect URIs to resolve 'invalid redirect URI' errors. Example: json { "servers": { "your-custom-server": { "type": "http", "url": "https://mcp.example.com", "oauth": { "clientId": "your-client-id", "callbackPort": 8080 } } } }