mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-10-23 19:32:24 +03:00
fix: Type compute_id as uuid.UUID to reject non-UUID values at MCP input layer
Previously compute_id was typed as str, so 'local' would pass MCP validation and reach the controller API where it crashed. Now uuid.UUID type ensures Pydantic rejects any non-UUID string before the handler runs.
This commit is contained in:
parent
67fa65a9e0
commit
8b014693a8
@ -31,6 +31,7 @@ import json
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import socket
|
import socket
|
||||||
|
import uuid
|
||||||
from typing import Any, Annotated
|
from typing import Any, Annotated
|
||||||
from urllib.parse import parse_qs
|
from urllib.parse import parse_qs
|
||||||
|
|
||||||
@ -610,7 +611,7 @@ async def compute_list() -> list[dict[str, Any]]:
|
|||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def compute_get(
|
async def compute_get(
|
||||||
compute_id: Annotated[str, Field(description="Compute UUID from compute_list output")],
|
compute_id: Annotated[uuid.UUID, Field(description="Compute UUID from compute_list output")],
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""Get detailed information about a compute node. Use compute_list first to get the UUID."""
|
"""Get detailed information about a compute node. Use compute_list first to get the UUID."""
|
||||||
return await asyncio.to_thread(_run_handler_sync, get_compute_handler, {"compute_id": compute_id})
|
return await asyncio.to_thread(_run_handler_sync, get_compute_handler, {"compute_id": compute_id})
|
||||||
@ -619,7 +620,7 @@ async def compute_get(
|
|||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def compute_images(
|
async def compute_images(
|
||||||
emulator: Annotated[str, Field(description="Emulator type (e.g. qemu, iou, docker)")],
|
emulator: Annotated[str, Field(description="Emulator type (e.g. qemu, iou, docker)")],
|
||||||
compute_id: Annotated[str, Field(description="Compute UUID from compute_list output")],
|
compute_id: Annotated[uuid.UUID, Field(description="Compute UUID from compute_list output")],
|
||||||
) -> list[dict[str, Any]]:
|
) -> list[dict[str, Any]]:
|
||||||
"""List available images for an emulator on a compute node."""
|
"""List available images for an emulator on a compute node."""
|
||||||
return await asyncio.to_thread(_run_handler_sync, get_compute_images_handler, {
|
return await asyncio.to_thread(_run_handler_sync, get_compute_images_handler, {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user