fix: accept the 'local' compute id in compute tools

The compute_get/compute_images MCP tools typed compute_id as a UUID, so
passing 'local' (the actual id of the built-in compute, which the
compute_images description itself pointed to) was rejected by schema
validation. Both tools now take a string defaulting to 'local', and the
compute_get REST route resolves 'local' through the controller since the
local compute has no database entry.
This commit is contained in:
YueGuobin committed 2026-08-26 00:44:57 +08:00
1 parent 6703e50487
commit df25e037ea
5 files changed
+63 -16

No files matched your search

+5 -1
View File
@@ -54,8 +54,12 @@ class ComputesService:
self._controller.notification.controller_emit("compute.created", compute.asdict())
return db_compute
async def get_compute(self, compute_id: Union[str, UUID]) -> models.Compute:
async def get_compute(self, compute_id: Union[str, UUID]) -> Union[models.Compute, dict]:
if str(compute_id) == "local":
# the built-in local compute only lives in the controller, not in the database;
# drop unset fields (e.g. user) as the response schema types them as str
return {k: v for k, v in self._controller.get_compute("local").asdict().items() if v is not None}
db_compute = await self._computes_repo.get_compute(compute_id)
if not db_compute:
raise ControllerNotFoundError(f"Compute '{compute_id}' not found")