Skip to content

directory parameter rejects valid absolute paths with "is not an absolute path" error #13

@MekaretEriker

Description

@MekaretEriker

Description

When passing a valid absolute path to the directory parameter of opencode_run, opencode_ask, or opencode_fire, the validation rejects it with the error below — even when the path IS absolute and points to an existing directory.
Error: Invalid directory: "/mnt/d/Projects/opencode-agent" is not an absolute path.
Suggestions:

The directory parameter must be an absolute path to an existing directory
Example: /home/user/my-project (not ./my-project or ~/my-project)

/mnt/d/Projects/opencode-agent is absolute (starts with /) and refers to an existing, readable directory containing a valid project.

Environment

  • opencode-mcp : 1.10.1 (also reproduced via npx -y opencode-mcp@^1.10.1)
  • opencode server : 1.14.48 (healthy)
  • MCP client : Claude Cowork (Anthropic desktop app), but reproducible from any MCP client
  • Host OS : Windows
  • opencode serve runs in : WSL2 (Ubuntu)

Steps to reproduce

  1. Have opencode serve running in WSL with a working directory like /mnt/d/Projects/SomeProjectA.
  2. Create another directory at /mnt/d/Projects/SomeProjectB (with or without .git).
  3. From any MCP client, call:
{
  "method": "opencode_run",
  "params": {
    "prompt": "git status",
    "directory": "/mnt/d/Projects/SomeProjectB",
    "agent": "build"
  }
}
  1. Observe the error above. Same behavior with opencode_ask and opencode_fire.

Expected

The directory parameter should accept any absolute path to an existing directory and switch the request's project context accordingly.

Workaround currently in use

Omit the directory parameter and prefix the prompt with an explicit cd:

{
  "prompt": "cd /mnt/d/Projects/SomeProjectB && git status",
  "agent": "build"
}

This works reliably but moves the context-switching responsibility from the MCP transport to the model/shell layer.

Hypothesis

The error message wording (mentioning ~/path and ./relative) suggests the validator was designed to reject those forms — but it appears to incorrectly trigger on valid absolute paths under WSL (/mnt/d/...) or when the target path differs from the opencode server's current working directory. Possibly a regex or path.isAbsolute()-style check that misfires.

Glancing at src/ would be useful — the check is likely in the params-validation layer for the workflow tools.

Why this matters

For MCP clients orchestrating multi-project workflows (delegating tasks across several repos), directory is the natural way to target a specific project per call. The cd workaround pollutes the prompt and isn't transparent for downstream tooling that inspects raw prompts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions