Fix appliance_install: add version parameter

This commit is contained in:
YueGuobin 2026-06-17 23:03:28 +08:00
parent 2e75c9319b
commit ead9747e1b
No known key found for this signature in database
2 changed files with 8 additions and 1 deletions

View File

@ -1284,6 +1284,7 @@ async def appliance_get(
@mcp.tool()
async def appliance_install(
appliance_id: Annotated[str, Field(description="UUID of the appliance to install")],
version: Annotated[str | None, Field(description="Version to install (e.g. '2.7.0.356'). Required if the appliance has multiple versions. Use appliance_get to see available versions.")] = None,
) -> list[dict[str, Any]]:
"""Create a template from a GNS3 appliance definition.
@ -1294,6 +1295,7 @@ async def appliance_install(
"""
return await asyncio.to_thread(_run_handler_sync, install_appliance_handler, {
"appliance_id": appliance_id,
"version": version,
})

View File

@ -80,5 +80,10 @@ def install_appliance_handler(params: dict[str, Any], gns3_ctx: dict[str, Any])
if not appliance_id:
return {"error": "appliance_id is required"}
conn = _get_connector(gns3_ctx)
result = conn.http_call("post", f"{conn.base_url}/appliances/{appliance_id}/install").json()
url = f"{conn.base_url}/appliances/{appliance_id}/install"
request_params = {}
version = params.get("version")
if version:
request_params["version"] = version
result = conn.http_call("post", url, params=request_params).json()
return {"message": f"Appliance {appliance_id} installation requested", "result": result}