MCP ExplorerExplorer

Mcp Python Executor

@bsmi021on a year ago
2 MIT
FreeCommunity
AI Systems
#claude#mcp#mcp-server#modelcontextprotocol#python
MCP Python Executor for safe execution and management of Python code and packages.

Overview

What is Mcp Python Executor

mcp-python-executor is a Model Context Protocol (MCP) server designed for executing Python code and managing Python packages safely and efficiently.

Use cases

Use cases include executing data processing scripts, running machine learning models, automating tasks, and providing a backend service for applications that require Python code execution.

How to use

To use mcp-python-executor, configure the server through environment variables, specifying pre-installed packages, memory limits, execution timeouts, and logging preferences. Use the ‘execute_python’ tool to run Python code or scripts and the ‘install_packages’ tool to manage Python packages.

Key features

Key features include safe execution of Python code, management of Python packages, pre-configuration of commonly used packages, resource monitoring, health checks, metrics, and structured logging.

Where to use

mcp-python-executor can be used in various fields such as data analysis, machine learning, web development, and any application requiring dynamic execution of Python code.

Content

MCP Python Executor

A Model Context Protocol (MCP) server for executing Python code and managing Python packages.

Features

  • Execute Python code with safety constraints
  • Install and manage Python packages
  • Pre-configure commonly used packages
  • Resource monitoring and limits
  • Health checks and metrics
  • Structured logging

Configuration

The server can be configured through environment variables in the MCP settings:

{
  "mcpServers": {
    "mcp-python-executor": {
      "command": "node",
      "args": [
        "path/to/python-executor/build/index.js"
      ],
      "env": {
        "PREINSTALLED_PACKAGES": "numpy pandas matplotlib scikit-learn",
        "MAX_MEMORY_MB": "512",
        "EXECUTION_TIMEOUT_MS": "30000",
        "MAX_CONCURRENT_EXECUTIONS": "5",
        "LOG_LEVEL": "info",
        "LOG_FORMAT": "json"
      }
    }
  }
}

Environment Variables

  • PREINSTALLED_PACKAGES: Space-separated list of Python packages to install on startup
  • MAX_MEMORY_MB: Maximum memory limit per execution (default: 512)
  • EXECUTION_TIMEOUT_MS: Maximum execution time in milliseconds (default: 30000)
  • MAX_CONCURRENT_EXECUTIONS: Maximum number of concurrent executions (default: 5)
  • LOG_LEVEL: Logging level (debug|info|error, default: info)
  • LOG_FORMAT: Log format (json|text, default: json)

Available Tools

1. execute_python

Execute Python code and return the results.

interface ExecutePythonArgs {
  code?: string;          // Python code to execute (inline)
  scriptPath?: string;    // Path to existing Python script file (alternative to code)
  inputData?: string[];   // Optional input data
}

Examples:

// Example with inline code
{
  "code": "print('Hello, World!!')\nfor i in range(3): print(i)",
  "inputData": ["optional", "input", "data"]
}

// Example with script path
{
  "scriptPath": "/path/to/your_script.py",
  "inputData": ["optional", "input", "data"]
}

2. install_packages

Install Python packages.

interface InstallPackagesArgs {
  packages: string[];
}

Example:

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers