examples/server-fastify-adapter/README.md
This example demonstrates how to use the @mastra/fastify server adapter to run Mastra with Fastify.
MastraServerinit() with access to Mastra contextrequest.mastrapnpm install
.env.example to .env and add your OpenAI API key:cp .env.example .env
pnpm start
List agents:
curl http://localhost:4111/api/agents
Health check (custom route):
curl http://localhost:4111/health
Generate a response:
curl -X POST http://localhost:4111/api/agents/assistantAgent/generate \
-H "Content-Type: application/json" \
-d '{"messages": "What is 2+2?"}'
request.mastra (extended Fastify request)