ssh_list_hosts
View all configured SSH hosts in your server fleet to manage access and monitor infrastructure connections.
Instructions
List configured hosts.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_ssh/mcp_server.py:862-872 (handler)The primary handler function for the 'ssh_list_hosts' MCP tool. It lists all configured SSH hosts from the global Config instance and returns them in a JSON-compatible dictionary. Errors are caught and returned as sanitized strings. The @mcp.tool() decorator handles MCP registration.@mcp.tool() def ssh_list_hosts() -> ToolResult: """List configured hosts.""" try: hosts = config.list_hosts() return {"hosts": hosts} except Exception as e: error_str = str(e) log_json({"level": "error", "msg": "list_hosts_exception", "error": error_str}) return f"Error: {sanitize_error(error_str)}"
- src/mcp_ssh/mcp_server.py:862-862 (registration)The @mcp.tool() decorator registers the ssh_list_hosts function as an MCP tool with FastMCP.@mcp.tool()
- src/mcp_ssh/mcp_server.py:13-19 (helper)Imports helper utilities used by ssh_list_hosts: log_json for error logging and sanitize_error for safe error messages.from mcp_ssh.tools.utilities import ( ASYNC_TASKS, TASKS, hash_command, log_json, sanitize_error, )