Skip to main content

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 the Editor overview for an introduction to what the editor does.

Usage example
Direct link to Usage example

src/mastra/index.ts
import { Mastra } from '@mastra/core'
import { MastraEditor } from '@mastra/editor'
import { ComposioToolProvider } from '@mastra/editor/providers/composio'

export const mastra = new Mastra({
agents: {
/* your agents */
},
editor: new MastraEditor({
toolProviders: {
composio: new ComposioToolProvider({
apiKey: process.env.COMPOSIO_API_KEY!,
}),
},
}),
})

Constructor parameters
Direct link to Constructor parameters

logger?:

Logger
Logger instance. Falls back to the Mastra instance logger if not set.

toolProviders?:

Record<string, ToolProvider>
= {}
Integration tool providers keyed by ID (for example, Composio or Arcade). Lets agents use third-party tools added through the editor.

processorProviders?:

Record<string, ProcessorProvider>
= {}
Processor providers for configurable input/output processing (for example, moderation or token limiting). Built-in providers are always included.

filesystems?:

Record<string, FilesystemProvider>
= {}
Filesystem providers for file access (for example, S3 or GCS). A local filesystem provider is always included.

sandboxes?:

Record<string, SandboxProvider>
= {}
Sandbox providers for code execution (for example, E2B). A local sandbox provider is always included.

blobStores?:

Record<string, BlobStoreProvider>
= {}
Blob storage providers for binary data (for example, S3). Falls back to the Mastra storage blob store if no provider is specified.

Namespaces
Direct link to Namespaces

The editor exposes namespaces for managing different entity types. These are used by the Mastra server and Studio — you don't call them directly in application code.

agent:

EditorAgentNamespace
CRUD operations and version management for stored agents. Handles applying stored overrides to code-defined agents.

prompt:

EditorPromptNamespace
CRUD operations for prompt blocks. Includes a preview method for resolving instruction blocks with draft content.

mcp:

EditorMCPNamespace
CRUD operations for stored MCP client configurations.

mcpServer:

EditorMCPServerNamespace
CRUD operations for MCP server configurations.

scorer:

EditorScorerNamespace
CRUD operations for scorer configurations.

Methods
Direct link to Methods

Provider access
Direct 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.

On this page