mcp-pyodide

by yonaka15

9 168 downloads Not rated yet MIT
GitHub

About

A Pyodide server for executing Python code by Large Language Models (LLMs) via the Model Context Protocol (MCP).

Details

Repository
yonaka15/mcp-pyodide
License
MIT

Explore

- Python code execution capability for LLMs using Pyodide
- MCP compliant server implementation
- Support for both stdio and SSE transport modes
- Robust implementation written in TypeScript
- Available as a command-line tool

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name mcp-pyodide
    Command (node, npx, python, etc.) mcp-pyodide
    Environment
    • PORT 3020
    • PYODIDE_DATA_DIR ./data
    • PYODIDE_CACHE_DIR ./cache

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

npm install mcp-pyodide

npm install

- PYODIDE_CACHE_DIR: Directory for Pyodide cache (default: "./cache")
- PYODIDE_DATA_DIR: Directory for mounted data (default: "./data")
- PORT: Port for SSE server (default: 3020)

Start in stdio mode (default):

mcp-pyodide

Start in SSE mode:

mcp-pyodide --sse

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp-pyodide": {
            "env": {
                "PORT": "3020",
                "PYODIDE_DATA_DIR": "./data",
                "PYODIDE_CACHE_DIR": "./cache"
            },
            "args": [],
            "command": "mcp-pyodide"
        }
    }
}

Linux

{
    "env": {
        "PORT": "3020",
        "PYODIDE_DATA_DIR": "./data",
        "PYODIDE_CACHE_DIR": "./cache"
    },
    "args": [],
    "command": "mcp-pyodide"
}

Macos

{
    "env": {
        "PORT": "3020",
        "PYODIDE_DATA_DIR": "./data",
        "PYODIDE_CACHE_DIR": "./cache"
    },
    "args": [],
    "command": "mcp-pyodide"
}

Windows

{
    "env": {
        "PORT": "3020",
        "PYODIDE_DATA_DIR": "./data",
        "PYODIDE_CACHE_DIR": "./cache"
    },
    "args": [
        "/c",
        "mcp-pyodide"
    ],
    "command": "cmd"
}

A Pyodide server implementation for the Model Context Protocol (MCP). This server enables Large Language Models (LLMs) to execute Python code through the MCP interface.

<a href="https://glama.ai/mcp/servers/pxls43joly">
mcp-pyodide MCP server
</a>

Features

- Python code execution capability for LLMs using Pyodide
- MCP compliant server implementation
- Support for both stdio and SSE transport modes
- Robust implementation written in TypeScript
- Available as a command-line tool

Installation

npm install mcp-pyodide

Usage

As a Server

import { runServer } from "mcp-pyodide";

// Start the server
runServer().catch((error: unknown) => {
console.error("Error starting server:", error);
process.exit(1);
});

As a Command-line Tool

Start in stdio mode (default):

mcp-pyodide

Start in SSE mode:

mcp-pyodide --sse

SSE Mode

When running in SSE mode, the server provides the following endpoints:

- SSE Connection: http://localhost:3020/sse
- Message Handler: http://localhost:3020/messages

Example client connection:

const eventSource = new EventSource("http://localhost:3020/sse");
eventSource.onmessage = (event) => {
  console.log("Received:", JSON.parse(event.data));
};

Project Structure

mcp-pyodide/
├── src/
│   ├── formatters/    # Data formatting handlers
│   ├── handlers/      # Request handlers
│   ├── lib/          # Library code
│   ├── tools/        # Utility tools
│   ├── utils/        # Utility functions
│   └── index.ts      # Main entry point
├── build/            # Build artifacts
├── pyodide-packages/ # Pyodide-related packages
└── package.json

Dependencies

- @modelcontextprotocol/sdk: MCP SDK (^1.4.0)
- pyodide: Python runtime environment (^0.27.1)
- arktype: Type validation library (^2.0.1)
- express: Web framework for SSE support
- cors: CORS middleware for SSE support

Development

Requirements

- Node.js 18 or higher
- npm 9 or higher

Setup

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.