Labsco
mark3labs logo

JavaScript Executor MCP Server

โ˜… 3

from mark3labs

Execute JavaScript code in a modern runtime environment with support for various built-in modules.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

JavaScript Executor MCP Server

This MCP server provides JavaScript execution capabilities with a modern runtime.

Features

The executeJS tool provides:

  • Console API: console.log(), console.error(), console.warn() (built-in)
  • HTTP Server: serve() for server creation (via require('http/server'))
  • Fetch API: Modern fetch() with Request, Response, Headers, FormData (global)
  • Timers: setTimeout(), setInterval(), clearTimeout(), clearInterval() (global)
  • Buffer: Buffer, Blob, File APIs for binary data handling (global)
  • Crypto: Cryptographic functions - hashing, encryption, HMAC (via require('crypto'))
  • Cache: In-memory caching with TTL support (via require('cache'))
  • Additional modules: encoding (global), url (global)

Tool Reference

executeJS

Execute JavaScript code with a modern runtime environment.

Parameters:

  • code (required): JavaScript code to execute

Configuration:

  • Default execution timeout: 5 minutes
  • Configurable via --execution-timeout <seconds> CLI flag

Example:

console.log("Hello, World!");

// Basic JavaScript execution
const result = 2 + 3;
console.log('Result:', result);

// Fetch API (available globally when enabled)
const response = await fetch('https://api.example.com/data');
const data = await response.json();

// HTTP server (require import)
const serve = require('http/server');
serve(8000, async (req) => {
  return new Response('Hello World');
});

// Cache operations (require import)
const cache = require('cache');
cache.set('key', 'value');
console.log(cache.get('key'));

// Crypto operations (require import)
const crypto = require('crypto');
const hash = crypto.md5('hello').hex();
console.log('MD5 hash:', hash);

// Timers (available globally)
setTimeout(() => console.log('Hello after 1 second'), 1000);

// Buffer operations (available globally)
const buffer = Buffer.from('hello', 'utf8');
console.log(buffer.toString('base64'));

// URL operations (available globally)
const url = new URL('https://example.com/path?param=value');
console.log('Host:', url.host);
console.log('Pathname:', url.pathname);

Building

go build -o codebench-mcp .