Bundle firecracker runtime and switch ollama demo to live logs

This commit is contained in:
Thales Maciel 2026-03-05 20:20:36 -03:00
parent ef0ddeaa11
commit 65f7c0d262
26 changed files with 1896 additions and 408 deletions

View file

@ -1,35 +1,23 @@
"""Runnable demonstration for the static MCP tool."""
"""Runnable deterministic demo for VM lifecycle tools."""
from __future__ import annotations
import asyncio
import json
from collections.abc import Sequence
from typing import Any
from mcp.types import TextContent
from pyro_mcp.server import HELLO_STATIC_PAYLOAD, create_server
from pyro_mcp.vm_manager import VmManager
async def run_demo() -> dict[str, str]:
"""Call the static MCP tool and return its structured payload."""
server = create_server()
result = await server.call_tool("hello_static", {})
blocks, structured = result
are_text_blocks = all(isinstance(item, TextContent) for item in blocks)
if not isinstance(blocks, Sequence) or not are_text_blocks:
raise TypeError("unexpected MCP content block output")
if not isinstance(structured, dict):
raise TypeError("expected a structured dictionary payload")
if structured != HELLO_STATIC_PAYLOAD:
raise ValueError("static payload did not match expected value")
typed: dict[str, str] = {str(key): str(value) for key, value in structured.items()}
return typed
def run_demo() -> dict[str, Any]:
"""Create/start/exec/delete a VM and return command output."""
manager = VmManager()
created = manager.create_vm(profile="debian-git", vcpu_count=1, mem_mib=512, ttl_seconds=600)
vm_id = str(created["vm_id"])
manager.start_vm(vm_id)
executed = manager.exec_vm(vm_id, command="git --version", timeout_seconds=30)
return executed
def main() -> None:
"""Run the demonstration and print the JSON payload."""
payload = asyncio.run(run_demo())
print(json.dumps(payload, indent=2, sort_keys=True))
"""Run the deterministic lifecycle demo."""
print(json.dumps(run_demo(), indent=2, sort_keys=True))