Refract a Python function into multiple interfaces: REST API, CLI, MCP tools, and Web UI
Refract demonstrates solid tool definition practices with clear naming, consistent descriptions, and proper parameter schemas. All 6 tools follow verb_noun conventions (add, greet, search, bmi, summarize, stream_words). Descriptions are present and actionable (avg ~80 chars). Input schemas use proper JSON Schema with types and descriptions for all parameters. However, output schemas are not explicitly documented in the tool definitions, only inferred from return type annotations. Parameter descriptions could be more prescriptive about constraints (e.g., search limit bounds, BMI height/weight ranges). No tool annotations (readOnlyHint, destructiveHint) are present despite all tools being READ_ONLY. Error handling and recovery guidance are absent.
Add two numbers.
Calculate Body Mass Index (BMI). Demonstrates float and bool params.
Greet someone with a custom message.
Search items. Uses GET only, Literal param becomes a select in the UI.
Stream text word by word via SSE. Demonstrates the streaming interface.
Summarize text. Async function — exposed on API and MCP only (no CLI).
Output schemas not documented in tool definitions. Return types are inferred from Python type hints (Sum, Greeting, SearchResult, etc.) but not explicitly exposed in the MCP tool schema. LLMs cannot see what fields to expect without inspecting the code.
No tool annotations (readOnlyHint, destructiveHint, idempotentHint) despite all tools being marked READ_ONLY. MCP spec allows tools to declare their safety profile; this metadata is missing.
Parameter constraints not fully specified. 'search' limit defaults to 5 but no min/max bounds documented. 'bmi' height_m and weight_kg lack realistic ranges (e.g., 0.5 - 3.0m, 10 - 500kg). LLMs may pass invalid values.
Inferred effective spec: <=2025-11-25.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-23 | C | 67 | <=2025-11-25 | v2 |
No error handling or recovery guidance. Tools have no documented failure modes, validation errors, or actionable error messages. If an LLM passes invalid input, there is no guidance on what to do next.
stream_words description is vague about streaming semantics. Does it return the full text immediately or only after streaming completes? What does the StreamResult contain? Streaming interface expectations are unclear.