GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): expand ~ in a local MCP server's cwd by rekram1-node · Pull Request #61496 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

A local MCP server's cwd didn't expand ~. The spawn path did path.resolve(directory, config.cwd), so "cwd": "~/tools" ended up as <project>/~/tools and "cwd": "~" as <project>/~.

Change

  • I added McpStdio.resolveCwd(directory, cwd) in packages/core/src/mcp/stdio.ts. It reuses FileAccess.resolvePath, the same ~ / ~/ / ~\ (Windows) expansion the shell and patch tools already use. ~user is left alone. The client now calls it, and anything else that spawns a stdio server can use the same function.
  • ~ means the home of the machine running opencode. Environments don't expose their own home, and the shell tool already behaves this way for workspace locations, so I kept it consistent and wrote that down.

Verification

  • New test in packages/core/test/mcp-stdio.test.ts covers ~, ~/tools, a relative path, an absolute path and an unset cwd. It fails on ~ with the old expression.
  • bun run typecheck, bun run typecheck:tsc and test/mcp* in packages/core, and bun run check from the root.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" font-family="ui-monospace,Menlo,monospace" font-size="12">
  <style>
    .bad{animation:bad 4s ease-in-out infinite;opacity:0}
    .good{animation:good 4s ease-in-out infinite}
    .arrow{animation:good 4s ease-in-out infinite}
    @keyframes bad{0%,35%{opacity:.55}50%,100%{opacity:0}}
    @keyframes good{0%,40%{opacity:0}55%,95%{opacity:1}100%{opacity:0}}
    @media (prefers-reduced-motion:reduce){.bad,.good,.arrow{animation:none}.bad{opacity:0}.good,.arrow{opacity:1}}
  </style>
  <rect x="1" y="1" width="238" height="70" rx="10" stroke="currentColor" stroke-opacity=".2"/>
  <text x="16" y="26" fill="currentColor" fill-opacity=".5">cwd: "~/tools"</text>
  <g class="bad">
    <text x="16" y="52" fill="currentColor">&lt;project&gt;/~/tools</text>
    <path d="M14 47h138" stroke="currentColor" stroke-width="1.5"/>
  </g>
  <g class="good">
    <path class="arrow" d="M16 48h14m-4-4 4 4-4 4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
    <path d="M40 54v-7l7-6 7 6v7z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
    <text x="64" y="52" fill="currentColor">$HOME/tools</text>
  </g>
</svg>

Added by the opencode bot (AI-generated).

Public API: local MCP cwd config now expands a leading ~ to the home directory (backwards compatible apart from a directory literally named ~ in the project)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): expand ~ in a local MCP server's cwd
cda52a8
@github-actions github-actions Bot added the contributor label Nov 3, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 3, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change looks sound. I ran the real MCP client connect path with cwd: "~/mcptools". On the base the server spawned in <workspace>/~/mcptools and the connection failed with NotFound. With this PR it spawns in $HOME/mcptools and connects. The MCP tests pass, except one descendant-termination test that also fails on the base. typecheck:tsc in core and tsc in schema both pass.

Public API: the config key is unchanged. Only the meaning of a cwd value starting with ~ / ~/ changes. Before, it pointed to a ~ directory inside the workspace; now it points to the home directory. This is backwards compatible, except for a config that really means a directory literally named ~ inside the project. That edge case is unlikely, and such a config can switch to ./~.

No concerns.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
revert schema and docs changes
e757e1a
@rekram1-node
rekram1-node merged commit 922994a into dev Nov 3, 2026
15 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the mcp-cwd-home branch November 3, 2026 23:52
@devin-ai-integration devin-ai-integration Bot mentioned this pull request Nov 4, 2026
upstream: provider/security fixes not yet ported AltimateAI/altimate-code#1478
Open
29 of 90 tasks
@amrkmn amrkmn mentioned this pull request Nov 7, 2026
opencode 2.2.6 amrkmn/homebrew-tap#1217
Closed
1 task
This was referenced Nov 7, 2026
feat: opencode release v2.2.6 sprisa/opencode-server#84
Merged
Tool release: OpenCode 2 v2.2.6 (was v2.2.5) agent-sh/agnix#1808
Closed
@teknium1 teknium1 mentioned this pull request Nov 13, 2026
MCP servers configured with cwd: ~/dir start instead of failing with 'missing executable' (port opencode#61496) NousResearch/hermes-agent#154766
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.