Skip to content

feat: MCP Connect guide -- live key injection + connection test (OPE-168)#292

Merged
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feat/mcp-connect-ope-168
Mar 11, 2026
Merged

feat: MCP Connect guide -- live key injection + connection test (OPE-168)#292
DevanshuNEU merged 3 commits into
OpenCodeIntel:mainfrom
DevanshuNEU:feat/mcp-connect-ope-168

Conversation

@DevanshuNEU

@DevanshuNEU DevanshuNEU commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

OPE-168: MCP Connect page upgrade

What changed

ConnectGuide now injects the user's actual API key into config snippets. No more ci_your-key-here placeholder -- the first active key's preview is embedded directly in the Claude Desktop, Claude Code, and Cursor configs.

New ConnectionTest widget runs a 3-step live health check:

  1. MCP server reachable (pings mcp.opencodeintel.com/health)
  2. API key authenticated (hits /api/v1/keys with the key)
  3. Repositories accessible (hits /api/v1/repos with the key)

Each step shows animated pass/fail/running state. All three green = 'Connected' badge. Any failure = error message with troubleshooting hint.

Other improvements

  • Per-tab setup hints: 'Settings > Developer > Edit Config' for Claude Desktop, 'Run in terminal' for Claude Code, '.cursor/mcp.json' for Cursor
  • Cursor config now includes Authorization header (was missing)
  • Wifi icon in section header for visual consistency

Files changed

File Change
frontend/src/pages/APIKeysPage.tsx +155/-10 lines (ConnectGuide upgrade + ConnectionTest widget)

Build: clean. No new dependencies.

Closes OPE-168

Summary by CodeRabbit

  • New Features

    • Added a three-step connection health check (service, API key, repository) with per-step statuses and progress shown in the API Keys flow.
    • Integrated the health check into the API Keys setup with an updated header and status icon.
  • Documentation

    • Code snippets now show dynamic API key previews and per-snippet contextual hints.
  • Bug Fixes / UI

    • Minor layout and control placement tweaks for code blocks and copy controls.

…st (OPE-168)

ConnectGuide enhancements:
- Active API key injected into config snippets (was hardcoded ci_your-key-here)
- Per-tab setup hints (Settings > Developer > Edit Config, etc.)
- Cursor config now includes Authorization header with user's key
- Wifi icon in section header

New ConnectionTest widget:
- 3-step animated health check: MCP reachable -> Auth verified -> Repos accessible
- Sequential test with per-step pass/fail/running states
- Emerald badges on success, destructive on failure
- Error message on failure with troubleshooting hint
- Test button toggles between 'Test connection' -> 'Testing...' -> 'Connected'

Props flow: activeKeys[0].key_preview passed to ConnectGuide -> ConnectionTest

Build: clean. No new dependencies.
@vercel

vercel Bot commented Mar 10, 2026

Copy link
Copy Markdown

@DevanshuNEU is attempting to deploy a commit to the Dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a ConnectionTest component and integrates it into ConnectGuide (now accepting an API key preview and session token) to run three sequential checks (MCP health, API auth, repository access). Also introduces an exported MCP_URL constant in API config and interpolates API key into snippets.

Changes

Cohort / File(s) Summary
ConnectionTest & ConnectGuide (page updates)
frontend/src/pages/APIKeysPage.tsx
New ConnectionTest({ token }) component with three-step health/auth/repo checks, step statuses and UI; ConnectGuide signature changed to ({ activeKeyPreview, sessionToken }); snippets now interpolate API key; UI rearranged (Wifi icon, hint line, copy button tweaks).
API config
frontend/src/config/api.ts
Added exported MCP_URL constant sourced from import.meta.env.VITE_MCP_URL with a default https://mcp.opencodeintel.com.

Sequence Diagram

sequenceDiagram
    participant User
    participant ConnectGuide
    participant ConnectionTest
    participant MCPServer
    participant APIService
    participant Repository

    User->>ConnectGuide: open guide / select API key
    ConnectGuide->>ConnectionTest: pass activeKeyPreview & sessionToken
    User->>ConnectionTest: click "Run Connection Test"

    ConnectionTest->>MCPServer: GET /health (MCP_URL)
    MCPServer-->>ConnectionTest: health response
    ConnectionTest->>ConnectionTest: set step1 status

    ConnectionTest->>APIService: authenticate using API key
    APIService-->>ConnectionTest: auth success/fail
    ConnectionTest->>ConnectionTest: set step2 status

    ConnectionTest->>Repository: attempt repo access with token
    Repository-->>ConnectionTest: access result
    ConnectionTest->>ConnectionTest: set step3 status

    ConnectionTest->>User: render overall pass/fail result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰
