JavaScript MCP Server

JavaScript MCP Server

A server that enables AI assistants to execute JavaScript code with persistent context through stateful REPL sessions, file operations, and package management features.

Category
Visit Server

README

JavaScript MCP Server (js-mcp)

A Model Context Protocol (MCP) server that allows AI assistants to execute JavaScript code with stateful REPL sessions.

Features

Core Features

  • One-time JavaScript Execution: Execute JavaScript code directly in Node.js
  • Stateful REPL Sessions: Maintain variables and context across multiple executions
  • File System Operations: Read, write, and manipulate files
  • Package Management: Import modules and manage npm packages

Advanced Features

  • Secure sandboxed execution
  • Asynchronous code support
  • Error handling with formatted stack traces
  • Session management with automatic cleanup

Installation

# Clone the repository
git clone https://github.com/yourusername/js-mcp.git
cd js-mcp

# Install dependencies
npm install

# Build the project
npm run build

Usage

Run with stdio transport (for use with Claude Desktop)

npm start
# or
node dist/index.js --stdio

Run with HTTP transport

node dist/index.js --http
# Default port is 3000, or specify with PORT environment variable
PORT=3456 node dist/index.js --http

Available Tools

JavaScript Execution

  • execute_javascript: Run JavaScript code in a basic sandbox
  • execute_javascript_with_modules: Run JavaScript with module imports
  • execute_javascript_async: Run asynchronous JavaScript code

REPL Sessions

  • repl_create_session: Create a new REPL session
  • repl_execute: Execute code in a REPL session
  • repl_get_context: Get variable values in a session
  • repl_delete_session: Delete a session
  • repl_list_sessions: List all active sessions

File Operations

  • file_read: Read file contents
  • file_write: Write content to a file
  • file_list: List files in a directory
  • file_delete: Delete a file or directory
  • file_exists: Check if a file exists

Package Management

  • package_check: Check if a module is available
  • package_install: Install an npm package
  • package_list: List installed packages

Security

The server uses direct JavaScript execution with safety features:

  • Timeout limits for code execution
  • File system access limited to working directory
  • Path validation to prevent dangerous operations

Configuration

Configure the server by setting environment variables:

  • PORT: HTTP server port (default: 3000)
  • WORKING_DIRECTORY: Base directory for file operations (default: current directory)
  • SESSION_TIMEOUT: REPL session timeout in minutes (default: 30)

Development

# Start in development mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

# Format code
npm run format

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured