Skip to content

feat(mcp): add HTTP Code Mode with explicit API permissions - #1670

Draft
betegon wants to merge 5 commits into
mainfrom
bt/code-mode-http
Draft

betegon wants to merge 5 commits into
mainfrom
bt/code-mode-http

Conversation

@betegon

@betegon betegon commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Code Mode is the MCP equivalent of sentry api: agents can use published API operations without a dedicated MCP tool.
The client's agent writes JavaScript; our Cloudflare sandbox executes authenticated HTTP calls and returns the result.

For example: “Copy this dashboard for two projects, preserving its widgets and filters.” The existing tool catalog cannot do this; Code Mode can.

search_sentry_api discovers the schema and execute_sentry_code runs the program. This version is HTTP-only; the SDK remains future work.

Server-side Code Mode over standard MCP: the client sends code through tools/call, Sentry executes it in a Cloudflare sandbox, and only the selected result returns to the model.

Prerequisite #1676 is merged. Stack: this PR → #1675 (agent evals). Runtime and permission safety tests remain here.

Code Mode architecture: generated code calls an RPC broker in the parent Worker; the token stays outside the sandbox.

Permissions

The Sentry token authenticates API calls; its OAuth scopes and the user's Sentry permissions set the maximum access.
The permission screen controls which of those actions this MCP connection may perform, without changing the token or its scopes.

  • API Read permits reads. API Write includes reads and enables create/update/delete. It starts unchecked; explicitly remembered selections are preserved.
  • Permissions are additive: API Write can modify issues even with Triage Issues unchecked, and projects/teams with Manage Projects & Teams unchecked. The consent screen explains this before approval.
  • The screen shows the scope: /mcp covers organizations authorized by the Sentry token; /mcp/{org} is restricted to that organization. Project-scoped connections do not expose Code Mode.
  • Existing grants gain no new permissions. Shared upstream OAuth scopes stay unchanged; the broker checks the MCP grant on every call, and Sentry still enforces token, role and resource permissions. Credentials stay outside generated code.
Sentry MCP permissions: organization scope, API Write unchecked, and additive permissions warning

Validation and before production

Executions now close pending RPC, abort in-flight HTTP and block requests whose authorization finishes after execution ends. Programs must await API calls before returning; accepted writes cannot be rolled back. See the lifecycle validation.

Passed locally: 474 hosted Cloudflare tests + 27 isolated runtime/access tests, 1,836 core tests (six skipped), 89 stdio tests, build/typechecks, lint and documentation links. Coverage includes a real 30-second timeout that closes the upstream connection while preserving an accepted write.

Pending before production: real hosted OAuth-to-API authorization and Cloudflare CPU/termination/concurrency enforcement. Local workerd tests do not establish these platform guarantees. No production deployment performed. GitHub CI now passes the complete workspace suite, including CLI, plus smoke tests, repository quality and security checks on 645c16d2. Warden code review, MCP audit and security review also pass, with no new findings. No CLI fixes were included.

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
sentry-local Ready Ready Preview Oct 27, 2026 5:13pm UTC

Request Review

Comment thread packages/mcp-cloudflare/src/code-mode/worker.test.ts Fixed
Comment thread packages/mcp-cloudflare/src/code-mode/worker.ts Outdated
Comment thread packages/mcp-core/src/server.ts
Comment thread packages/mcp-cloudflare/src/code-mode/http.ts
Comment thread packages/mcp-cloudflare/src/server/lib/mcp-handler.ts
Comment thread packages/mcp-cloudflare/src/code-mode/worker.test.ts
@betegon
betegon changed the base branch from main to bt/cloudflare-test-runtime October 27, 2026 10:32
@betegon
betegon force-pushed the bt/cloudflare-test-runtime branch from 7fb178a to 49d10be Compare October 27, 2026 13:28
betegon added a commit that referenced this pull request Oct 27, 2026
The Cloudflare test plugin still used an older Miniflare/workerd than
Wrangler, so updating the direct dependency alone left different
runtimes in local and integration tests.

Switch to `@cloudflare/vitest-plugin` 1.4.6 and align Miniflare/workerd
with Wrangler. Miniflare 5 removed `fetchMock`; an Undici outbound
service preserves the existing fixtures and `disableNetConnect()`
policy.

This is the prerequisite for #1670 (HTTP Code Mode), followed by #1675
(agent evals). Only seven test/dependency files move here; the broker,
permissions and production integration remain in #1670.

Validated independently on Node 24: **443 Cloudflare tests across 34
files**, root typechecks, lint and frozen install. The earlier full
workspace run had unrelated CLI fixture/platform failures; CLI fixes are
excluded. No deployment performed.
Base automatically changed from bt/cloudflare-test-runtime to main October 27, 2026 13:42
Bound broker access and HTTP work to one execution so unawaited calls and late authorization cannot start writes after the result. Cover cleanup and the real deadline with Worker integration tests.

This branch was successfully deployed

1 active and 1 inactive (outdated) deployments
Preview — 645c16d2 Deployed Oct 27, 2026 by vercel[bot]
Actions — 2718d905 Deployed Oct 26, 2026 by betegon via eval #1365
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