I hopped through code with eager hops,
Three little checks—no fatal flops.
MCP, auth, repo in row,
Green lights glow and off I go! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding MCP Connect guide with live key injection and connection test functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@DevanshuNEU

Copy link
Copy Markdown
Collaborator Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/APIKeysPage.tsx`:
- Around line 293-305: The UI is copying the preview-only value
(activeKeyPreview / keyDisplay) into generated configs and passing it to
ConnectionTest, but the backend auth (middleware.auth hashing logic) requires
the full token so the preview will always 401; change the logic so that
functions/components that build or test auth configs (referenced by keyDisplay,
activeKeyPreview, and ConnectionTest) only use the real fullKey held in memory
immediately after generation (e.g., when createKey returns the raw secret) and
never pull tokens from the /keys list; if the full key is not available fall
back to inserting an explicit placeholder and showing a “copy/paste the full key
now” instruction (manual-paste flow) rather than reusing the preview string.
- Around line 190-193: The health probe is hardcoded to
https://mcp.opencodeintel.com/health while the rest of the page uses the
env-derived API base (API_URL); change the fetch in the MCP health check to
build its base from the same config/env variable used for the API base (e.g.,
use API_URL or the existing config getter) instead of the literal string, e.g.
derive mcpBase = <existing API base source> (or derive a dedicated MCP_BASE from
env) then call fetch(`${mcpBase.replace(/\/$/,'')}/health`), leaving the
surrounding logic (update(0, 'running') and the try/catch) intact.
- Around line 314-316: The Claude MCP example in APIKeysPage.tsx currently sets
config to the multiline string starting with "claude mcp add codeintel
--transport http https://mcp.opencodeintel.com/mcp" but omits authentication;
update that config string to include an explicit header flag per Anthropic MCP
docs (e.g., add --header "Authorization: Bearer <YOUR_API_KEY>") so the snippet
shows how to send the Bearer token with the HTTP transport; locate the config
literal in the APIKeysPage component and append the header flag to the existing
command string.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0c0e3043-606c-4494-be55-7aca51d9bb7d

📥 Commits

Reviewing files that changed from the base of the PR and between f0f339c and 3162b3f.

📒 Files selected for processing (1)
  • frontend/src/pages/APIKeysPage.tsx

Comment thread frontend/src/pages/APIKeysPage.tsx Outdated
Comment thread frontend/src/pages/APIKeysPage.tsx
Comment thread frontend/src/pages/APIKeysPage.tsx
Connection test was broken: used key_preview (truncated, e.g.
ci_80ba...e980) for Authorization header -- always 401 because
backend hashes the full key. Fixed: ConnectionTest now receives
the session JWT token from useAuth, which works with require_auth
middleware. The test verifies the user's backend access, not the
API key specifically.

Added MCP_URL to config/api.ts (separate Railway service from
API_URL). Health check now uses env-derived MCP_URL instead of
hardcoded string.

Claude Code snippet now includes --header flag for auth, matching
how Desktop (env.API_KEY) and Cursor (headers.Authorization)
handle it.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
frontend/src/pages/APIKeysPage.tsx (1)

316-316: ⚠️ Potential issue | 🟡 Minor

Missing space in Authorization header will cause auth failures.

The HTTP Authorization header syntax requires a space after the colon. The current format Authorization:Bearer will likely be rejected by the MCP server.

🔧 Proposed fix
      config: `claude mcp add codeintel \\
  --transport http \\
-  --header "Authorization:Bearer ${keyDisplay}" \\
+  --header "Authorization: Bearer ${keyDisplay}" \\
  https://mcp.opencodeintel.com/mcp`,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/APIKeysPage.tsx` at line 316, In APIKeysPage.tsx update
