Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Oct 8, 2025

Description

authenticate using mcp-remote for mcp servers requiring authorization

resolves CON-4179

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

feat.mp4

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Add OAuth handling for MCP servers in the CLI by falling back to mcp-remote (stdio) when SSE/HTTP connections return 401. Enables authentication to protected MCP endpoints and aligns with Linear CON-4179.

  • New Features

    • Detect 401/Unauthorized errors from SSE/HTTP transports.
    • On auth failure, automatically invoke npx -y mcp-remote <url> via stdio to complete auth and connect.
  • Bug Fixes

    • Validate transport types and throw a clear error for unsupported values.

@uinstinct uinstinct requested a review from a team as a code owner October 8, 2025 14:52
@uinstinct uinstinct requested review from sestinj and removed request for a team October 8, 2025 14:52
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 8, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="extensions/cli/src/services/MCPService.ts">

<violation number="1" location="extensions/cli/src/services/MCPService.ts:388">
Non-401 connection failures are now swallowed by this catch block, so the client proceeds without a live connection. Please rethrow errors that are not authorization-related so the caller can report the failure.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

const transport = this.constructHttpTransport(serverConfig);
await client.connect(transport, {});
}
} catch (error: unknown) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 8, 2025

Choose a reason for hiding this comment

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

Non-401 connection failures are now swallowed by this catch block, so the client proceeds without a live connection. Please rethrow errors that are not authorization-related so the caller can report the failure.

Prompt for AI agents
Address the following comment on extensions/cli/src/services/MCPService.ts at line 388:

<comment>Non-401 connection failures are now swallowed by this catch block, so the client proceeds without a live connection. Please rethrow errors that are not authorization-related so the caller can report the failure.</comment>

<file context>
@@ -366,15 +377,27 @@ export class MCPService
+          const transport = this.constructHttpTransport(serverConfig);
+          await client.connect(transport, {});
+        }
+      } catch (error: unknown) {
+        // on authorization error, use &quot;mcp-remote&quot; with stdio transport to connect
+        if (is401Error(error)) {
</file context>

✅ Addressed in 68292ed

@sestinj sestinj merged commit c7b8e0f into continuedev:main Oct 8, 2025
41 of 42 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Oct 8, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Oct 8, 2025
@sestinj
Copy link
Contributor

sestinj commented Oct 8, 2025

🎉 This PR is included in version 1.27.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@uinstinct uinstinct deleted the cli-mcp-oauth branch October 9, 2025 02:35
@sestinj
Copy link
Contributor

sestinj commented Oct 12, 2025

🎉 This PR is included in version 1.24.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor

sestinj commented Oct 15, 2025

🎉 This PR is included in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

released size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants