Skip to main content

ProcessorProvider

ProcessorProvider is the interface a package implements to register a configurable processor with MastraEditor. Processor providers serve two purposes:

  1. Discovery — the UI uses info, configSchema, and availablePhases to render configuration forms.
  2. Runtime — the editor calls createProcessor(config) during agent hydration to instantiate processors from stored configuration.

Providers are supplied via MastraEditorConfig.processorProviders.

Usage example
Direct link to Usage example

src/mastra/index.ts
import { MastraEditor } from '@mastra/editor'
import { moderationProcessorProvider } from '@mastra/processors/moderation'

new MastraEditor({
processorProviders: {
moderation: moderationProcessorProvider,
},
})

Properties
Direct link to Properties

info:

ProcessorProviderInfo
Metadata about the provider.

id:

string
Unique identifier (for example, `"moderation"`, `"token-limiter"`).

name:

string
Human-readable name.

description?:

string
Short description of the provider.

configSchema:

ZodSchema
Zod schema describing the configuration this provider accepts. Used by the UI to render a form. The validated config object is passed to `createProcessor()`.

availablePhases:

ProcessorPhase[]
Phases this provider's processors support. One or more of `'processInput'`, `'processInputStep'`, `'processOutputStream'`, `'processOutputResult'`, `'processOutputStep'`.

createProcessor:

(config: Record<string, unknown>) => Processor
Create a `Processor` instance from the validated configuration. Called during agent hydration to resolve stored processor configs into live instances.

Implementing a provider
Direct link to Implementing a provider

src/providers/my-processor.ts
import type { ProcessorProvider } from '@mastra/core/processor-provider'
import { z } from 'zod'
import { MyProcessor } from './my-processor-impl'

export const myProcessorProvider: ProcessorProvider = {
info: {
id: 'my-processor',
name: 'My Processor',
description: 'Filters output for sensitive content.',
},
configSchema: z.object({
threshold: z.number().min(0).max(1),
}),
availablePhases: ['processOutputStream', 'processOutputResult'],
createProcessor(config) {
return new MyProcessor(config as { threshold: number })
},
}
On this page