Skip to content

toolcraft MCP proxy cache path depends on caller cwd #237

@kamilio

Description

@kamilio

Summary

Toolcraft MCP proxy cache files are currently resolved from process.cwd() by walking upward to the nearest package.json and writing .toolcraft/mcp/*.json there.

This makes cache placement depend on where the CLI is invoked from, not where the Toolcraft CLI entrypoint/package lives.

Why this is surprising

A CLI package can be run from different working directories, for example:

node path/to/my-cli/bin/cli.mjs --help

In that case, Toolcraft may write cache files into the caller's current project instead of alongside the CLI package that defines the MCP proxy groups.

Expected

MCP proxy cache location should be stable for a CLI package, independent of caller cwd.

Possible options:

  • Resolve cache relative to the Toolcraft root/group source package.
  • Allow runCLI(..., { projectRoot }) or MCP proxy config to specify cache root.
  • Respect an explicit env var such as TOOLCRAFT_PROJECT_ROOT or TOOLCRAFT_MCP_CACHE_DIR.

Current workaround

CLI authors can call process.chdir(...) before runCLI, but that is surprising and can affect user code that expects cwd to remain the caller's directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions