Surface HTTP MCP bearer header for opencode on --foreground (part of #1120)#1141
Surface HTTP MCP bearer header for opencode on --foreground (part of #1120)#1141RhysSullivan wants to merge 1 commit into
Conversation
…round The local /mcp endpoint is bearer-gated and exposes no OAuth discovery, so an external client that auto-detects OAuth (opencode) just chokes on a plain 401 with no way to find the token. The --foreground ready output now prints the exact Authorization: Bearer header plus a copy-pasteable opencode.json block that pins `oauth: false` so the client sends the header instead of probing for an authorization server. Adds an e2e scenario (http-mcp-bearer) asserting /mcp works with the bearer header and 401s without it.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | 33edb90 | Commit Preview URL Branch Preview URL |
Jun 26 2026, 05:39 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-cloud | 33edb90 | Jun 26 2026, 05:40 AM |
Cloudflare preview
Sign-in is Cloudflare Access (one-time PIN to an allowed email). The preview has its own database and encryption key; it is destroyed when this PR closes. |
@executor-js/cli
@executor-js/config
@executor-js/execution
@executor-js/sdk
@executor-js/codemode-core
@executor-js/runtime-quickjs
@executor-js/plugin-file-secrets
@executor-js/plugin-graphql
@executor-js/plugin-keychain
@executor-js/plugin-mcp
@executor-js/plugin-onepassword
@executor-js/plugin-openapi
executor
commit: |
| // to discover the token (there is no OAuth server on the local app, so a | ||
| // client that tries OAuth auto-detection just errors). Surface the exact | ||
| // header — and a ready opencode block that pins `oauth: false` so it sends | ||
| // the header instead of probing for an authorization server. |
There was a problem hiding this comment.
Em-dash in code comment. AGENTS.md explicitly prohibits the
— character anywhere, including code comments: "Never use em-dashes anywhere: prose, docs, code comments, commit messages, or PRs. Use commas, colons, parentheses, or separate sentences instead." The same violation appears in e2e/local/http-mcp-bearer.test.ts line 1 (// Local-only — REPRO + guard). Replace both with a comma, colon, or parenthetical.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| // Local-only — REPRO + guard for "I've been running executor as stdio as get | ||
| // errors trying http one in opencode". The local app's HTTP `/mcp` endpoint is | ||
| // bearer-gated (hardened so loopback is not a free pass) and serves NO OAuth | ||
| // discovery. An external agent like opencode, pointed at the URL, tries MCP | ||
| // OAuth auto-detection, gets a plain `401 Bearer realm="executor"` with no | ||
| // resource-metadata to discover an authorization server from, and errors out. | ||
| // | ||
| // The HTTP transport itself is fine — it works the moment the bearer is supplied | ||
| // (opencode's remote MCP supports `headers` + `oauth: false`). This scenario | ||
| // proves exactly that: tools list over HTTP WITH the bearer, and the gate 401s | ||
| // WITHOUT it. It also asserts the `--foreground` ready output now prints a | ||
| // ready-to-paste opencode config (URL + bearer header + `oauth: false`) so a | ||
| // user does not have to reverse-engineer the gate. | ||
| import { expect } from "@effect/vitest"; |
There was a problem hiding this comment.
Test comment overstates coverage. Line 13 says "It also asserts the
--foreground ready output now prints a ready-to-paste opencode config (URL + bearer header + oauth: false)". The actual test body never checks the terminal snapshot for this output, so the assertion described in the comment does not exist. Per e2e/AGENTS.md, the test source is the review artifact; a reader should be able to trust comments as a spec. The withLocalServer helper does expose the full terminal text in snapshot, so the check is addable, but as written the comment is misleading.
Context Used: e2e/AGENTS.md (source)
Part of #1120 (4 of 4). Independent of the other three.
Problem
The local
/mcpendpoint is bearer-gated and exposes no OAuth discovery, so an external client that auto-detects OAuth (opencode) just chokes on a plain 401 with no way to find the token.Fix
The
--foregroundready output now prints the exactAuthorization: Bearerheader plus a copy-pasteableopencode.jsonblock that pinsoauth: false, so the client sends the header instead of probing for an authorization server.Tests
Adds an e2e scenario (
http-mcp-bearer) asserting/mcpworks with the bearer header and 401s without it (lint 0/0, typecheck 41/41).