Skip to content

feat(mcp): add authenticated workspace code mode#653

Merged
urjitc merged 24 commits into
mainfrom
staging
Jul 17, 2026
Merged

feat(mcp): add authenticated workspace code mode#653
urjitc merged 24 commits into
mainfrom
staging

Conversation

@urjitc

@urjitc urjitc commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an authenticated MCP endpoint that exposes ThinkEx workspace operations through a compact code-mode operation catalog.
  • Let connected users work with every workspace available to their account while enforcing their current workspace role on each read or mutation.
  • Add the OAuth provider, consent, token verification, CORS, metadata, and durable signing-key foundation required by MCP clients.
  • Harden workspace mutation conflicts, operational error handling, React hook usage, and transitive sanitizer resolution.

Why

ThinkEx needs an MCP surface that remains useful as the operation catalog grows without loading a large tool schema into every client context. The implementation uses a compact executor-style interface while retaining the existing workspace service and permission boundaries as the source of truth.

The earlier MCP pull request was old and coupled a large amount of code to outdated assumptions. This branch rebuilds the feature on the current workspace architecture and keeps authentication, protocol routing, operation metadata, and workspace execution behind separate boundaries.

Changes

  • Add Better Auth OAuth provider tables and persisted signing keys, including the required database migrations.
  • Add OAuth consent and dynamic client registration for MCP clients.
  • Publish OAuth authorization-server and protected-resource metadata and handle browser preflights.
  • Verify MCP bearer tokens locally using issuer, audience, and persisted JWKS constraints.
  • Add a compact MCP operation catalog covering the existing read and mutation operations.
  • Derive operation availability and authorization from the user's live workspace memberships and roles.
  • Normalize mutation IDs and typed conflict handling across HTTP, RPC, AI tools, and MCP execution.
  • Isolate staging Worker deployment behavior from production.
  • Preserve infrastructure failures instead of flattening them into expected domain errors, and record cleanup failures through structured operational events.
  • Remove redundant React memoization and replace callback-ref synchronization with React effect events where lifecycle-safe.
  • Pin DOMPurify to a patched transitive release and document the single-audience constraint for Better Auth 1.6.

Testing

  • pnpm check
  • pnpm test — 72 tests passed
  • pnpm test:workers — 4 tests passed
  • pnpm knip
  • Production dependency audit: no high or critical findings

Review Notes

  • Start with src/features/mcp/mcp-route.ts, src/features/mcp/mcp-auth.ts, and src/features/mcp/mcp-operation-catalog.ts for the protocol and execution boundaries.
  • Review src/lib/auth.server.ts and the two new Drizzle migrations together; the OAuth signing-key persistence is required before deployment.
  • Dynamic client registration is intentionally available for MCP clients. User authorization and workspace permissions are still enforced after authentication at operation execution time.
  • Better Auth 1.6's resource-indicator advisory is mitigated by allowing exactly one MCP audience and verifying that exact audience at the resource server. Upgrade to the patched stable line when available and apply its schema migration.
  • The remaining production audit findings are moderate: the mitigated Better Auth advisory above and a development-server-only esbuild advisory under legacy Drizzle tooling.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Added OAuth-based MCP access for workspace operations, including a new consent page, scoped permissions, metadata, and CORS handling.
    • Enabled listing and executing workspace operations via MCP-compatible tools.
  • Bug Fixes
    • Improved handling of workspace name conflicts and returned outcomes.
    • Improved invite loading/acceptance when unavailable, with clearer redirect behavior.
    • Enhanced telemetry and safer failure handling for uploads, document sessions, invitations, and AI thread operations.
  • Reliability
    • Added rate limiting and persistent key storage for authentication flows.

