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

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()

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