Daytona Python Interpreter MCP server

Integrates with Daytona's secure Python execution environment to enable isolated code running and workspace management for testing and educational purposes.
Back to servers
Provider
Nikola Balic
Release date
Jan 20, 2025
Language
Python
Stats
16 stars

Daytona MCP Interpreter provides Python code execution capabilities in secure, isolated environments. It allows AI assistants like Claude to execute Python code and shell commands, manage files, clone Git repositories, and generate web previews - all within ephemeral Daytona sandboxes that are automatically cleaned up after use.

Installation

Prerequisites

First, install uv:

curl -LsSf https://astral.sh/uv/install.sh | sh

Setup Environment

Create and activate a virtual environment:

uv venv
source .venv/bin/activate

On Windows, activate with:

.venv\Scripts\activate

Install Dependencies

Install the required packages:

uv add "mcp[cli]" pydantic python-dotenv "daytona-sdk>=0.10.5"

Note that daytona-sdk version 0.10.5 or higher is required.

Configuration

Environment Variables

Set these environment variables for proper operation:

  • MCP_DAYTONA_API_KEY: Required API key for Daytona authentication
  • MCP_DAYTONA_SERVER_URL: Server URL (default: https://app.daytona.io/api)
  • MCP_DAYTONA_TIMEOUT: Request timeout in seconds (default: 180.0)
  • MCP_DAYTONA_TARGET: Target region (default: eu)
  • MCP_VERIFY_SSL: Enable SSL verification (default: false)

Running the Server

Start the server directly:

uv run src/daytona_mcp_interpreter/server.py

View logs:

tail -f /tmp/daytona-interpreter.log

Integration with Claude Desktop

Configuration

Edit the Claude Desktop configuration file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the following configuration:

{
    "mcpServers": {
        "daytona-interpreter": {
            "command": "/Users/USER/.local/bin/uv",
            "args": [
                "--directory",
                "/Users/USER/dev/daytona-mcp-interpreter",
                "run",
                "src/daytona_mcp_interpreter/server.py"
            ],
            "env": {
                "PYTHONUNBUFFERED": "1",
                "MCP_DAYTONA_API_KEY": "api_key",
                "MCP_DAYTONA_SERVER_URL": "api_server_url",
                "MCP_DAYTONA_TIMEOUT": "30.0",
                "MCP_VERIFY_SSL": "false",
                "PATH": "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
            }
        }
    }
}

Restart Claude Desktop to apply the changes.

Available Tools

Shell Exec

Execute shell commands in the Daytona workspace:

# List files
ls -la

# Install a package
pip install pandas

File Download

Download files from the Daytona workspace:

# Basic usage
file_download(file_path="/path/to/file.txt")

# Set custom file size limit
file_download(file_path="/path/to/large_file.csv", max_size_mb=10.0)

# Download partial content for large files
file_download(file_path="/path/to/large_file.csv", download_option="download_partial", chunk_size_kb=200)

# Convert large file to text
file_download(file_path="/path/to/large_file.pdf", download_option="convert_to_text")

# Compress file before downloading
file_download(file_path="/path/to/large_file.bin", download_option="compress_file")

# Force download despite size
file_download(file_path="/path/to/large_file.zip", download_option="force_download")

File Upload

Upload files to the Daytona workspace:

# Upload a text file
file_upload(file_path="/workspace/example.txt", content="Hello, World!")

# Upload a text file with specific path
file_upload(
    file_path="/workspace/data/config.json",
    content='{"setting": "value", "enabled": true}'
)

# Upload a binary file using base64 encoding
import base64
with open("local_image.png", "rb") as f:
    base64_content = base64.b64encode(f.read()).decode('utf-8')

file_upload(
    file_path="/workspace/images/uploaded.png",
    content=base64_content,
    encoding="base64"
)

# Upload without overwriting existing files
file_upload(
    file_path="/workspace/important.txt",
    content="New content",
    overwrite=False
)

Git Clone

Clone Git repositories into the workspace:

# Basic usage
git_clone(repo_url="https://github.com/username/repository.git")

# Clone a specific branch
git_clone(
    repo_url="https://github.com/username/repository.git",
    branch="develop"
)

# Clone to a specific directory with full history
git_clone(
    repo_url="https://github.com/username/repository.git",
    target_path="my_project",
    depth=0  # 0 means full history
)

# Clone with Git LFS support for repositories with large files
git_clone(
    repo_url="https://github.com/username/large-files-repo.git",
    lfs=True
)

Web Preview

Generate preview URLs for web servers running in the workspace:

# Generate a preview link for a web server running on port 3000
web_preview(port=3000)

# Generate a preview link with a descriptive name
web_preview(
    port=8080,
    description="React Development Server"
)

# Generate a link without checking if server is running
web_preview(
    port=5000,
    check_server=False
)

Example usage:

# First run a simple web server using Python via the shell
shell_exec(command="python -m http.server 8000 &")

# Then generate a preview link for the server
web_preview(port=8000, description="Python HTTP Server")

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later