Skip to main content
Glama
nwnusun-cool

MCP SSH Tools Server

by nwnusun-cool

execute

Run remote commands on servers via SSH using the MCP SSH Tools Server. Specify the server name and the command to execute, streamlining server management tasks efficiently.

Instructions

执行远程命令 参数:

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

  • command: 要执行的命令

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYes
server_nameYes

Implementation Reference

  • main.py:244-280 (handler)
    The handler function for the MCP 'execute' tool. It uses @mcp.tool() decorator for registration and implements execution of remote SSH commands, handling connection, command execution, and returning structured results including stdout, stderr, exit code, and error handling.
    @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 documentation in the docstring of the execute function, describing parameters: server_name (str) and command (str). Type hints: server_name: str, command: str -> Dict[str, Any].
    """ 执行远程命令 参数: - server_name: 服务器名称 (如果只有一个服务器配置,可以使用 'default') - command: 要执行的命令 """
  • main.py:244-244 (registration)
    Registration of the 'execute' tool via the @mcp.tool() decorator, which registers the subsequent function as an MCP tool (name inferred from function name).
    @mcp.tool()

Other Tools

Related 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