iflow-mcp_python-execute-server


Nameiflow-mcp_python-execute-server JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA Model Context Protocol server providing python code execution capability
upload_time2025-09-01 09:34:59
maintainerNone
docs_urlNone
authoriflow team
requires_python==3.12.7
licenseMIT
keywords automation code llm mcp python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python Execute Server

A Model Context Protocol (MCP) server that provides Python code execution capabilities for Large Language Models (LLMs).

## Features

- **Python Code Execution**: Execute Python code in a persistent REPL environment
- **Data Analysis Support**: Perform calculations and data analysis with full Python ecosystem
- **File Output**: Automatically save executed code to timestamped files
- **Workspace Integration**: Execute code within a designated workspace directory
- **Error Handling**: Comprehensive error reporting and exception handling
- **Output Capture**: Capture and return both stdout and execution results

## Tools Provided

- `python_repl_tool`: Execute Python code and perform data analysis or calculations with visible output

## Execution Features

### Code Execution
- Persistent REPL environment maintains state between executions
- Support for all Python standard library modules
- Data analysis and scientific computing capabilities
- Real-time output capture and display

### File Management
- Automatic code saving with unique timestamped filenames
- Organized file storage in workspace/python directory
- Code preservation for debugging and reference

### Output Handling
- Stdout capture for print statements and output
- Error detection and reporting
- Structured result formatting
- Multi-format result support

## Configuration Options

- `--workspace-path`: Set the workspace directory (default: ./workspace)

## Server Configuration

To use this server with MCP clients, add the following configuration to your MCP settings:

For development or when using `uv`:

```json
{
  "mcpServers": {
    "python-execute-server": {
      "command": "uv",
      "args": ["--directory", "directory_of_python-execute-server", "run", "python-execute-server", "--workspace-path", "/path/to/your/workspace"],
      "env": {}
    }
  }
}
```

## Usage Examples

### Basic Code Execution
```python
# Execute simple calculations
result = await python_repl_tool("print(2 + 2)")
# Output: Successfully executed code with Stdout: 4
```

### Data Analysis
```python
# Perform data analysis
code = """
import pandas as pd
import numpy as np

data = {'A': [1, 2, 3], 'B': [4, 5, 6]}
df = pd.DataFrame(data)
print(df.describe())
"""
result = await python_repl_tool(code)
```

### Mathematical Calculations
```python
# Complex mathematical operations
code = """
import math
result = math.sqrt(16) + math.pi
print(f"Result: {result}")
"""
result = await python_repl_tool(code)
```

## REPL Environment

### Persistent State
- Variables and imports persist between executions
- Allows for multi-step data analysis workflows
- State maintained throughout session

### Library Support
- Full access to Python standard library
- Support for popular data science libraries (pandas, numpy, matplotlib, etc.)
- Extensible with additional package installations

### Error Handling
- Graceful error capture and reporting
- Exception details preserved and returned
- Non-blocking error handling

## File Output System

### Automatic Saving
- All executed code automatically saved to files
- Unique filenames with timestamp and random suffix
- Organized storage in workspace/python directory

### File Naming Convention
```
replaceChatId_{timestamp}_{random_number}.py
```

### Output Tracking
- File paths returned in execution results
- Support for multiple output formats
- Integration with file management systems

## Safety Features

- **Workspace Isolation**: Code execution contained within workspace
- **Error Containment**: Exceptions don't crash the server
- **Input Validation**: Code input validation and sanitization
- **Resource Management**: Proper cleanup and resource handling

## Use Cases

- **Data Analysis**: Statistical analysis and data processing
- **Mathematical Calculations**: Complex mathematical operations
- **Prototyping**: Quick code testing and validation
- **Educational**: Learning and experimenting with Python
- **Automation**: Script execution and task automation

## License

MIT License - see LICENSE file for details.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "iflow-mcp_python-execute-server",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "==3.12.7",
    "maintainer_email": null,
    "keywords": "automation, code, llm, mcp, python",
    "author": "iflow team",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/1b/f8/db2c0df0816315d1cd8845190d2d38958e9c1e16444266b56dc881cf4ab7/iflow_mcp_python_execute_server-0.1.2.tar.gz",
    "platform": null,
    "description": "# Python Execute Server\n\nA Model Context Protocol (MCP) server that provides Python code execution capabilities for Large Language Models (LLMs).\n\n## Features\n\n- **Python Code Execution**: Execute Python code in a persistent REPL environment\n- **Data Analysis Support**: Perform calculations and data analysis with full Python ecosystem\n- **File Output**: Automatically save executed code to timestamped files\n- **Workspace Integration**: Execute code within a designated workspace directory\n- **Error Handling**: Comprehensive error reporting and exception handling\n- **Output Capture**: Capture and return both stdout and execution results\n\n## Tools Provided\n\n- `python_repl_tool`: Execute Python code and perform data analysis or calculations with visible output\n\n## Execution Features\n\n### Code Execution\n- Persistent REPL environment maintains state between executions\n- Support for all Python standard library modules\n- Data analysis and scientific computing capabilities\n- Real-time output capture and display\n\n### File Management\n- Automatic code saving with unique timestamped filenames\n- Organized file storage in workspace/python directory\n- Code preservation for debugging and reference\n\n### Output Handling\n- Stdout capture for print statements and output\n- Error detection and reporting\n- Structured result formatting\n- Multi-format result support\n\n## Configuration Options\n\n- `--workspace-path`: Set the workspace directory (default: ./workspace)\n\n## Server Configuration\n\nTo use this server with MCP clients, add the following configuration to your MCP settings:\n\nFor development or when using `uv`:\n\n```json\n{\n  \"mcpServers\": {\n    \"python-execute-server\": {\n      \"command\": \"uv\",\n      \"args\": [\"--directory\", \"directory_of_python-execute-server\", \"run\", \"python-execute-server\", \"--workspace-path\", \"/path/to/your/workspace\"],\n      \"env\": {}\n    }\n  }\n}\n```\n\n## Usage Examples\n\n### Basic Code Execution\n```python\n# Execute simple calculations\nresult = await python_repl_tool(\"print(2 + 2)\")\n# Output: Successfully executed code with Stdout: 4\n```\n\n### Data Analysis\n```python\n# Perform data analysis\ncode = \"\"\"\nimport pandas as pd\nimport numpy as np\n\ndata = {'A': [1, 2, 3], 'B': [4, 5, 6]}\ndf = pd.DataFrame(data)\nprint(df.describe())\n\"\"\"\nresult = await python_repl_tool(code)\n```\n\n### Mathematical Calculations\n```python\n# Complex mathematical operations\ncode = \"\"\"\nimport math\nresult = math.sqrt(16) + math.pi\nprint(f\"Result: {result}\")\n\"\"\"\nresult = await python_repl_tool(code)\n```\n\n## REPL Environment\n\n### Persistent State\n- Variables and imports persist between executions\n- Allows for multi-step data analysis workflows\n- State maintained throughout session\n\n### Library Support\n- Full access to Python standard library\n- Support for popular data science libraries (pandas, numpy, matplotlib, etc.)\n- Extensible with additional package installations\n\n### Error Handling\n- Graceful error capture and reporting\n- Exception details preserved and returned\n- Non-blocking error handling\n\n## File Output System\n\n### Automatic Saving\n- All executed code automatically saved to files\n- Unique filenames with timestamp and random suffix\n- Organized storage in workspace/python directory\n\n### File Naming Convention\n```\nreplaceChatId_{timestamp}_{random_number}.py\n```\n\n### Output Tracking\n- File paths returned in execution results\n- Support for multiple output formats\n- Integration with file management systems\n\n## Safety Features\n\n- **Workspace Isolation**: Code execution contained within workspace\n- **Error Containment**: Exceptions don't crash the server\n- **Input Validation**: Code input validation and sanitization\n- **Resource Management**: Proper cleanup and resource handling\n\n## Use Cases\n\n- **Data Analysis**: Statistical analysis and data processing\n- **Mathematical Calculations**: Complex mathematical operations\n- **Prototyping**: Quick code testing and validation\n- **Educational**: Learning and experimenting with Python\n- **Automation**: Script execution and task automation\n\n## License\n\nMIT License - see LICENSE file for details.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Model Context Protocol server providing python code execution capability",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [
        "automation",
        " code",
        " llm",
        " mcp",
        " python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "45fcc74aad60de84a6df6d11f6bb9ad4f037e2b47f48406abc06147e6a159999",
                "md5": "9cef70335dd0d2e37a07f5736aec9c09",
                "sha256": "629104ebcbc77affbee77939ebb51a4ef0ef932135022070a008b761fd9ced8e"
            },
            "downloads": -1,
            "filename": "iflow_mcp_python_execute_server-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9cef70335dd0d2e37a07f5736aec9c09",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "==3.12.7",
            "size": 250007,
            "upload_time": "2025-09-01T09:34:57",
            "upload_time_iso_8601": "2025-09-01T09:34:57.583439Z",
            "url": "https://files.pythonhosted.org/packages/45/fc/c74aad60de84a6df6d11f6bb9ad4f037e2b47f48406abc06147e6a159999/iflow_mcp_python_execute_server-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1bf8db2c0df0816315d1cd8845190d2d38958e9c1e16444266b56dc881cf4ab7",
                "md5": "741cac2565ffcdede7fc8d054b7992b2",
                "sha256": "7c829f4a8b49f8ae279da415b8c1a4840403ee571d23001f74026da10675b765"
            },
            "downloads": -1,
            "filename": "iflow_mcp_python_execute_server-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "741cac2565ffcdede7fc8d054b7992b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "==3.12.7",
            "size": 247280,
            "upload_time": "2025-09-01T09:34:59",
            "upload_time_iso_8601": "2025-09-01T09:34:59.121691Z",
            "url": "https://files.pythonhosted.org/packages/1b/f8/db2c0df0816315d1cd8845190d2d38958e9c1e16444266b56dc881cf4ab7/iflow_mcp_python_execute_server-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-01 09:34:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "iflow-mcp_python-execute-server"
}
        
Elapsed time: 1.50275s