fix: remove console_host/port from get_node_console_info

Return only ws_url + websocat command to avoid LLM misinterpreting
direct telnet connection.
This commit is contained in:
YueGuobin 2026-06-04 23:53:03 +08:00
parent 8775583b83
commit f34de4c075
No known key found for this signature in database
2 changed files with 9 additions and 10 deletions

View File

@ -283,7 +283,7 @@ async def update_node(project_id: str, node_id: str, **kwargs: Any) -> list[dict
@mcp.tool()
async def get_node_console_info(project_id: str, node_id: str) -> list[dict[str, Any]]:
"""Get console connection info for a node (host, port, type, and suggested command).
"""Get console WebSocket URL for a node (use websocat to connect).
Args:
project_id: Project UUID

View File

@ -144,20 +144,19 @@ def get_node_console_info_handler(params: dict[str, Any], gns3_ctx: dict[str, An
return {"error": "project_id and node_id are required"}
conn = _get_connector(gns3_ctx)
node = conn.get_node(project_id=project_id, node_id=node_id)
console_type = node.get("console_type", "unknown")
ws_url = f"{gns3_ctx['server_url']}/v3/projects/{project_id}/nodes/{node_id}/console/ws?token={gns3_ctx['jwt_token']}"
result = {
"node_id": node_id,
"node_name": node.get("name"),
"console_type": console_type,
"console_host": node.get("console_host"),
"console_port": node.get("console"),
"ws_url": ws_url,
"command": f"websocat {ws_url}",
}
if console_type == "telnet":
result["command"] = f"telnet {node.get('console_host')} {node.get('console')}"
elif console_type in ("vnc",):
result["command"] = f"vncviewer {node.get('console_host')}::{node.get('console')}"
elif console_type in ("http", "https"):
result["url"] = f"{console_type}://{node.get('console_host')}:{node.get('console')}"
if console_type in ("vnc",):
result["vnc_url"] = f"/v3/projects/{project_id}/nodes/{node_id}/console/vnc?token={gns3_ctx['jwt_token']}"
return result
@ -289,7 +288,7 @@ NODE_TOOLS = [
},
{
"name": "get_node_console_info",
"description": "Get console connection info for a node (host, port, type, and suggested command)",
"description": "Get console WebSocket URL for a node (use websocat to connect)",
"parameters": {
"type": "object",
"properties": {