Skip to content

Add project scoping support#100

Merged
masnwilliams merged 2 commits intomainfrom
hypeship/mcp-project-support
Apr 28, 2026
Merged

Add project scoping support#100
masnwilliams merged 2 commits intomainfrom
hypeship/mcp-project-support

Conversation

@masnwilliams
Copy link
Copy Markdown
Collaborator

@masnwilliams masnwilliams commented Apr 17, 2026

Adds server-side project scoping for the MCP server.

What changed

createKernelClient() now reads KERNEL_PROJECT from env vars and, when set, injects the X-Kernel-Project-Id header into all SDK requests.

Scope

This is server-side env-var scoping — the deployment is pinned to one project for every user that connects. Useful for self-hosted MCP deployments where the operator wants every connecting user/agent locked to a single project.

For the hosted mcp.onkernel.com (multi-tenant), this env var is not the right knob — it would scope every user of the hosted deployment to the same project. For per-user project scoping on hosted MCP, use either:

  • A project-scoped API key as the bearer token — works today, no header needed (the server resolves scope from the key).
  • Once OAuth project scoping ships (Neil), the Clerk OAuth token will carry the user's selected project.

Notes

  • Reads KERNEL_PROJECT only. KERNEL_PROJECT_ID was never shipped, so there's no legacy fallback to preserve.
  • If KERNEL_PROJECT is not set, no header is sent (backwards compatible).

Related

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.

@masnwilliams masnwilliams requested a review from hiroTamada April 28, 2026 03:08
@masnwilliams masnwilliams merged commit 2f60210 into main Apr 28, 2026
8 checks passed
@masnwilliams masnwilliams deleted the hypeship/mcp-project-support branch April 28, 2026 15:02
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.

2 participants