Skip to main content
Glama
yzfly

MCP Python Interpreter

by yzfly

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MCP_ALLOW_SYSTEM_ACCESSNoControls whether the MCP server has system access. Set to 0 to disable system access for security.0

Capabilities

Server capabilities have not been inspected yet.

Tools

Functions exposed to the LLM to take actions

NameDescription
list_python_environments

List all available Python environments (system Python and conda environments).

list_installed_packages
List installed packages for a specific Python environment.

Args:
    environment: Name of the Python environment
run_python_code
Execute Python code with flexible execution modes.

Args:
    code: Python code to execute
    execution_mode: Execution mode - "inline" (default, fast, in-process) or "subprocess" (isolated)
    session_id: Session ID for inline mode to maintain state across executions
    environment: Python environment name (only for subprocess mode)
    save_as: Optional filename to save the code before execution
    timeout: Maximum execution time in seconds (only enforced for subprocess mode)

Returns:
    Execution result with output

Execution modes:
- "inline" (default): Executes code in the current process. Fast and reliable,
  maintains session state. Use for most code execution tasks.
- "subprocess": Executes code in a separate Python process. Use when you need
  environment isolation or a different Python environment.
run_python_file
Execute a Python file (always uses subprocess for file execution).

Args:
    file_path: Path to the Python file to execute
    environment: Name of the Python environment to use
    arguments: List of command-line arguments to pass to the script
    timeout: Maximum execution time in seconds (default: 300)
install_package
Install a Python package in the specified environment.

Args:
    package_name: Name of the package to install
    environment: Name of the Python environment
    upgrade: Whether to upgrade if already installed
    timeout: Maximum execution time in seconds
read_file
Read the content of any file, with size limits for safety.

Args:
    file_path: Path to the file
    max_size_kb: Maximum file size to read in KB
write_file
Write content to a file.

Args:
    file_path: Path to the file to write
    content: Content to write
    overwrite: Whether to overwrite if exists
list_directory
List all Python files in a directory.

Args:
    directory_path: Path to directory (empty for working directory)
clear_session
Clear a REPL session's state and history.

Args:
    session_id: Session ID to clear
list_sessions

List all active REPL sessions.

Prompts

Interactive templates invoked by user choice

NameDescription
python_function_templateGenerate a template for a Python function with docstring.
refactor_python_codeHelp refactor Python code for better readability and performance.
debug_python_errorHelp debug a Python error.

Resources

Contextual data attached and managed by the client

NameDescription
get_environments_resourceList all available Python environments as a resource.
get_working_directory_listingList all Python files in the working directory as a resource.

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/yzfly/mcp-python-interpreter'

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