Skip to main content
Glama
nwnusun-cool

MCP SSH Tools Server

by nwnusun-cool

execute

Execute commands on remote servers via SSH to manage systems, run scripts, and perform administrative tasks remotely.

Instructions

执行远程命令 参数:

  • server_name: 服务器名称 (如果只有一个服务器配置,可以使用 'default')

  • command: 要执行的命令

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
server_nameYes
commandYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:244-280 (handler)
    The primary handler for the 'execute' MCP tool. It connects to the specified SSH server and executes the given command, returning stdout, stderr, exit code, and success status.
    @mcp.tool()
    def execute(server_name: str, command: str) -> Dict[str, Any]:
        """
        执行远程命令
        参数:
        - server_name: 服务器名称 (如果只有一个服务器配置,可以使用 'default')
        - command: 要执行的命令
        """
        client = mcp_manager.get_connection(server_name)
        if not client:
            return {
                "success": False,
                "error": "SSH连接失败",
                "server": server_name
            }
        
        try:
            stdin, stdout, stderr = client.exec_command(command)
            exit_code = stdout.channel.recv_exit_status()
            stdout_content = stdout.read().decode('utf-8', 'replace')
            stderr_content = stderr.read().decode('utf-8', 'replace')
            
            return {
                "success": True,
                "server": server_name,
                "ip": mcp_manager.server_configs[server_name].ssh_ip,
                "exit_code": exit_code,
                "stdout": stdout_content,
                "stderr": stderr_content
            }
        except Exception as e:
            return {
                "success": False,
                "error": str(e),
                "server": server_name
            }
  • Input schema for the 'execute' tool defined by function signature (server_name: str, command: str) and docstring description. Output is Dict[str, Any] with success, stdout, stderr, etc.
    def execute(server_name: str, command: str) -> Dict[str, Any]:
        """
        执行远程命令
        参数:
        - server_name: 服务器名称 (如果只有一个服务器配置,可以使用 'default')
        - command: 要执行的命令
        """
  • main.py:244-244 (registration)
    Registration of the 'execute' tool via the FastMCP @mcp.tool() decorator, which automatically registers the function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does (execute remote commands) but doesn't disclose critical behavioral traits: whether this requires authentication, what permissions are needed, whether commands run with elevated privileges, what happens on execution failure, or any rate limits. The description is functionally accurate but lacks necessary operational context for a potentially dangerous tool.

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 appropriately concise with a clear purpose statement followed by parameter explanations. Each sentence adds value: the first establishes the core function, the second explains server_name with a useful tip, and the third defines command. No wasted words, though the structure could be slightly improved with bullet points or clearer formatting.

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 this is a potentially dangerous execution tool with no annotations, the description is moderately complete. It explains the basic function and parameters adequately, and the existence of an output schema means return values don't need description. However, for a tool that executes arbitrary commands on remote servers, it should include more safety warnings, permission requirements, and execution context to be fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds significant value by explaining both parameters: server_name (including the 'default' special case) and command (what to execute). This compensates well for the schema's lack of descriptions. However, it doesn't provide format details like command syntax restrictions or server_name validation rules that would be helpful for safe usage.

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 the tool's purpose as '执行远程命令' (execute remote command), which is a specific verb+resource combination. It distinguishes from siblings like list_servers or upload_file by focusing on command execution rather than configuration or file operations. However, it doesn't explicitly differentiate from potential similar tools like test_connection that might also involve server interaction.

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 minimal usage guidance, only mentioning that 'default' can be used if there's only one server configuration. It doesn't explain when to use this tool versus alternatives like test_connection for server verification, or provide context about prerequisites, security considerations, or typical use cases for remote command execution.

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/nwnusun-cool/mcp-server-ssh-tools'

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