
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
@mastra/fastify
Advanced tools
Affected versions:
Fastify server adapter for Mastra, enabling you to run Mastra with the Fastify framework.
npm install @mastra/fastify fastify
import Fastify from 'fastify';
import { MastraServer } from '@mastra/fastify';
import { mastra } from './mastra';
const app = Fastify({ logger: true });
const server = new MastraServer({ app, mastra });
await server.init();
app.listen({ port: 3000 }, (err, address) => {
if (err) {
console.error(err);
process.exit(1);
}
console.log(`Server running on ${address}`);
});
Add routes directly to the Fastify app with access to Mastra context:
// Routes added after init() have access to Mastra context
app.get('/health', async request => {
const mastraInstance = request.mastra;
const agents = Object.keys(mastraInstance.listAgents());
return { status: 'ok', agents };
});
const server = new MastraServer({
app,
mastra,
prefix: '/api/v2', // Route prefix
openapiPath: '/openapi.json', // OpenAPI spec endpoint
bodyLimitOptions: {
maxSize: 10 * 1024 * 1024, // 10MB
onError: err => ({ error: 'Payload too large' }),
},
streamOptions: { redact: true }, // Redact sensitive data from streams
});
Access these in route handlers via request:
| Key | Description |
|---|---|
mastra | Mastra instance |
requestContext | Request context map |
abortSignal | Request cancellation signal |
tools | Available tools |
For multipart file uploads, register @fastify/multipart:
import multipart from '@fastify/multipart';
await app.register(multipart);
FAQs
Mastra Fastify adapter for the server
The npm package @mastra/fastify receives a total of 12,784 weekly downloads. As such, @mastra/fastify popularity was classified as popular.
We found that @mastra/fastify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.