Skip to content

MCP command, should have relative path support #1672

Closed

Description

@tzookb

Im trying to create a local mcp for our company, it would be living in our of our repos, and I want people to be able to use it from diff repos and folders.
Now they can easily define it manually, but I want to commit the config for everyone, so I want to use relative path.

Activity

  1. tzookb commented on Aug 7, 2025

    @tzookb
    Author

    /opencode

    I want to update the opencode codebase so that the "command" array for local MCP servers in the
    config file is resolved relative to the config file's directory, not the current working
    directory.

    Requirements:

    • When loading the MCP config, if the "command" array contains a relative path (e.g., ["node", ".
      /dist/main.js"]), resolve the script path relative to the directory of the config file that
      defined it.
    • If the command is already absolute, do not modify it.
    • If the command is ["node", "./dist/main.js"], resolve "./dist/main.js" relative to the config
      file directory, but leave "node" as-is.
    • This should work for any config file location, so that engineers can run opencode from any
      directory and the MCP command will always work.
    • Add a comment in the code explaining this behavior.
    • Add a test or example to verify that a config in a subdirectory with a relative MCP command
      works regardless of the working directory.

    Context:

    • The config loader code is in Config.state and related files.
    • The code that spawns the MCP local server uses the "command" array from the config.
    • You may need to pass the config file path or directory to the code that spawns the MCP server.

    Deliverables:

    • The code change(s) implementing this fix.
    • A brief explanation of the change.
    • A test or example demonstrating the new behavior.
  2. tzookb commented on Aug 7, 2025

    @tzookb
    Author

    tried my luck to let opencode do it for me

  3. thdxr commented on Aug 7, 2025

    @thdxr
    Member

    i'm reworking a lot of thigns related to this problem so will fix

  4. self-assigned this
    on Aug 7, 2025
  5. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

    [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions