mcp-pyodide

by yonaka15

Integrations

  • Used as the web framework for SSE (Server-Sent Events) support, providing endpoints for SSE connection and message handling

  • The server runs on Node.js, requiring version 18 or higher for development

  • Used for package management and running scripts for the MCP server

mcp-pyodide

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.

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

# Clone the repository git clone <repository-url> # Install dependencies npm install # Build npm run build

Scripts

  • npm run build: Compile TypeScript and set execution permissions
  • npm start: Run server in stdio mode
  • npm run start:sse: Run server in SSE mode

Environment Variables

  • 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)

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Create a Pull Request

Important Notes

  • This project is under development, and the API may change
  • Thoroughly test before using in production
  • Exercise caution when executing untrusted code for security reasons
  • When using SSE mode, ensure proper CORS configuration if needed

Support

Please use the Issue tracker for problems and questions.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

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

  1. Features
    1. Installation
      1. Usage
        1. As a Server
        2. As a Command-line Tool
        3. SSE Mode
      2. Project Structure
        1. Dependencies
          1. Development
            1. Requirements
            2. Setup
            3. Scripts
          2. Environment Variables
            1. License
              1. Contributing
                1. Important Notes
                  1. Support

                    Related MCP Servers

                    • -
                      security
                      A
                      license
                      -
                      quality
                      A Python-based server that implements the Model Context Protocol to interface with Claude Desktop as an MCP client, supporting interaction through efficient memory management.
                      Last updated -
                      1
                      Python
                      MIT License
                    • -
                      security
                      A
                      license
                      -
                      quality
                      A Model Context Protocol server that extracts and analyzes Python code structures, focusing on import/export relationships between files to help LLMs understand code context.
                      Last updated -
                      4
                      Python
                      MIT License
                    • A
                      security
                      F
                      license
                      A
                      quality
                      A Python server implementing the Model Context Protocol to provide customizable prompt templates, resources, and tools that enhance LLM interactions in the continue.dev environment.
                      Last updated -
                      2
                      Python
                    • -
                      security
                      A
                      license
                      -
                      quality
                      Model Context Protocol server to run Python code in a sandbox.
                      Last updated -
                      1,462
                      9,276
                      Python
                      MIT License

                    View all related MCP servers

                    ID: pxls43joly