urjitc added 19 commits July 16, 2026 13:28
Represent expected name conflicts as serializable kernel outcomes so Cloudflare RPC does not
discard conflict metadata. Create initial relations in the same kernel command to avoid partial
workspace mutations.
Verify access tokens through the typed Better Auth API, preserve JWKS infrastructure failures,
and centralize MCP paths, scopes, and audience configuration. Reject consent requests that do
not name any permissions.
Type provider-specific reasoning options at their source and use the generated Browser binding
directly. This keeps provider configuration checked without changing the tool surface.
Translate only expected domain errors and surface infrastructure failures.
Record cleanup and purge failures with structured operational events.
Remove redundant manual memoization from compiler-compatible components.
Use effect events for file-drop callbacks and hoist stable render values.
Force the patched DOMPurify release across transitive consumers.
Document the single-audience constraint mitigating Better Auth 1.6 resource widening.
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@urjitc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ae81d6b-6964-4079-b2a3-df0b6124c2a7

📥 Commits

Reviewing files that changed from the base of the PR and between 210ed66 and e088e4f.

📒 Files selected for processing (10)
  • server.json
  • src/components/AuthPageLayout.tsx
  • src/components/AuthScreen.tsx
  • src/components/ui/command.tsx
  • src/features/mcp/mcp-consent.functions.ts
  • src/features/mcp/mcp-route.ts
  • src/features/workspaces/kernel/workspace-kernel-item-commands.ts
  • src/features/workspaces/kernel/workspace-kernel.ts
  • src/routes/invite.$token.tsx
  • src/routes/oauth.consent.tsx
📝 Walkthrough

Walkthrough

Adds a remote OAuth-protected MCP server with database schema, authentication, scoped workspace operations, OpenAPI metadata, consent UI, and routing. Refactors workspace kernel mutations to structured outcomes, adds reliability telemetry and invite status handling, and removes selected React memoization.

Changes

MCP OAuth Server

Layer / File(s) Summary
OAuth and MCP schema
drizzle/*, src/db/schema.ts
Adds OAuth, JWKS, rate-limit tables, migrations, snapshots, and journal entries.
MCP contracts and execution
src/features/mcp/mcp-config.ts, mcp-auth.ts, mcp-operation-catalog.ts, mcp-openapi.ts
Defines MCP scopes and URLs, verifies bearer tokens, catalogs scoped workspace operations, and generates OpenAPI paths.
MCP transport and auth wiring
src/features/mcp/mcp-cors.ts, mcp-route.ts, src/lib/auth.*, src/routes/api/auth/$.ts, src/server.ts
Adds CORS handling, OAuth metadata routing, Better Auth OAuth provider configuration, and worker request dispatch.
Consent UI and validation
src/routes/oauth.consent.tsx, src/routeTree.gen.ts, src/features/mcp/*test.ts
Adds the OAuth consent page, generated route registration, and MCP catalog/CORS tests.

Workspace Kernel Mutation Outcomes

Layer / File(s) Summary
Mutation contracts and resolution
src/features/workspaces/kernel/workspace-kernel-types.ts, workspace-kernel-store.ts, workspace-kernel-item-commands.ts
Replaces name-conflict exceptions with resolved/conflict outcome objects for kernel mutations.
Kernel access and consumers
src/features/workspaces/kernel/*, src/features/workspaces/operations/*, src/routes/api/v1/workspaces.$workspaceId.file-upload.ts
Propagates structured outcomes through kernel access, workspace operations, file commands, and upload handling.

Workspace Tool Access/Effects Model

Layer / File(s) Summary
Access/effects contract and consumers
src/features/workspaces/operations/workspace-tool-definitions.ts, src/features/workspaces/ai/ai-thread-runtime.ts, workspace-tools.ts
Replaces mutating/scopes metadata with access/effects fields and derives scope checks from access.

Workspace Reliability and Invite Flow

Layer / File(s) Summary
Error telemetry and typed handling
src/features/workspaces/ai/*, documents/*, durable-object-lifecycle.ts, extraction/*, invites/workspace-invite-email.ts, kernel/workspace-kernel.ts
Adds structured operational failure events and typed permission, lookup, cleanup, and projection error handling.
Invite status resolution
src/features/workspaces/invites/workspace-invite-functions.ts, src/routes/invite.$token.tsx
Returns ready/unavailable invite results and updates route redirects and rendering accordingly.

React and Utility Updates

Layer / File(s) Summary
React hook cleanup
src/components/*, src/features/workspaces/components/*, src/lib/use-native-file-drop-target.ts, use-workspace-presence.ts
Removes selected useCallback/useMemo usage and uses useId/effect-event handling where updated.
Configuration and utilities
package.json, pnpm-workspace.yaml, src/features/workspaces/contracts.ts, src/lib/*
Updates deployment/package configuration, validation, error naming, environment lookup, browser typing, and date formatting.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant routeMcpRequest
  participant authenticateMcpRequest
  participant BetterAuth
  participant executeMcpOperation

  Client->>routeMcpRequest: POST MCP operation with Bearer token
  routeMcpRequest->>authenticateMcpRequest: Verify request token
  authenticateMcpRequest->>BetterAuth: Load JWKS
  BetterAuth-->>authenticateMcpRequest: Token payload
  authenticateMcpRequest-->>routeMcpRequest: Principal or 401 response
  routeMcpRequest->>executeMcpOperation: Dispatch operation and principal
  executeMcpOperation-->>routeMcpRequest: Scoped operation result
  routeMcpRequest-->>Client: MCP response with CORS headers
Loading
sequenceDiagram
  participant Operation
  participant WorkspaceKernel
  participant WorkspaceKernelStore

  Operation->>WorkspaceKernel: Execute mutation
  WorkspaceKernel->>WorkspaceKernelStore: Resolve item name
  WorkspaceKernelStore-->>WorkspaceKernel: Resolved or conflict outcome
  WorkspaceKernel-->>Operation: Applied command or conflict outcome
  Operation-->>Operation: Map conflict to path_already_exists
Loading

Possibly related issues

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding an authenticated MCP-based workspace code mode.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch staging

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.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

React Doctor found 2 new issues in 2 files · 2 warnings · score 77 / 100 (Needs work) · 21 fixed · vs main

2 warnings

src/features/workspaces/operations/create-items.ts

  • ⚠️ L144 await inside a loop async-await-in-loop

src/routes/invite.$token.tsx

  • ⚠️ L15 Sequential awaits in loader tanstack-start-loader-parallel-fetch

Reviewed by React Doctor for commit e088e4f. See inline comments for fixes.

@urjitc
urjitc marked this pull request as ready for review July 16, 2026 20:20
@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an authenticated MCP workspace surface. The main changes are:

  • OAuth provider tables, persisted JWKS signing keys, consent UI, and dynamic client registration.
  • MCP protocol routing with CORS, OAuth metadata, protected-resource metadata, and bearer-token verification.
  • A compact workspace operation catalog backed by existing workspace permission checks.
  • Shared workspace tool definitions and normalized mutation conflict handling across AI tools, HTTP, RPC, and MCP paths.
  • Related React hook cleanup, operational error handling, and dependency resolution updates.

Confidence Score: 5/5

This PR appears safe to merge with low risk.

The MCP authentication path verifies issuer and audience locally, operation execution checks OAuth scopes, and workspace operations re-check live membership and role permissions.

No files require special attention.

T-Rex T-Rex Logs

What T-Rex did

  • Ran pnpm check as part of the general contract validation, and it failed with exit code 1 due to formatting issues in the node-review draft and the Trex setup guide.
  • Executed MCP CORS tests with Vitest, and all 3 tests passed.
  • Executed MCP operation-catalog.worker tests with Vitest, and all 4 tests passed.
  • Uploaded and organized four artifacts summarizing the pnpm check failure and the passing Vitest runs for reviewer access.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
src/features/mcp/mcp-route.ts Adds MCP protocol routing, metadata, bearer authentication, and operation execution boundaries.
src/features/mcp/mcp-auth.ts Adds bearer-token extraction and local JWS verification against issuer, audience, and JWKS.
src/features/mcp/mcp-operation-catalog.ts Introduces compact MCP workspace operation catalog with scope checks and per-workspace access contexts.
src/lib/auth.server.ts Configures Better Auth OAuth provider, persisted JWKS, dynamic registration, consent, and MCP audience restriction.
src/db/schema.ts Adds OAuth provider, token, consent, rate-limit, and JWKS schema tables.
drizzle/0002_lyrical_lorna_dane.sql Creates OAuth provider and rate-limit tables matching the schema.
drizzle/0003_aberrant_nitro.sql Creates persisted JWKS table for OAuth signing keys.
src/routes/oauth.consent.tsx Adds OAuth consent UI for MCP clients with scope display and consent submission.
src/routes/api/auth/$.ts Routes Better Auth requests and applies MCP CORS only to public OAuth endpoints.
src/features/workspaces/operations/workspace-tool-definitions.ts Centralizes workspace tool definitions and MCP-reusable execution adapters.

Reviews (1): Last reviewed commit: "fix(security): pin sanitizer and MCP aud..." | Re-trigger Greptile

@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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/features/mcp/mcp-cors.ts`:
- Line 1: Add mcp-session-id to mcpCorsRequestHeaders in
src/features/mcp/mcp-cors.ts. Update the preflight assertion in
src/features/mcp/mcp-cors.test.ts lines 12-19 to verify the response allows
mcp-session-id.

In `@src/features/workspaces/kernel/workspace-kernel-item-commands.ts`:
- Around line 176-184: Update the item-creation command containing
relations.createRelations and events.commit so item insertion, initial relation
creation, and event persistence execute in one database transaction. Ensure
transaction failure compensates by removing the created shell file (or otherwise
cleans up the item) while preserving the existing idempotency behavior, so
retries can complete or return the original mutation.

In `@src/routes/oauth.consent.tsx`:
- Around line 31-59: Update decide so the authClient.oauth2.consent call is
covered by try/finally, ensuring setPendingDecision(null) always runs when the
request rejects or completes. Preserve the existing validation, result-error
handling, and redirect behavior while preventing rejected requests from leaving
the consent buttons disabled.
- Around line 17-20: Update the consent action around
authClient.oauth2.consent(...) to use try/catch, ensuring pendingDecision is
cleared in the error path so the consent buttons become enabled again when the
request rejects. Preserve the existing success behavior and decision handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d9baf30-6c6c-464c-a374-8493e978dce1

📥 Commits

Reviewing files that changed from the base of the PR and between 9eb99be and 99e2e7f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (59)
  • drizzle/0002_lyrical_lorna_dane.sql
  • drizzle/0003_aberrant_nitro.sql
  • drizzle/meta/0002_snapshot.json
  • drizzle/meta/0003_snapshot.json
  • drizzle/meta/_journal.json
  • package.json
  • pnpm-workspace.yaml
  • src/components/landing/gravity.tsx
  • src/components/ui/command.tsx
  • src/db/schema.ts
  • src/features/mcp/mcp-auth.ts
  • src/features/mcp/mcp-config.ts
  • src/features/mcp/mcp-cors.test.ts
  • src/features/mcp/mcp-cors.ts
  • src/features/mcp/mcp-openapi.ts
  • src/features/mcp/mcp-operation-catalog.ts
  • src/features/mcp/mcp-operation-catalog.worker.test.ts
  • src/features/mcp/mcp-route.ts
  • src/features/workspaces/ai/ai-thread-prompt-scope.ts
  • src/features/workspaces/ai/ai-thread-runtime.ts
  • src/features/workspaces/ai/ai-thread.ts
  • src/features/workspaces/ai/user-ai-agents.ts
  • src/features/workspaces/ai/web-tools.ts
  • src/features/workspaces/ai/workspace-tools.ts
  • src/features/workspaces/components/WorkspaceFileIntakeProvider.tsx
  • src/features/workspaces/components/WorkspaceFileUploadProvider.tsx
  • src/features/workspaces/components/WorkspaceShareEmailInviteField.tsx
  • src/features/workspaces/components/ai-chat/AiChatModelPicker.tsx
  • src/features/workspaces/components/use-auto-hide-overlay.ts
  • src/features/workspaces/contracts.ts
  • src/features/workspaces/documents/document-session.ts
  • src/features/workspaces/durable-object-lifecycle.ts
  • src/features/workspaces/extraction/liteparse-projection.ts
  • src/features/workspaces/extraction/workspace-page-projection.ts
  • src/features/workspaces/invites/workspace-invite-email.ts
  • src/features/workspaces/invites/workspace-invite-functions.ts
  • src/features/workspaces/kernel/workspace-kernel-access.ts
  • src/features/workspaces/kernel/workspace-kernel-file-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-item-commands.ts
  • src/features/workspaces/kernel/workspace-kernel-store.ts
  • src/features/workspaces/kernel/workspace-kernel-types.ts
  • src/features/workspaces/kernel/workspace-kernel.ts
  • src/features/workspaces/operations/create-items.ts
  • src/features/workspaces/operations/move-items.ts
  • src/features/workspaces/operations/rename-item.ts
  • src/features/workspaces/operations/workspace-tool-definitions.ts
  • src/features/workspaces/read-page-selection.ts
  • src/features/workspaces/realtime/use-workspace-presence.ts
  • src/lib/app-origin.ts
  • src/lib/auth-client.ts
  • src/lib/auth.server.ts
  • src/lib/blog.ts
  • src/lib/use-native-file-drop-target.ts
  • src/routeTree.gen.ts
  • src/routes/api/auth/$.ts
  • src/routes/api/v1/workspaces.$workspaceId.file-upload.ts
  • src/routes/invite.$token.tsx
  • src/routes/oauth.consent.tsx
  • src/server.ts

Comment thread src/features/mcp/mcp-cors.ts Outdated
@@ -0,0 +1,31 @@
const mcpCorsRequestHeaders = "authorization, content-type, mcp-protocol-version";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Files ==\n'
git ls-files src/features/mcp/mcp-cors.ts src/features/mcp/mcp-cors.test.ts

printf '\n== Outline: src/features/mcp/mcp-cors.ts ==\n'
ast-grep outline src/features/mcp/mcp-cors.ts --view expanded || true

printf '\n== Outline: src/features/mcp/mcp-cors.test.ts ==\n'
ast-grep outline src/features/mcp/mcp-cors.test.ts --view expanded || true

printf '\n== Relevant lines: src/features/mcp/mcp-cors.ts ==\n'
cat -n src/features/mcp/mcp-cors.ts

printf '\n== Relevant lines: src/features/mcp/mcp-cors.test.ts ==\n'
cat -n src/features/mcp/mcp-cors.test.ts

Repository: ThinkEx-OSS/thinkex

Length of output: 3604


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Search for MCP CORS and session header references ==\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  'mcp-session-id|mcpCorsRequestHeaders|mcpCorsPreflightResponse|Mcp-Session-Id' src

printf '\n== Show any MCP-related transport code ==\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' \
  'MCP|mcp' src/features src | head -n 200

Repository: ThinkEx-OSS/thinkex

Length of output: 15192


🌐 Web query:

MCP transport spec Mcp-Session-Id request header CORS preflight browser clients

💡 Result:

In the Model Context Protocol (MCP) Streamable HTTP transport specification, the Mcp-Session-Id header is used to maintain stateful sessions between a client and a server [1][2][3]. When an MCP server is accessed by browser-based clients, proper Cross-Origin Resource Sharing (CORS) configuration is required to ensure that this header is accessible and that browser-enforced security policies do not block the communication [4][5][6]. Key considerations for CORS and the Mcp-Session-Id header include: 1. Exposing the Header: Browsers restrict access to response headers by default. For a browser-based client to read the Mcp-Session-Id header returned by the server during the initialization phase (and persist it for subsequent requests), the server must explicitly include it in the Access-Control-Expose-Headers list in its CORS policy [4][5][6][7]. Failing to do this is a common cause of session management failures in browser environments, as the client library cannot access the session ID to include it in future requests [4][5]. 2. Preflight Requests: When a browser client makes requests that include custom headers (such as Mcp-Session-Id), it triggers a CORS preflight (OPTIONS) request [8][7][9]. The server must respond to this preflight request with appropriate Access-Control-Allow-Headers that include Mcp-Session-Id, as well as any other headers used by the protocol (e.g., Mcp-Protocol-Version, Content-Type) [4][5][10]. 3. Security Recommendations: - Avoid overly permissive configurations like Access-Control-Allow-Origin: * when credentials are involved [11][12][13]. - Ensure the server adheres to restrictive CORS policies, specifically listing allowed origins, methods (GET, POST, DELETE, OPTIONS), and required headers [12][7]. - Implement Access-Control-Max-Age to cache preflight responses, reducing the overhead of repeated preflight requests [8][12][13]. - Consider mandatory security headers, such as Strict-Transport-Security (HSTS), to protect the transport [12]. In summary, for browser clients to successfully manage sessions, your server's CORS middleware must be configured to both allow the Mcp-Session-Id header in requests (via Access-Control-Allow-Headers) and expose it in responses (via Access-Control-Expose-Headers) [4][5][13][7].

Citations:


Allow Mcp-Session-Id in CORS preflight headers.

Browser clients need to send the MCP session ID on follow-up requests, but mcpCorsRequestHeaders omits mcp-session-id from Access-Control-Allow-Headers.

  • src/features/mcp/mcp-cors.ts: add mcp-session-id to mcpCorsRequestHeaders.
  • src/features/mcp/mcp-cors.test.ts: assert the preflight response allows mcp-session-id.
📍 Affects 2 files
  • src/features/mcp/mcp-cors.ts#L1-L1 (this comment)
  • src/features/mcp/mcp-cors.test.ts#L12-L19
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/mcp/mcp-cors.ts` at line 1, Add mcp-session-id to
mcpCorsRequestHeaders in src/features/mcp/mcp-cors.ts. Update the preflight
assertion in src/features/mcp/mcp-cors.test.ts lines 12-19 to verify the
response allows mcp-session-id.

Comment thread src/features/workspaces/kernel/workspace-kernel-item-commands.ts
Comment thread src/routes/oauth.consent.tsx
Comment thread src/routes/oauth.consent.tsx

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 60 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/components/ui/command.tsx Outdated
Comment thread src/features/mcp/mcp-cors.ts Outdated
Comment thread src/features/mcp/mcp-route.ts Outdated
Comment thread src/routes/oauth.consent.tsx Outdated
@capy-ai

capy-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Capy auto-review is paused for this organization because the usage-cycle auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 6 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 7 files (changes from recent commits).

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

initialContent: initialContent.content,
actorUserId: accessContext.actor.userId,
clientMutationId: accessContext.operationId,
const outcome = await workspaceContext.kernel.createItem({

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

React Doctor · react-doctor/async-await-in-loop (warning)

This makes the for…of loop slow because each await runs one after another, so collect the independent calls & run them together with await Promise.all(items.map(...))

Fix → Collect the items, then use await Promise.all(items.map(...)) so independent work runs at the same time

Docs

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Requires human review: Introduces database migrations, OAuth authentication, and new public MCP API endpoints; these require human review for security, schema, and operational tradeoffs.

Re-trigger cubic

@urjitc
urjitc merged commit c84d411 into main Jul 17, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Dev Board Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant