Skip to content

Add project scoping support#100

Open
masnwilliams wants to merge 2 commits intomainfrom
hypeship/mcp-project-support
Open

Add project scoping support#100
masnwilliams wants to merge 2 commits intomainfrom
hypeship/mcp-project-support

Conversation

@masnwilliams
Copy link
Copy Markdown
Collaborator

@masnwilliams masnwilliams commented Apr 17, 2026

Adds support for project-scoped API requests in the MCP server.

What changed

createKernelClient() now reads KERNEL_PROJECT or KERNEL_PROJECT_ID env vars and injects the X-Kernel-Project-Id header into all SDK requests. This allows org-scoped API keys to target a specific project, matching the approach used in the CLI and dashboard.

How it works

  • KERNEL_PROJECT takes priority over KERNEL_PROJECT_ID (same as CLI)
  • If neither env var is set, no header is sent (backwards compatible)
  • All 14 call sites use createKernelClient() so no call-site changes needed

Related


Note

Medium Risk
Adds an optional X-Kernel-Project-Id header to all Kernel SDK calls when KERNEL_PROJECT is set, which could change which project data is accessed for org-scoped API keys.

Overview
Adds project scoping to outbound Kernel SDK requests by building defaultHeaders in createKernelClient() and conditionally injecting X-Kernel-Project-Id from process.env.KERNEL_PROJECT.

When the env var is unset, requests remain unchanged (existing X-Source/X-Referral-Source headers only).

Reviewed by Cursor Bugbot for commit 8a7abb7. Bugbot is set up for automated code reviews on this repo. Configure here.

Read KERNEL_PROJECT or KERNEL_PROJECT_ID env var and inject the
X-Kernel-Project-Id header into all SDK requests. This mirrors the
CLI approach and allows org-scoped API keys to target a specific
project.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 17, 2026

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

Project Deployment Actions Updated (UTC)
mcp Ready Ready Preview, Comment Apr 23, 2026 8:59pm
mcp (staging) Ready Ready Preview, Comment Apr 23, 2026 8:59pm

@masnwilliams masnwilliams marked this pull request as ready for review April 17, 2026 16:32
@firetiger-agent
Copy link
Copy Markdown

Firetiger deploy monitoring skipped

This PR didn't match the auto-monitor filter configured on your GitHub connection:

Any PR that changes the kernel API. Monitor changes to API endpoints (packages/api/cmd/api/) and Temporal workflows (packages/api/lib/temporal) in the kernel repo

Reason: PR modifies the MCP server client setup, not the kernel API endpoints (packages/api/cmd/api/) or Temporal workflows (packages/api/lib/temporal) specified in the filter.

To monitor this PR anyway, reply with @firetiger monitor this.

Projects is a brand new feature — KERNEL_PROJECT_ID was never in
production, so there's no legacy to preserve. Only read KERNEL_PROJECT.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8a7abb7. Configure here.

const projectId = process.env.KERNEL_PROJECT;
if (projectId) {
headers["X-Kernel-Project-Id"] = projectId;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing KERNEL_PROJECT_ID environment variable fallback

High Severity

The PR description states that KERNEL_PROJECT takes priority over KERNEL_PROJECT_ID, matching the CLI behavior. However, the implementation only reads process.env.KERNEL_PROJECT and never falls back to process.env.KERNEL_PROJECT_ID. Users who configure project scoping via KERNEL_PROJECT_ID (instead of KERNEL_PROJECT) will silently get no project scoping applied to their requests, which could lead to API calls hitting the wrong project scope.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8a7abb7. Configure here.

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