An MCP server that allows you to run Node.js scripts and npm commands, with permission prompts via node-notifier
.
- Node.js >= 22.0.0
- Run Node.js scripts with arguments and standard input
- Execute npm scripts from package.json files with standard input
- Run JavaScript code directly with Node's eval and provide standard input
- View available npm scripts in package.json files
- Permission prompts before any execution (can be disabled)
- Clone this repository
- Install dependencies:
npm install
- Build the TypeScript code:
npm run build
src/index.ts
- Main MCP server implementationtest.js
- Sample test script to run with the server
- Build the project with
npm run build
- Add the server to your Claude for Desktop configuration:
{
"mcpServers": {
"node-runner": {
"command": "npx",
"args": ["-y", "mcp-node@latest"],
"env": {
"DISABLE_NOTIFICATIONS": "true", // Optional: disable permission prompts
"EVAL_DIRECTORIES": "/path/to/safe/dir1:/path/to/safe/dir2" // Optional: additional allowed eval directories
}
}
}
}
- Restart Claude for Desktop
- You can now ask Claude to run Node.js scripts or npm commands
- (Optional) Use the
env
configuration to disable notification prompts as shown above
Executes a Node.js script file.
Parameters:
scriptPath
: Path to the Node.js script to executenodeArgs
: (Optional) Arguments to pass to the Node.js executable itselfargs
: (Optional) Array of arguments to pass to the scriptstdin
: (Optional) Text to provide as standard input to the scriptcwd
: (Optional) Directory to run the script in (defaults to OS temp directory if not specified)
Example prompt: "Run the test.js script with arguments 'hello' and 'world'"
Example with working directory:
run-node-script({
scriptPath: "/absolute/path/to/my-script.js",
args: ["arg1", "arg2"],
cwd: "/absolute/path/to/project"
});
Executes an npm script from a package.json file.
Parameters:
packageDir
: Directory containing the package.jsonscriptName
: Name of the script to runargs
: (Optional) Array of arguments to pass to the scriptstdin
: (Optional) Text to provide as standard input to the script
Example prompt: "Run the 'start' script from the package.json in the current directory"
Executes JavaScript code directly.
Parameters:
code
: JavaScript code to executeevalDirectory
: (Optional) Directory to execute the code instdin
: (Optional) Text to provide as standard input to the code
Example prompt: "Run this JavaScript code: console.log('Hello world');"
// Example script: process-data.js
process.stdin.on('data', (data) => {
const input = data.toString().trim();
console.log(`Received: ${input}`);
// Process the input...
});
You can execute this with standard input and a specific working directory:
run-node-script({
scriptPath: "/absolute/path/to/process-data.js",
stdin: "This is input data",
cwd: "/absolute/path/to/my-project-directory" // Sets the working directory for the script
});
run-node-eval({
code: `
let data = '';
process.stdin.on('data', (chunk) => { data += chunk; });
process.stdin.on('end', () => {
console.log('Received:', data);
});
`,
stdin: "Data to process"
});
// First read the file
const fileContent = read_file({ path: "/absolute/path/to/data.txt" });
// Then pass it as standard input to a script
run-node-script({
scriptPath: "/absolute/path/to/process-data.js",
stdin: fileContent,
cwd: "/absolute/path/to/working-directory"
});
Displays information about the Node.js environment running the MCP server.
URI template: node-version://info
Example prompt: "What version of Node.js is being used to run the scripts?"
Lists all available npm scripts in a package.json file.
URI template: npm-scripts://{directory}
Example prompt: "Show me the available npm scripts in this project"
- The server will always prompt for permission before executing any command
- Scripts run with the same permissions as the MCP server process
- Be cautious when running scripts from untrusted sources
Set DISABLE_NOTIFICATIONS=true
to automatically approve all permission requests without showing notification prompts:
# Run with notifications disabled
DISABLE_NOTIFICATIONS=true npm run dev
This is useful for automation scenarios or when you don't want to be prompted for each action.
Specify a colon-separated list of directories where JavaScript code can be evaluated using the run-node-eval
tool:
# Allow code evaluation in specific directories
EVAL_DIRECTORIES=/path/to/dir1:/path/to/dir2 npm run dev
By default, only the system temporary directory is allowed. This environment variable lets you add additional safe directories.
MIT