Fresh JavaScript MCP server

Provides a stateful REPL interface for executing JavaScript and TypeScript code with session management, NPM package installation, and source mapping capabilities
Back to servers
Setup instructions
Provider
yannbam
Release date
Mar 25, 2025
Language
TypeScript

This JavaScript MCP Server provides a robust environment for AI models to execute JavaScript code through the Model Context Protocol (MCP). The server supports various execution modes including one-time script execution, stateful REPL sessions, and TypeScript support.

Installation

To get started with the JavaScript MCP Server, follow these steps:

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

# Install dependencies
npm install

# Build the project
npm run build

Usage Options

The server can be started in different modes depending on your needs:

# Start the MCP server in standard mode
npm start

# Start in interactive REPL mode
node dist/index.js --interactive

# Start with named pipe interface
node dist/index.js --pipe

# See all options
node dist/index.js --help

Operating Modes

Standard MCP Mode

This is the default mode which communicates via stdio using the Model Context Protocol.

Interactive Mode

Provides a REPL (Read-Eval-Print Loop) interface for direct user interaction, making it easier to test and debug your JavaScript code.

Pipe Mode

Uses named pipes for communication with external processes, allowing for integration with other applications.

Available Tools

The MCP server provides several powerful tools:

JavaScript Execution

Run one-time JavaScript code and get the results:

// Example of using the 'execute' tool
{
  "name": "execute",
  "parameters": {
    "code": "const result = 2 + 3; return result;"
  }
}

REPL Sessions

Create and maintain stateful REPL sessions:

// Create a new session
{
  "name": "createSession",
  "parameters": {
    "id": "my-session"
  }
}

// Execute code in the session
{
  "name": "executeInSession",
  "parameters": {
    "sessionId": "my-session",
    "code": "let counter = 1; counter;"
  }
}

// Later execution in the same session
{
  "name": "executeInSession",
  "parameters": {
    "sessionId": "my-session",
    "code": "counter += 1; counter;"
  }
}

Session Management

Work with multiple REPL sessions:

// List all active sessions
{
  "name": "listSessions"
}

// Delete a session when you're done
{
  "name": "deleteSession",
  "parameters": {
    "sessionId": "my-session"
  }
}

TypeScript and NPM Support

The server supports TypeScript code execution with automatic transpilation and can dynamically import and use npm packages:

// TypeScript example
{
  "name": "execute",
  "parameters": {
    "code": "const greeting: string = 'Hello, TypeScript!'; return greeting;"
  }
}

// Using NPM packages
{
  "name": "execute",
  "parameters": {
    "code": "const _ = require('lodash'); return _.chunk(['a', 'b', 'c', 'd'], 2);"
  }
}

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "fresh-js-mcp" '{"command":"node","args":["dist/index.js"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "fresh-js-mcp": {
            "command": "node",
            "args": [
                "dist/index.js"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "fresh-js-mcp": {
            "command": "node",
            "args": [
                "dist/index.js"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later