Overview
The Config interface defines all the optional components that can be registered with a Mastra instance, including agents, workflows, storage, logging, and more.
Type Parameters
TAgents
Record<string, Agent>
default:"Record<string, Agent>"
Record of agent instances keyed by their names
TWorkflows
Record<string, Workflow>
default:"Record<string, Workflow>"
Record of workflow instances
TVectors
Record<string, MastraVector>
default:"Record<string, MastraVector>"
Record of vector store instances
TTTS
Record<string, MastraTTS>
default:"Record<string, MastraTTS>"
Record of text-to-speech instances
TLogger
IMastraLogger
default:"IMastraLogger"
Logger implementation type
TMCPServers
Record<string, MCPServerBase>
default:"Record<string, MCPServerBase>"
Record of MCP server instances
TScorers
Record<string, MastraScorer>
default:"Record<string, MastraScorer>"
Record of scorer instances
TTools
Record<string, ToolAction>
default:"Record<string, ToolAction>"
Record of tool instances
TProcessors
Record<string, Processor>
default:"Record<string, Processor>"
Record of processor instances
TMemory
Record<string, MastraMemory>
default:"Record<string, MastraMemory>"
Record of memory instances
Properties
agents
agents?: { [K in keyof TAgents]: TAgents[K] | ToolLoopAgentLike }
Agents are autonomous systems that can make decisions and take actions. Accepts both Mastra Agent instances and AI SDK v6 ToolLoopAgent instances. ToolLoopAgent instances are automatically converted to Mastra Agents.
storage
storage?: MastraCompositeStore
Storage provider for persisting data, conversation history, and workflow state. Required for agent memory and workflow persistence.
vectors
Vector stores for semantic search and retrieval-augmented generation (RAG). Used for storing and querying embeddings.
logger
Logger implementation for application logging and debugging. Set to false to disable logging entirely. Defaults to INFO level in development, WARN in production.
workflows
Workflows provide type-safe, composable task execution with built-in error handling.
tts
Text-to-speech providers for voice synthesis capabilities.
observability
observability?: ObservabilityEntrypoint
Observability entrypoint for tracking model interactions and tracing. Pass an instance of the Observability class from @mastra/observability.
Example:
import { Observability, DefaultExporter, CloudExporter, SensitiveDataFilter } from '@mastra/observability';
new Mastra({
observability: new Observability({
configs: {
default: {
serviceName: 'mastra',
exporters: [new DefaultExporter(), new CloudExporter()],
spanOutputProcessors: [new SensitiveDataFilter()],
},
},
})
})
idGenerator
idGenerator?: MastraIdGenerator
Custom ID generator function for creating unique identifiers. Defaults to crypto.randomUUID().
deployer
deployer?: MastraDeployer
Deployment provider for publishing applications to cloud platforms.
server
Server configuration for HTTP endpoints and middleware.
mcpServers
MCP servers provide tools and resources that agents can use.
bundler
Bundler configuration for packaging and deployment.
pubsub
Pub/sub system for event-driven communication between components. Defaults to EventEmitterPubSub.
scorers
Scorers help assess the quality of agent responses and workflow outputs.
Tools are reusable functions that agents can use to interact with external systems.
processors
Processors transform inputs and outputs for agents and workflows.
memory
Memory instances that can be referenced by stored agents. Keys are used to look up memory instances when resolving stored agent configurations.
workspace
Global workspace for file storage, skills, and code execution. Agents inherit this workspace unless they have their own configured. Skills are accessed via workspace.skills when skills are configured.
gateways
gateways?: Record<string, MastraModelGateway>
Custom model router gateways for accessing LLM providers. Gateways handle provider-specific authentication, URL construction, and model resolution.
events
events?: {
[topic: string]: (event: Event, cb?: () => Promise<void>) => Promise<void>
}
Event handlers for custom application events. Maps event topics to handler functions for event-driven architectures.
editor
Editor instance for handling agent instantiation and configuration. The editor handles complex instantiation logic including memory resolution.
Example
import { Mastra, type Config } from '@mastra/core';
import { Agent } from '@mastra/core/agent';
import { LibSQLStore } from '@mastra/libsql';
import { PineconeVector } from '@mastra/pinecone';
import { PinoLogger } from '@mastra/pino';
const config: Config = {
agents: {
assistant: new Agent({
id: 'assistant',
name: 'Assistant',
instructions: 'You are a helpful assistant',
model: 'openai/gpt-5'
})
},
storage: new LibSQLStore({
id: 'mastra-storage',
url: process.env.DATABASE_URL
}),
vectors: {
knowledge: new PineconeVector({
apiKey: process.env.PINECONE_API_KEY,
indexName: 'knowledge-base'
})
},
logger: new PinoLogger({ name: 'MyApp' }),
workflows: {
dataProcessor: myWorkflow
}
};
const mastra = new Mastra(config);