Bootstrap pyro_mcp v0.0.1 with MCP static tool and Ollama demo
This commit is contained in:
commit
11d6f4bcb4
18 changed files with 1945 additions and 0 deletions
35
src/pyro_mcp/demo.py
Normal file
35
src/pyro_mcp/demo.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"""Runnable demonstration for the static MCP tool."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
from collections.abc import Sequence
|
||||
|
||||
from mcp.types import TextContent
|
||||
|
||||
from pyro_mcp.server import HELLO_STATIC_PAYLOAD, create_server
|
||||
|
||||
|
||||
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 main() -> None:
|
||||
"""Run the demonstration and print the JSON payload."""
|
||||
payload = asyncio.run(run_demo())
|
||||
print(json.dumps(payload, indent=2, sort_keys=True))
|
||||
Loading…
Add table
Add a link
Reference in a new issue