Skip to content

Unable to set up usage of npm run <command> as a tool #262

@cbarrerah

Description

@cbarrerah

Hi,

First of all, the project is amazing and super useful, so keep up the good work ^.^

I managed to get the claude desktop app talking with the codemcp server and being able to manage files without resorting to the filesystem mcp server and doing an amazing job at helping to manage the coverage improvements in an easy and useful way. But I was thinking that if the codemcp server was able to actually run the tests being implemented to check the execution results, or running the coverage command to actually see the improvements, it would enable for a more autonomous agent behavior.

I have setup some npm run scripts in my package.json file (typescript project using npm) so I am able to execute in the terminal in the root of the project both "npm run test" and "npm run coverage" and it gets the tests running, or the coverage reported in the cli. So I was expecting that by making those commands available as tools to the codemcp server, it would work. I defined the tools as:

[commands]
npm =["/Users/username/.nvm/versions/node/v18.16.0/bin/npm"]
prettier = ["npm", "run", "lint"]
lint = ["npm","run", "prettier" ]
coverage = ["npm", "run", "coverage"]
test = ["npm", "run", "test"]

But when asked about coverage it tries to use the coverage command, but errors out

Error: Error during npm: Command failed with exit code 1: npm run coverage
Stdout:

appName@1.6.31 coverage
vitest run --config ./vitest.config.ts --coverage

Stderr:
⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: crypto$2.getRandomValues is not a function
at resolveConfig (file:///Users//dev/webdev/appName/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:54232:16)
at async _createServer (file:///Users//dev/webdev/appName/node_modules/vite/dist/node/chunks/dep-ByPKlqZ5.js:43841:18)
at async createViteServer (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cli-api.BZbq1zTX.js:10310:18)
at async createVitest (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cli-api.BZbq1zTX.js:13530:18)
at async prepareVitest (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cli-api.BZbq1zTX.js:13949:15)
at async startVitest (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cli-api.BZbq1zTX.js:13880:15)
at async start (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cac.87F_onld.js:1571:17)
at async CAC.run (file:///Users//dev/webdev/appName/node_modules/vitest/dist/chunks/cac.87F_onld.js:1542:3)

View result from codemcp from codemcp (local)

What am I doing wrong to configure the right command to be executed and available? Is there a different environment being set up when codemcp is running the command, and if so how could I configure it properly?

Thanks :)

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