Skip to main content
Glama
yonaka15
by yonaka15

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

Related MCP server: Sandbox MCP

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.

Available Tools

5 tools
pyodide_executeA

Execute Python code using Pyodide with output capture. When generating images, they will be automatically saved to the output directory instead of being displayed. Images can be accessed from the saved file paths that will be included in the output.

ParametersJSON Schema
NameRequiredDescriptionDefault
codeYesPython code to execute
timeoutNoExecution timeout in milliseconds (default: 5000)

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: output capture, automatic image saving to an output directory, and inclusion of file paths in output. It also implies a sandboxed execution environment (Pyodide). However, it doesn't cover potential side effects like memory usage, error handling, or security restrictions, leaving some gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured in two sentences. The first sentence states the core functionality, and the second adds important behavioral context about image handling. Every word earns its place with no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (executing arbitrary Python code), no annotations, and no output schema, the description does a good job covering essential aspects: execution method, output capture, and image handling. However, it doesn't explain the return format or error behavior, which would be helpful for an AI agent. The absence of an output schema increases the need for more completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, providing clear documentation for both parameters (code and timeout). The description doesn't add any parameter-specific information beyond what's in the schema, such as code syntax examples or timeout implications. According to the rules, with high schema coverage, the baseline is 3 even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Execute Python code using Pyodide with output capture.' It specifies the action (execute), resource (Python code), and key capability (output capture). However, it doesn't explicitly differentiate from sibling tools like pyodide_install-packages or pyodide_read-image, which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance by mentioning that 'When generating images, they will be automatically saved to the output directory instead of being displayed.' This suggests a specific use case for image handling. However, it lacks explicit guidance on when to use this tool versus alternatives like pyodide_get-mount-points or pyodide_list-mounted-directory, and doesn't mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

pyodide_get-mount-pointsB

List mounted directories

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool lists mounted directories but doesn't describe what 'mounted' means in this context, the format of the output, whether it's a read-only operation, or any performance or error-handling traits. This leaves significant gaps for a tool that might interact with a filesystem.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'List mounted directories' is a single, efficient sentence that front-loads the core purpose with zero waste. It's appropriately sized for a simple tool with no parameters.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'mounted' entails in this Pyodide context, the return format (e.g., list of paths, JSON structure), or how it differs from 'pyodide_list-mounted-directory'. For a tool that might involve filesystem operations, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so the schema fully documents the absence of inputs. The description doesn't add parameter-specific information, but since there are no parameters, a baseline score of 4 is appropriate as no compensation is needed for missing details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'List mounted directories' clearly states the verb ('List') and resource ('mounted directories'), making the tool's purpose immediately understandable. However, it doesn't differentiate from the sibling tool 'pyodide_list-mounted-directory', which appears to have a similar function, so it doesn't achieve full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'pyodide_list-mounted-directory'. There's no mention of prerequisites, context, or exclusions, leaving the agent with no usage instructions beyond the basic purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

pyodide_install-packagesC

Install Python packages using Pyodide. Multiple packages can be specified using space-separated format.

ParametersJSON Schema
NameRequiredDescriptionDefault
packageYesPython package(s) to install. For multiple packages, use space-separated format (e.g., 'numpy matplotlib pandas').

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the installation action but fails to describe critical traits: whether this requires specific permissions, if it's idempotent (re-installing existing packages), potential side effects (e.g., overwriting dependencies), error handling, or performance implications (e.g., network delays). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise—two sentences that directly address the core functionality and parameter format without any fluff. It's front-loaded with the primary purpose and efficiently communicates the key usage note. Every word earns its place, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation installing packages), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what happens after installation (e.g., success/failure indicators, installed package details, or error messages), nor does it cover behavioral aspects like idempotency or dependencies. For a tool that modifies the environment, more context is needed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, fully documenting the single 'package' parameter with format examples. The description adds value by reinforcing the space-separated format for multiple packages, but doesn't provide additional semantics beyond what the schema already covers (e.g., package name validation, version pinning, or dependency resolution). This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Install') and resource ('Python packages using Pyodide'), making the purpose immediately understandable. It distinguishes itself from sibling tools like pyodide_execute or pyodide_read-image by focusing on package installation rather than code execution or file operations. However, it doesn't explicitly differentiate from potential non-sibling alternatives (like other package installation methods), keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance on when to use this tool, mentioning only that multiple packages can be installed. It lacks explicit context on when to choose this over alternatives (e.g., vs. manual installation or other package managers), prerequisites (e.g., Pyodide environment setup), or exclusions (e.g., packages not supported by Pyodide). This leaves the agent with insufficient decision-making information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

