Skip to main content
Glama
heresun

OrbStack MCP Server

by heresun

orbstack_docker_run

Create and run Docker containers with port mapping, volume mounts, and environment variable configuration through OrbStack MCP Server.

Instructions

创建并运行一个新的 Docker 容器。

支持端口映射、卷挂载、环境变量等配置。

Args: params: 容器运行参数

Returns: str: 容器 ID 或运行输出

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The implementation of the `orbstack_docker_run` tool. It constructs the docker command arguments and executes them using `_run_docker`.
    async def orbstack_docker_run(params: DockerRunInput) -> str:
        """创建并运行一个新的 Docker 容器。
    
        支持端口映射、卷挂载、环境变量等配置。
    
        Args:
            params: 容器运行参数
    
        Returns:
            str: 容器 ID 或运行输出
        """
        args = ["run"]
        if params.detach:
            args.append("-d")
        if params.name:
            args.extend(["--name", params.name])
        if params.platform:
            args.extend(["--platform", params.platform])
        if params.ports:
            for port in params.ports:
                args.extend(["-p", port])
        if params.volumes:
            for vol in params.volumes:
                args.extend(["-v", vol])
        if params.env:
            for e in params.env:
                args.extend(["-e", e])
        args.append(params.image)
        if params.command:
            args.extend(params.command.split())
    
        code, stdout, stderr = await _run_docker(args, timeout=120)
        if code != 0:
            return _format_error(stderr)
        container_id = stdout[:12] if len(stdout) >= 12 else stdout
        display_name = params.name or container_id
        return f"容器 '{display_name}' 已启动\n容器ID: {container_id}"
    
    
    @mcp.tool(
        name="orbstack_docker_stop",
        annotations={
  • The MCP tool registration for `orbstack_docker_run` using the `@mcp.tool` decorator.
    @mcp.tool(
        name="orbstack_docker_run",
        annotations={
            "title": "运行 Docker 容器",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "openWorldHint": True,
        },
    )
  • The `DockerRunInput` schema definition using Pydantic, which defines the input parameters for the `orbstack_docker_run` tool.
    class DockerRunInput(BaseModel):
        """运行 Docker 容器的输入参数"""
        model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
    
        image: str = Field(
            ...,
            description="Docker 镜像名称,如 nginx:latest, ubuntu:22.04",
            min_length=1,
        )
        name: Optional[str] = Field(
            default=None,
            description="容器名称",
        )
        ports: Optional[List[str]] = Field(
            default=None,
            description="端口映射列表,如 ['8080:80', '443:443']",
        )
        volumes: Optional[List[str]] = Field(
            default=None,
            description="卷挂载列表,如 ['/host/path:/container/path']",
        )
        env: Optional[List[str]] = Field(
            default=None,
            description="环境变量列表,如 ['KEY=VALUE']",
        )
        detach: bool = Field(
            default=True,
            description="是否后台运行,默认为 True",
Behavior3/5

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

Annotations indicate readOnlyHint=false (mutation), openWorldHint=true (flexible inputs), idempotentHint=false (non-idempotent), and destructiveHint=false (non-destructive). The description adds that it '支持端口映射、卷挂载、环境变量等配置' (supports port mapping, volume mounting, environment variables, etc.), which provides useful context about configurability beyond annotations. However, it doesn't mention potential side effects like resource consumption, network exposure, or that it might fail if the image doesn't exist locally.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, support features, Args, Returns). It's front-loaded with the main purpose, and each sentence adds value. However, the 'Args' section is redundant with the schema and could be more concise by integrating with the feature list.

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?

Given the tool's complexity (creating/running containers with multiple config options), annotations cover safety aspects, and the output schema exists (implied by 'Returns: str'), so the description doesn't need to detail return values. However, it lacks guidance on usage context, error conditions, or dependencies (e.g., Docker daemon running), making it minimally adequate but with gaps for a mutation tool.

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?

Schema description coverage is 0%, but the description has an 'Args:' section listing 'params: 容器运行参数' (container run parameters). This adds minimal semantic value beyond the schema's detailed property descriptions (image, ports, volumes, etc.). The description doesn't explain parameter interactions or provide examples of the 'params' object structure, leaving the schema to carry most of the burden.

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 '创建并运行一个新的 Docker 容器' (create and run a new Docker container), which is a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'orbstack_docker_pull' (which pulls images) or 'orbstack_docker_restart' (which restarts existing containers), though the 'new' aspect implies creation rather than management of existing containers.

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 (e.g., needing an image pulled first), when to use 'orbstack_docker_exec' for running commands in existing containers, or when 'orbstack_compose_up' might be better for multi-container setups. The lack of context leaves the agent guessing about appropriate use cases.

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

Install Server

Other Tools

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/heresun/orbstack-mcp'

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