npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mcp-js-executor

v1.1.3

Published

MCP server that executes JavaScript code for data analysis with support for JSON, CSV, and TSV formats

Readme

MCP JavaScript Executor

Secure MCP server that executes JavaScript code for data analysis with support for multiple data formats using isolated-vm.

🚀 Features

  • Multi-format Data Support: JSON, CSV, TSV, and pipe-separated data
  • Smart Format Detection: Automatically detects data format from content (not file extension)
  • Secure Execution: Isolated JavaScript environment with resource limits
  • Flexible Data Input: Support for URLs and inline data
  • Advanced JavaScript: Variables, functions, return statements, and complex logic
  • Safety Limits: 5-second timeout and 128MB memory protection

📊 Supported Data Formats

JSON

[{"name": "John", "age": 30}, {"name": "Jane", "age": 25}]

CSV (Comma-separated)

name,age,city
John,30,New York
Jane,25,Boston

TSV (Tab-separated)

name	age	city
John	30	New York
Jane	25	Boston

Pipe-separated

name|age|city
John|30|New York
Jane|25|Boston

Note: The MCP automatically detects the format and delimiter from the content, converting all tabular data into JavaScript arrays of objects.

Installation

npx mcp-js-executor

🔧 Usage Examples

Simple Data Analysis

// Count total records
data.length

// Filter and count active items
data.filter(item => item.status === 'active').length

// Find maximum value
Math.max(...data.map(item => item.price))

Complex Data Processing

// Sales analysis by month
const salesByMonth = {};
data.forEach(sale => {
  const month = sale.Mese;
  salesByMonth[month] = (salesByMonth[month] || 0) + sale['Totale Vendita'];
});
return Object.entries(salesByMonth).map(([month, total]) => ({month, total}));

Advanced Analytics

// Find top performers with statistics
const sellers = {};
data.filter(o => o.Mese === 'agosto').forEach(o => {
  sellers[o.Venditore] = (sellers[o.Venditore] || 0) + 1;
});
return Object.entries(sellers)
  .map(([name, count]) => ({name, orders: count}))
  .sort((a,b) => b.orders - a.orders);

🌐 MCP Tool Call Format

Using URL Data Source

{
  "tool": "execute_js",
  "parameters": {
    "url": "https://example.com/data.csv",
    "code": "data.filter(item => item.status === 'active').length"
  }
}

Using Inline Data

{
  "tool": "execute_js", 
  "parameters": {
    "data": [{"name": "John", "age": 30}],
    "code": "data.filter(person => person.age > 25).length"
  }
}

🔄 Data Conversion Process

  1. Format Detection: Analyzes content to identify delimiter (,, \t, ;, |)
  2. Smart Parsing: Skips header lines and separator rows automatically
  3. Type Conversion: Converts strings to numbers/booleans when appropriate
  4. Object Creation: Transforms rows into JavaScript objects with column headers as keys

Example Conversion

Input CSV:

name,age,active
John,30,true
Jane,25,false

Becomes JavaScript:

[
  {"name": "John", "age": 30, "active": true},
  {"name": "Jane", "age": 25, "active": false}
]

🛡️ Security & Limits

  • Isolated Execution: Uses isolated-vm for complete sandboxing
  • Memory Limit: 128MB maximum per execution
  • Timeout Protection: 5-second execution limit
  • No File System Access: Cannot read/write local files
  • No Network Access: Cannot make external HTTP requests (except for data fetching)
  • Safe Environment: No access to Node.js modules or system functions

🔧 Technical Details

Supported Delimiters

  • , (comma) - Standard CSV
  • \t (tab) - TSV files
  • ; (semicolon) - European CSV format
  • | (pipe) - Custom delimiter format

Auto-Detection Logic

  1. Analyzes first data line (skipping headers and separators)
  2. Counts occurrence of each delimiter
  3. Selects most frequent delimiter
  4. Falls back to comma if no clear winner

Data Type Conversion

  • Numbers: Automatic conversion for integers and floats
  • Booleans: Converts "true"/"false" strings
  • Null Values: Empty cells become null
  • Strings: Everything else remains as string

📈 Version History

v1.1.0 (Current)

  • ✅ Added CSV/TSV/pipe-separated data support
  • ✅ Implemented smart delimiter detection
  • ✅ Enhanced data parsing with type conversion
  • ✅ Improved error handling for malformed data
  • ✅ Maintained full backward compatibility

v1.0.2

  • ✅ Initial JSON-only support
  • ✅ Basic JavaScript execution
  • ✅ Security isolation with isolated-vm

🤝 Contributing

This MCP server is designed for secure data analysis. When contributing:

  1. Maintain security isolation
  2. Preserve backward compatibility
  3. Add comprehensive tests for new data formats
  4. Update documentation and examples

📄 License

MIT License - Feel free to use in your projects!