pyodide_list-mounted-directoryB

List contents of a mounted directory

ParametersJSON Schema
NameRequiredDescriptionDefault
mountNameYesName of the mount point

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'List contents' implies a read-only operation, it doesn't specify what format the listing returns (e.g., file names, metadata, recursive structure), whether there are permission constraints, error conditions, or any rate limits. The description provides minimal behavioral context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise at 5 words - 'List contents of a mounted directory'. Every word earns its place, with no redundant information. It's front-loaded with the core action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read operation with 1 parameter and 100% schema coverage, the description is minimally adequate. However, with no output schema and no annotations, it should ideally provide more context about what the listing returns (e.g., file names, types, sizes) and any behavioral constraints. The description covers the basic operation but leaves important contextual gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, with the single parameter 'mountName' clearly documented as 'Name of the mount point'. The description doesn't add any additional parameter semantics beyond what the schema already provides, so it meets the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as 'List contents of a mounted directory' - a specific verb ('List') and resource ('contents of a mounted directory'). It distinguishes from siblings like 'pyodide_execute' (execution) and 'pyodide_read-image' (reading specific files), though it doesn't explicitly differentiate from 'pyodide_get-mount-points' which lists mounts rather than directory contents.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (like needing a mounted directory first), when not to use it, or how it relates to sibling tools like 'pyodide_get-mount-points' (which lists mount points rather than directory contents).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

pyodide_read-imageC

Read an image from a mounted directory

ParametersJSON Schema
NameRequiredDescriptionDefault
mountNameYesName of the mount point
imagePathYesPath of the image file

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It states the action ('Read') but doesn't disclose behavioral traits like what happens if the image is invalid, if it requires specific permissions, or what the output format is. This is inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized and front-loaded, making it easy to understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., image data, metadata, or an error) or handle potential issues like invalid paths. For a tool with 2 parameters and no structured support, it should provide more context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters (mountName and imagePath) with descriptions. The description doesn't add any meaning beyond this, such as examples or constraints, but meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Read') and resource ('an image from a mounted directory'), making the purpose understandable. It doesn't explicitly differentiate from sibling tools like pyodide_list-mounted-directory, which might also involve mounted directories, so it's not a perfect 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as how it differs from pyodide_list-mounted-directory or when to prefer it over other image-handling methods. It lacks explicit context or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.4/5.0
Disambiguation4/5

Most tools have distinct purposes: execute code, list mount points, install packages, list directory contents, and read images. However, pyodide_get-mount-points and pyodide_list-mounted-directory could cause minor confusion as both relate to directory listing, but their scopes differ (mount points vs. specific directory contents).

Naming Consistency5/5

All tools follow a consistent pyodide_verb-noun naming pattern with hyphens for multi-word verbs or nouns. This uniformity makes the tool set predictable and easy to understand, with no mixing of conventions.

Tool Count4/5

With 5 tools, the count is reasonable for a Pyodide execution server, covering core operations like code execution, package management, and file handling. It might benefit from additional tools for writing files or managing environments, but it's well-scoped for basic functionality.

Completeness3/5

The tools cover key areas such as code execution, package installation, and file reading/listing, but there are notable gaps. For example, there's no tool for writing or saving files (beyond automatic image saving), deleting files, or managing Python environments more comprehensively, which could limit agent workflows.

Maintenance

ActivityInactive
ResponsivenessUnresponsive

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol (MCP) server that enables LLMs to run ANY code safely in isolated Docker containers.
    121
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    A secure Model Context Protocol server that allows AI assistants and LLM applications to safely execute Python and JavaScript code snippets in containerized environments.
    2
    203
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A production-grade MCP server providing a persistent Python REPL with multi-session support, sandboxing, and timeout protection, enabling LLM agents to execute Python code across multiple turns with variables that persist between calls.
    12
    1
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yonaka15/mcp-pyodide'

If you have feedback or need assistance with the MCP directory API, please join our Discord server