examples/server-express-adapter/README.md
This example demonstrates how to use the @mastra/express server adapter to run Mastra with Express.
MastraServerexpress.json() middleware for body parsinginit() with access to Mastra contextres.localspnpm 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?"}'
express.json() middleware for JSON body parsingres.locals instead of c.get()