Skip to main content
Glama
heresun

OrbStack MCP Server

by heresun

orbstack_machine_run

Execute commands on Linux machines within OrbStack, specifying target machines and users to run system operations and retrieve output.

Instructions

在 Linux 机器中执行命令并返回输出。

可以指定目标机器和执行用户。不指定机器时使用默认机器。

Args: params: 包含要执行的命令、可选的机器名和用户

Returns: str: 命令执行输出

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function for the `orbstack_machine_run` tool, which constructs the command arguments and executes them.
    async def orbstack_machine_run(params: MachineRunInput) -> str:
        """在 Linux 机器中执行命令并返回输出。
    
        可以指定目标机器和执行用户。不指定机器时使用默认机器。
    
        Args:
            params: 包含要执行的命令、可选的机器名和用户
    
        Returns:
            str: 命令执行输出
        """
        args = []
        if params.machine:
            args.extend(["-m", params.machine])
        if params.user:
            args.extend(["-u", params.user])
    
        # orb 命令直接接受要运行的命令
        args.extend(["run", "--"] + params.command.split())
  • MCP tool registration for `orbstack_machine_run` using the `@mcp.tool` decorator.
    @mcp.tool(
        name="orbstack_machine_run",
        annotations={
            "title": "在 Linux 机器中执行命令",
            "readOnlyHint": False,
            "destructiveHint": False,
            "idempotentHint": False,
            "openWorldHint": False,
        },
    )
  • Pydantic model defining the input parameters for `orbstack_machine_run`.
    class MachineRunInput(BaseModel):
        """在 Linux 机器中执行命令的输入参数"""
        model_config = ConfigDict(str_strip_whitespace=True, extra="forbid")
    
        command: str = Field(
            ...,
            description="要执行的命令,如 'uname -a', 'ls -la /home' 等",
            min_length=1,
        )
        machine: Optional[str] = Field(
            default=None,
            description="目标机器名称,不指定则使用默认机器",
        )
        user: Optional[str] = Field(
            default=None,
            description="执行命令的用户,如 root",
        )

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