mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-27 12:30:13 +03:00
fix: correct MCP nodes and links tool parameter handling for nested kwargs
Extended the kwargs parameter handling fix to nodes and links MCP tools, which had the same nested kwargs structure issue as templates. Changes: - Modified update_node_handler to extract params from nested kwargs - Modified update_link_handler to extract params from nested kwargs This ensures that node and link updates through MCP tools work correctly, allowing proper modification of node and link properties.
This commit is contained in:
parent
0d22d275fb
commit
3ba11c8bff
@ -94,7 +94,13 @@ def update_link_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) -> dic
|
||||
if not project_id or not link_id:
|
||||
return {"error": "project_id and link_id are required"}
|
||||
conn = _get_connector(gns3_ctx)
|
||||
update_data = {k: v for k, v in params.items() if k not in ("project_id", "link_id")}
|
||||
|
||||
# Extract update parameters - handle nested kwargs structure from MCP clients
|
||||
if "kwargs" in params and isinstance(params["kwargs"], dict):
|
||||
update_data = params["kwargs"]
|
||||
else:
|
||||
update_data = {k: v for k, v in params.items() if k not in ("project_id", "link_id", "kwargs")}
|
||||
|
||||
url = f"{conn.base_url}/projects/{project_id}/links/{link_id}"
|
||||
return conn.http_call("put", url, json_data=update_data).json()
|
||||
|
||||
|
||||
@ -132,7 +132,13 @@ def update_node_handler(params: dict[str, Any], gns3_ctx: dict[str, Any]) -> dic
|
||||
if not project_id or not node_id:
|
||||
return {"error": "project_id and node_id are required"}
|
||||
conn = _get_connector(gns3_ctx)
|
||||
update_data = {k: v for k, v in params.items() if k not in ("project_id", "node_id")}
|
||||
|
||||
# Extract update parameters - handle nested kwargs structure from MCP clients
|
||||
if "kwargs" in params and isinstance(params["kwargs"], dict):
|
||||
update_data = params["kwargs"]
|
||||
else:
|
||||
update_data = {k: v for k, v in params.items() if k not in ("project_id", "node_id", "kwargs")}
|
||||
|
||||
url = f"{conn.base_url}/projects/{project_id}/nodes/{node_id}"
|
||||
return conn.http_call("put", url, json_data=update_data).json()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user