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.
Summary
Toolcraft MCP proxy cache files are currently resolved from
process.cwd()by walking upward to the nearestpackage.jsonand writing.toolcraft/mcp/*.jsonthere.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:
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:
runCLI(..., { projectRoot })or MCP proxy config to specify cache root.TOOLCRAFT_PROJECT_ROOTorTOOLCRAFT_MCP_CACHE_DIR.Current workaround
CLI authors can call
process.chdir(...)beforerunCLI, but that is surprising and can affect user code that expects cwd to remain the caller's directory.