Expose Python functions as executable capabilities for your MCP clients.
Tools are the core primitives that let an LLM reach outside its training data: query a database, hit an API, crunch numbers, or open a file. In Hyperia, a tool is just a Python function decorated with @mcp.tool() and surfaced through the Model Context Protocol.
What are Tools?
When an LLM decides to call a tool:
It sends a request containing parameters that match the tool’s input schema.
Hyperia validates those parameters against your function signature (types, constraints, defaults).
Your function executes with the validated inputs.
The result is returned to the LLM, which can use it to craft its next response.
That single loop enables powerful behaviours—calculations, searches, side‑effects—well beyond what the model “knows” natively.
The @tool Decorator
Creating a tool is as simple as decorating a function:
from hyperia import Hyperiamcp =Hyperia(name="CalculatorServer")@mcp.tool()defadd(a:int,b:int)->int:"""Adds two numbers."""return a + b
When registered, Hyperia automatically:
Uses the function name (add) as the tool name.
Uses the docstring as the description.
Generates a JSON input schema from type hints.
Handles validation and error reporting.
Note Variadic signatures (*args, **kwargs) are not supported—Hyperia must know every parameter to build a complete schema.
Parameter Basics
Type Annotations
Type hints are required for robust schemas and validation.
Rich Metadata with Annotated + Field
Use Annotated to attach Pydantic Field metadata—descriptions, ranges, regex, etc.—without polluting the default value column:
You can embed Field as the default value, but Annotated keeps type hints clear:
Supported Types
Hyperia supports nearly every Pydantic‑compatible type. A non‑exhaustive list:
from hyperia import Hyperia, ToolError
mcp = Hyperia("DivideDemo")
@mcp.tool()
def divide(a: float, b: float) -> float:
if b == 0:
raise ToolError("Division by zero is not allowed.")
return a / b