- Create REST and streaming endpoints for agents and workflows
- Access telemetry and observability data via HTTP
- Run the Mastra development UI with
mastra dev - Deploy your agents as production-ready HTTP services
Package Architecture
The server package consists of two main components:Handlers
Framework-agnostic handler functions that accept aMastra instance and request context. These are exported from @mastra/server/handlers and include:
- agents - List agents, retrieve metadata, and run
generateorstream - workflows - Start and inspect workflow runs
- tools - Discover available tools
- memory - Interact with memory stores
- logs - Query runtime logs
- observability - Expose telemetry metrics
- vectors - Vector store operations
- voice - Voice synthesis endpoints
Server Adapters
Framework-specific implementations that integrate handlers with popular HTTP frameworks:- @mastra/hono - Hono adapter
- @mastra/express - Express adapter
- @mastra/koa - Koa adapter
- @mastra/fastify - Fastify adapter
Installation
Install the server package and your preferred adapter:Quick Start
Here’s a minimal example using the Hono adapter:GET /api/agents- List all agentsPOST /api/agents/:agentId/generate- Generate agent responsePOST /api/agents/:agentId/stream- Stream agent responsePOST /api/workflows/:workflowId/execute- Execute workflow- And many more…
Server Configuration
TheMastraServer constructor accepts these options:
Running the Development UI
Themastra dev CLI command starts a local development server with a web UI:
http://localhost:3000 using the handlers from this package, providing a visual interface to:
- Test agents interactively
- Execute workflows
- View logs and telemetry
- Explore available tools
Next Steps
Creating a Server
Learn how to set up an HTTP server for your agents
Routes & Handlers
Understand the available routes and handlers
Server Adapters
Choose and configure a server adapter
Middleware
Add authentication and custom middleware