Skip to content

StdioClientTransport()Throw Error: spawn node ENOENT #277

@linzb93

Description

@linzb93

Describe the bug
StdioClientTransport()Throw Error: spawn node ENOENT。But when I change StdioClientTransport code in node_modules, it works.

To Reproduce

  1. I use amap-maps-mcp-server to create a map。https://www.npmjs.com/package/@amap/amap-maps-mcp-server
new StdioClientTransport({
    command: 'npx',
    "args": [
        "-y",
        "@amap/amap-maps-mcp-server"
    ],
    env: { AMAP_MAPS_API_KEY: '<my key>' }
})

When I run this code, it throw Error: spawn node ENOENT
2. I change code above to this code.

new StdioClientTransport({
    command: 'node',
    "args": [
        "./node_modules/@amap/amap-maps-mcp-server/build/index.js"
    ],
    env: { AMAP_MAPS_API_KEY: '<my key>' },
})

I run this code, it doesn't work.
3. I change StdioClientTransport code in node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js in startmethod。I change shell:false to shell:true
I run this code again, it works.
4. I keep StdioClientTransport class start method shell:true,and change command to npx。I run this code again, it doesn't works, throw error: env: node: No such file or directory

new StdioClientTransport({
    command: 'npx',
    "args": [
        "-y",
        "@amap/amap-maps-mcp-server"
    ],
    env: { AMAP_MAPS_API_KEY: '<my key>' }
})

Additional context
I use macOS Intel CPU.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions