A Javascript code execution sandbox that uses v8 to isolate code to run AI generated javascript locally without fear. Supports heap snapshotting for persistent sessions.
A Rust-based Model Context Protocol (MCP) server that exposes a V8 JavaScript runtime as a tool for AI agents like Claude and Cursor. Supports persistent heap snapshots via S3 or local filesystem, and is ready for integration with modern AI development environments.
Install mcp-v8 using the provided install script:
curl -fsSL https://raw.githubusercontent.com/r33drichards/mcp-js/main/install.sh | sudo bash
This will automatically download and install the latest release for your platform to /usr/local/bin/mcp-v8 (you may be prompted for your password).
Advanced users: If you prefer to build from source, see the Build from Source section at the end of this document.
mcp-v8 supports the following command line arguments:
--s3-bucket <bucket>: Use AWS S3 for heap snapshots. Specify the S3 bucket name. (Conflicts with --directory-path)--directory-path <path>: Use a local directory for heap snapshots. Specify the directory path. (Conflicts with --s3-bucket)Note: You must specify either --s3-bucket or --directory-path. If neither is provided, the server defaults to S3 with the bucket name test-mcp-js-bucket.
After installation, you can run the server directly. Choose one of the following options:
# Use S3 for heap storage (recommended for cloud/persistent use)
mcp-v8 --s3-bucket my-bucket-name
# Use local filesystem directory for heap storage (recommended for local development)
mcp-v8 --directory-path /tmp/mcp-v8-heaps
claude_desktop_config.json:{
"mcpServers": {
"js": {
"command": "/usr/local/bin/mcp-v8 --s3-bucket my-bucket-name"
}
}
}
.cursor/mcp.json in your project root:{
"mcpServers": {
"js": {
"command": "/usr/local/bin/mcp-v8 --directory-path /tmp/mcp-v8-heaps"
}
}
}
1 + 2"You can configure heap storage using the following command line arguments:
--s3-bucket <bucket>
mcp-v8 --s3-bucket my-bucket-name--directory-path <path>
mcp-v8 --directory-path /tmp/mcp-v8-heapsNote: Only one storage backend can be used at a time. If both are provided, the server will return an error.
While mcp-v8 provides a powerful and persistent JavaScript execution environment, there are limitations to its runtime.
async/await or Promises: Asynchronous JavaScript is not supported. All code must be synchronous.fetch or network access: There is no built-in way to make HTTP requests or access the network.console.log or standard output: Output from console.log or similar functions will not appear. To return results, ensure the value you want is the last line of your code.npm install or external packages: You cannot install or import npm packages. Only standard JavaScript (ECMAScript) built-ins are available.setTimeout and setInterval are not available.window, document, or other browser-specific objects.If you prefer to build from source instead of using the install script:
cd server
cargo build --release
The built binary will be located at server/target/release/server. You can use this path in the integration steps above instead of /usr/local/bin/mcp-v8 if desired.