Repository navigation
fix(mcp): read string commands from opencode.json and pass environment on first connect - #4552
Merged
Merged
Conversation
…t on first connect Users who paste a Claude Desktop or Cursor style server into opencode.json (command: "python3", args: [...]) got a blank Settings page, because every reader assumed command was already an array. The parser now reads both shapes into one command list so the server appears in the list and can be edited or removed. Connecting a local MCP without the OpenWork server forwarded the command but not its resolved environment to the hot-add call that actually spawns the process, so a server that needs an environment variable failed on its first connect and only worked after an engine restart. The hot-add config now carries the same environment that is written to the file.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (bd4911b7a89fcb92001dd7f0e3eb6652c9231590). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
…er command shape A person who copies a server from Claude Desktop or Cursor writes command: "python3", args: [...] into opencode.json. The journey writes that entry beside an array-command server and a remote server, opens Settings -> Library -> MCPs, and asserts all three are listed, the page stayed rendered, and Technical details shows the folded command line.
Contributor
There was a problem hiding this comment.
Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (b1237658d53ec93eb70fc29e0cb9c8a238df6ebd). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two ways a local MCP breaks the first time someone uses it:
command: "python3", args: ["server.py"]. OpenWork readcommandas if it were already an array, so the Settings route threw inside render and the whole page went white (Settings page renders blank/white when a local MCP server uses stringcommand(config.command?.some is not a function) #3372, [Bug]: Windows: hardthrowin getComputerUseMcpCommand() crashes desktop renderer (blank screen) on 0.17.30 and 0.17.32 #2908). The user cannot even reach the list to fix or remove the entry.Change
apps/app/src/app/mcp.ts:parseMcpServersFromContentnormalizes a stringcommandplus optionalargsinto one command list. Array commands and remote entries pass through unchanged; an empty string command is dropped rather than spawned. Every downstream reader (Settings, the connections store, the MCP view) sees one shape.apps/app/src/react-app/domains/connections/store.ts: the local hot-add config forwardsenvironmentthe same way the remote branch already forwardsheadersandoauth.Verification
pnpm --filter @openwork/app typecheck— passed.bun test --isolate tests/mcp-oauth-status-synchronization.test.ts(apps/app) — 14 passed, 0 failed (3 new: string command with args becomes one list; array and remote entries unchanged and unknown types dropped; empty string command dropped).Verdict: Incomplete
No
evals/specsjourney seeds a workspaceopencode.jsonwith a local MCP and opens Settings → Connections, so the blank-page recovery is proven at the parser boundary only. Missing: an app journey that seeds a string-command entry and asserts the Settings page lists it. Manual repro: add"docs": { "type": "local", "command": "python3", "args": ["-m", "http.server"] }undermcpin a workspace'sopencode.json, open Settings → Connections, and confirm the page renders with the entry listed.