Skip to content

feat(opencode): support cwd on local MCP servers#30676

Merged
rekram1-node merged 8 commits into
anomalyco:devfrom
Grantmartin2002:feat/mcp-local-cwd
Jun 11, 2026
Merged

feat(opencode): support cwd on local MCP servers#30676
rekram1-node merged 8 commits into
anomalyco:devfrom
Grantmartin2002:feat/mcp-local-cwd

Conversation

@Grantmartin2002

@Grantmartin2002 Grantmartin2002 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #30677

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds an optional cwd to local MCP server config. Lets a server spawn from a subdir of the workspace without hardcoded absolute paths. Relative resolves against the workspace dir, absolute passes through, omitting keeps current behavior.

Also covers one of the suggested fixes in #18805 (root cause there is a Web UI bug so this PR doesn't fully close it):

Add a cwd option to the McpLocal schema so users can specify a fixed working directory for MCP processes

How did you verify your code works?

Three tests in lifecycle.test.ts for omitted/relative/absolute cwd. Full file (24/24) passes, pre-push bun turbo typecheck clean across all packages.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add an optional `cwd` field to the local MCP server config. When set, the
spawned process uses `path.resolve(InstanceState.directory, mcp.cwd)` as
its working directory instead of the instance directory.

Addresses suggested fix anomalyco#4 of anomalyco#18805.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 4, 2026
@Grantmartin2002 Grantmartin2002 marked this pull request as draft June 4, 2026 04:06
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node

Copy link
Copy Markdown
Collaborator

This follows the configuration exposed by other coding agents such as Codex, which supports a per-server mcp_servers.<id>.cwd for stdio MCP processes: https://developers.openai.com/codex/mcp/#stdio-servers. I also updated both OpenCode config schemas to document workspace-relative resolution and reduced the lifecycle coverage to one focused relative-path test.

# Conflicts:
#	packages/opencode/src/mcp/index.ts
@Grantmartin2002 Grantmartin2002 marked this pull request as ready for review June 11, 2026 20:43
@rekram1-node rekram1-node merged commit 7e7ad37 into anomalyco:dev Jun 11, 2026
7 of 8 checks passed
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.

[FEATURE]: add cwd field to local MCP server config

2 participants