Model Context Protocol (MCP) Server
Relevant source files
The following files were used as context for generating this wiki page:
The Daytona Model Context Protocol (MCP) Server is a specialized interface that allows AI agents to interact directly with Daytona's environment. It enables agents to manage sandboxes, perform file operations, and execute commands within secure, isolated Linux environments. By implementing the MCP standard, Daytona provides a bridge between Large Language Models (LLMs) and local development resources.
The server is designed to integrate seamlessly with popular AI tools such as Claude Desktop, Cursor, and Windsurf. It exposes Daytona's core functionality—including sandbox lifecycle management, git operations, and web application previewing—as a set of tools that agents can discover and invoke during a conversation.
Sources: apps/cli/mcp/README.md:1-12, apps/cli/mcp/server.go:14-25
Architecture and Core Components
The Daytona MCP Server is built as an extension of the MCPServer base class from the mcp-go library. It operates primarily over the stdio transport layer, allowing it to communicate with agent host applications.
Server Initialization
The server is initialized with specific capabilities, including recovery support and tool capabilities. It explicitly disables prompt and resource capabilities in its current implementation. During initialization, it registers a comprehensive suite of tools that map to Daytona CLI and SDK functionalities.
The diagram above shows the communication flow between an AI agent host and the Daytona MCP Server, illustrating how tool requests are routed to internal Daytona services.
Sources: apps/cli/mcp/server.go:17-31, apps/cli/cmd/mcp/config.go:61-75
Tool Categories and Capabilities
The MCP Server exposes several categories of tools that allow agents to control the development environment.
Sandbox Management
These tools handle the lifecycle of Daytona sandboxes. Agents can programmatically create environments with specific images and intervals, or destroy them when no longer needed.
| Tool Name | Purpose | Key Parameters |
|---|---|---|
create_sandbox | Provision a new environment | id, target, image, auto_stop_interval |
destroy_sandbox | Remove an environment | id |
Sources: apps/cli/mcp/README.md:43-56, apps/cli/mcp/server.go:42-43
File and Git Operations
The server provides a rich set of file system tools, including uploading, downloading, moving, and deleting files. It also includes a git_clone tool to pull source code into the sandbox.
- File Upload/Download: Supports text and base64-encoded binary content.
- Directory Management: Allows creating folders and listing directory contents with metadata.
- Git Integration: Supports cloning via URL with optional branch, commit ID, and credential parameters.
Sources: apps/cli/mcp/README.md:58-105, apps/cli/mcp/server.go:45-51
Execution and Preview
Agents can execute shell commands in the ephemeral Linux environment with the same permissions as a sandbox user. Additionally, the preview_link tool creates secure tunnels to expose local ports for web application testing.
Sources: apps/cli/mcp/README.md:113-131, apps/cli/mcp/server.go:53-55
Configuration and Integration
The integration process involves configuring the agent host to launch the Daytona CLI in "mcp start" mode.
Initialization Flow
The init command automates the configuration for supported agents like Claude, Cursor, and Windsurf by injecting the necessary JSON into the agent's configuration files.
The sequence shows how the daytona mcp init command modifies local agent configurations to enable the Daytona MCP Server.
Sources: apps/cli/cmd/mcp/init.go:17-48, apps/cli/cmd/mcp/config.go:61-75
Configuration Structure
The MCP configuration defines the command (daytona), arguments (mcp, start), and environment variables (like PATH and HOME) required to run the server. It also specifies a log file path for troubleshooting.
{
"command": "daytona",
"args": ["mcp", "start"],
"env": {
"HOME": "/user/home",
"PATH": "/usr/local/bin:..."
},
"logFile": "/path/to/daytona-mcp.log"
}
Sources: apps/cli/cmd/mcp/config.go:66-77, apps/cli/mcp/README.md:28-39
Multi-Agent Systems
The MCP Server facilitates complex architectures, such as a "Project Manager" agent running locally coordinating with a "Developer" agent running inside a Daytona sandbox. In this setup, the local agent uses the MCP tools to delegate code execution and file management tasks to the sandbox-bound agent.
Sources: guides/typescript/anthropic/multi-agent-claude-sdk/README.md:5-15
Conclusion
The Daytona MCP Server serves as a critical integration layer for AI-driven development. By exposing sandbox management and execution tools through the Model Context Protocol, it enables LLMs to transition from generating code snippets to actively managing and testing code within fully functional, isolated development environments.