Run your Hyperia server locally or in production using STDIO , Streamable HTTP , or (legacy) SSE transports.
Hyperia servers can be started:
In‑code via mcp.run() / mcp.run_async().
From the CLI with hyperia run or hyperia dev.
Inside ASGI stacks (covered in Advanced ASGI Integration ).
This guide focuses on the built‑in runner and CLI.
1 · run() – the one‑liner
Place the call in a __main__ guard so importing the module doesn’t auto‑start the server:
Copy # my_server.py
from hyperia import Hyperia
mcp = Hyperia ( " MyServer " )
@ mcp . tool ()
def hello ( name : str ):
return f "Hello, { name } !"
if __name__ == " __main__ " :
mcp . run () # defaults to stdio transport Run:
run() arguments:
If your script is already async, use await mcp.run_async(...).
Calling blocking run() inside an event loop will raise an error.
2 · Hyperia CLI
The CLI bypasses the __main__ guard and hunts for an object named mcp, server, or app.
Override transport on the fly:
Development mode (auto‑reload + Inspector):
See hyperia --help for all flags.
3 · Choosing a Transport
Transport
Ideal For
Pros
Cons
Local tools, IDEs (Cursor, Claude Desktop)
Zero config; client spawns per‑session
Server code runs on client machine (security); not network‑shareable
Web/API deployments, containers, microservices
Stateless option, efficient streaming, easily load‑balanced
Requires open port + reverse proxy in prod
Older setups reliant on EventSource
Deprecated – prefer Streamable HTTP
STDIO example (explicit)
Clients typically launch the server themselves; no extra config needed.
Streamable HTTP example
Starts Uvicorn under the hood. Deploy behind nginx/Traefik or a cloud LB.
SSE (deprecated)
Use only for backward compatibility; new projects should migrate.
4 · Custom Routes
Need a quick health‑check? Add routes without a full ASGI framework:
For complex web apps, mount the Hyperia ASGI app inside FastAPI/Starlette instead.
5 · Deployment Tips
Docker – pip install hyperia && python my_server.py --transport streamable-http --host 0.0.0.0 in CMD.
Kubernetes – expose port, add readiness probe hitting /health.
Serverless – wrap the ASGI app in an adapter (AWS Lambda + Lambda‑Powertools, GCP Cloud Run, etc.).
TLS/Certs – terminate at ingress/proxy; Hyperia’s built‑in Uvicorn runner is HTTP only.
run() / run_async() for code‑driven starts, hyperia run for CLI flexibility. Streamable HTTP is the recommended production transport; STDIO remains perfect for local tool execution.
Last updated 7 months ago