MastraEditor class
The MastraEditor class sets up the editor system. Pass it to the Mastra constructor to turn on editor features like prompt blocks, agent code override, versioning, and tool providers.
See Editor for an introduction to what the editor does.
Usage exampleDirect link to Usage example
import { Mastra } from '@mastra/core'
import { MastraEditor } from '@mastra/editor'
export const mastra = new Mastra({
agents: {/* your agents */},
editor: new MastraEditor(),
})
Constructor parametersDirect link to Constructor parameters
logger?:
toolProviders?:
processorProviders?:
filesystems?:
sandboxes?:
blobStores?:
browsers?:
builder.features.agent.browser is enabled. See the BrowserProvider reference for the provider interface.builder?:
enabled: false to disable the Builder.source?:
codePath?:
Provider interfacesDirect link to Provider interfaces
Each provider field above takes a record keyed by provider id. See the per-provider reference pages for the implementation shape:
Agent BuilderDirect link to Agent Builder
The builder field enables the Agent Builder, a browser-based UI for creating and editing stored agents. See:
- Agent Builder overview: Concepts and getting started.
- AgentBuilderOptions: Full options schema.
- BuilderAgentDefaults: Admin-pinned defaults for new agents.
- builder.configuration.agent.models: Model allowlist and default model.
Registering the Builder agentDirect link to Registering the Builder agent
The Builder UI runs against an agent created by the createBuilderAgent() factory from @mastra/editor/ee. Import the factory, invoke it, and register the returned agent under agents on your Mastra instance:
import { Mastra } from '@mastra/core'
import { MastraEditor } from '@mastra/editor'
import { createBuilderAgent } from '@mastra/editor/ee'
export const mastra = new Mastra({
agents: { builderAgent: createBuilderAgent() },
editor: new MastraEditor({
builder: { enabled: true },
}),
})
The key name (builderAgent) is conventional. Any key works. The @mastra/editor/ee subpath is gated by the Mastra Enterprise Edition license at runtime.
See the Agent Builder overview for the full setup checklist.
NamespacesDirect link to Namespaces
The editor exposes namespaces for managing different entity types. Access them from any Mastra instance with mastra.getEditor() and call the CRUD methods directly in application code, or rely on the Mastra server routes that use them under the hood.
All namespaces extend a shared CRUD base class, so they expose the same create, getById, update, delete, list, listResolved, and clearCache methods. The namespace-specific property tables below also document any additional methods.
agent:
create:
getById:
update:
delete:
list:
listResolved:
applyStoredOverrides:
clone:
clearCache:
prompt:
create:
getById:
update:
delete:
list:
listResolved:
preview:
clearCache:
mcp:
create:
getById:
update:
delete:
list:
listResolved:
clearCache:
mcpServer:
create:
getById:
update:
delete:
list:
listResolved:
clearCache:
scorer:
create:
getById:
update:
delete:
list:
listResolved:
clearCache:
Agent namespace examplesDirect link to Agent namespace examples
Create a stored override for an existing code-defined agent:
import { mastra } from '../mastra'
const editor = mastra.getEditor()!
await editor.agent.create({
id: 'support-agent',
instructions: 'You are a friendly support agent for Acme.',
tools: {
search_kb: { description: 'Search the Acme knowledge base' },
},
})
MethodsDirect link to Methods
Provider accessDirect link to Provider access
getToolProvider(id)Direct link to gettoolproviderid
Returns a registered tool provider by its ID.
const composio = mastra.getEditor()?.getToolProvider('composio')
getToolProviders()Direct link to gettoolproviders
Returns all registered tool providers as a Record<string, ToolProvider>.
getProcessorProvider(id)Direct link to getprocessorproviderid
Returns a registered processor provider by its ID.
getProcessorProviders()Direct link to getprocessorproviders
Returns all registered processor providers.
getFilesystemProviders()Direct link to getfilesystemproviders
Returns all registered filesystem providers.
getSandboxProviders()Direct link to getsandboxproviders
Returns all registered sandbox providers.
getBlobStoreProviders()Direct link to getblobstoreproviders
Returns all registered blob store providers.
SourceDirect link to Source
getSource()Direct link to getsource
Returns the configured source ('code' or 'db'), or undefined when the editor was constructed without an explicit source.
const source = mastra.getEditor()?.getSource()
Returns: 'code' | 'db' | undefined
When source is omitted, Editor uses the configured database storage even though getSource() returns undefined. See Editor storage options for the storage workflows and code-source versioning for activation and Git history behavior.