the Authorization header string where the curl/header is constructed so it
includes a space after the colon; change the header that currently reads
"Authorization:Bearer ${keyDisplay}" to "Authorization: Bearer ${keyDisplay}"
(locate the string near the curl/headers construction referencing keyDisplay) to
ensure the MCP server accepts the header.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@frontend/src/pages/APIKeysPage.tsx`:
- Line 316: In APIKeysPage.tsx update the Authorization header string where the
curl/header is constructed so it includes a space after the colon; change the
header that currently reads "Authorization:Bearer ${keyDisplay}" to
"Authorization: Bearer ${keyDisplay}" (locate the string near the curl/headers
construction referencing keyDisplay) to ensure the MCP server accepts the
header.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 18494e68-e1c1-4e3c-9619-12255f51f4e3

📥 Commits

Reviewing files that changed from the base of the PR and between 3162b3f and bfc549e.

📒 Files selected for processing (2)
  • frontend/src/config/api.ts
  • frontend/src/pages/APIKeysPage.tsx

'Authorization:Bearer' -> 'Authorization: Bearer' per HTTP spec.
Missing space could cause header parsing failures on strict servers.

Skipped preview-in-config finding: ConnectionTest already uses
session JWT (fixed in prior commit). Config snippets intentionally
show masked preview (ci_80ba...e980) as a visual hint -- the '...'
masking clearly signals 'replace with your key'.
@vercel

vercel Bot commented Mar 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opencodeintel Ready Ready Preview, Comment Mar 10, 2026 11:55pm

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
frontend/src/pages/APIKeysPage.tsx (1)

200-217: ⚠️ Potential issue | 🔴 Critical

This can show “Connected” for configs that will never authenticate.

Line 293 still feeds the copyable snippets from key_preview, but this file already treats that value as display-only/incomplete. Lines 203-217 then validate the browser session token instead, so the widget can pass even though the pasted Desktop/Code/Cursor config is unusable. Please only inject a real key while generatedKey is still in memory after creation; otherwise keep the placeholder/manual-paste flow and avoid presenting this as an API-key connection test.

Also applies to: 293-327, 582-586

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/pages/APIKeysPage.tsx` around lines 200 - 217, The current
auth/repo checks in APIKeysPage use the browser session token (variable token)
to call `${API_URL}/keys` and `${API_URL}/repos`, which lets the widget show
"Connected" even when the displayed copyable snippets come from key_preview and
no real API key exists; change the logic so that the auth tests (the update(1,
...) and update(2, ...) fetches) only run when a freshly created generatedKey is
still in memory (i.e., after key creation and before it’s cleared), and when
running use the real generatedKey value (not token) as the Bearer credential;
otherwise keep the placeholder/manual-paste UI/state (do not run the fetches and
do not mark as connected). Ensure places that render copyable snippets
(key_preview) remain display-only unless generatedKey is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/APIKeysPage.tsx`:
- Around line 299-327: The snippets for Desktop/Code/Cursor currently hardcode
"https://mcp.opencodeintel.com/mcp"; update them to use the normalized MCP URL
(the same MCP_URL/MCP normalization used by the health check) instead of the
literal host so non-prod environments show correct endpoints — modify the
template strings in the config fields for the mcpServers block, the code object
config, and the cursor config to interpolate the normalized MCP base (reuse the
existing normalizedMcpUrl or MCP_URL variable) in place of the hardcoded URL
while keeping keyDisplay for the Authorization header.
- Around line 190-217: The three raw fetch probes (MCP health, auth check, repos
accessible) must be replaced with React Query calls: use
queryClient.fetchQuery() (or create test-specific hooks) instead of direct fetch
to respect retries, error/abort handling and caching; locate the probes using
MCP_URL, API_URL, token, update and setRunning in APIKeysPage.tsx and convert
each try/catch block to await queryClient.fetchQuery(key, () => fetch(...)) or
corresponding custom hooks, propagating success/fail into update(...) and
setRunning(...) and ensuring you pass abort signal and react-query options
(retry, staleTime) consistent with the app.

---

Duplicate comments:
In `@frontend/src/pages/APIKeysPage.tsx`:
- Around line 200-217: The current auth/repo checks in APIKeysPage use the
browser session token (variable token) to call `${API_URL}/keys` and
`${API_URL}/repos`, which lets the widget show "Connected" even when the
displayed copyable snippets come from key_preview and no real API key exists;
change the logic so that the auth tests (the update(1, ...) and update(2, ...)
fetches) only run when a freshly created generatedKey is still in memory (i.e.,
after key creation and before it’s cleared), and when running use the real
generatedKey value (not token) as the Bearer credential; otherwise keep the
placeholder/manual-paste UI/state (do not run the fetches and do not mark as
connected). Ensure places that render copyable snippets (key_preview) remain
display-only unless generatedKey is present.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6ed68cd3-47d3-43a1-80b8-5242e4624da2

📥 Commits

Reviewing files that changed from the base of the PR and between bfc549e and df958de.

📒 Files selected for processing (1)
  • frontend/src/pages/APIKeysPage.tsx

Comment thread frontend/src/pages/APIKeysPage.tsx
Comment thread frontend/src/pages/APIKeysPage.tsx
@DevanshuNEU DevanshuNEU merged commit 09513de into OpenCodeIntel:main Mar 11, 2026
8 checks passed
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.

1 participant