plugin
AppKit plugin that builds one or more Mastra Agent instances and
mounts the @mastra/express server. Clients drive the conversation
over the standard Mastra agent stream (@mastra/client-js’s
getAgent(id).stream()), so there’s no bespoke chat transport to
keep in sync.
- Agents: registered through
config.agentsat plugin creation (MastraAgentDefinition). Each entry’stoolsfield accepts either a plain record or a(plugins) => toolscallback that gets a typed sibling-plugin index (MastraPlugins). Omitconfig.agentsto get a single built-indefaultanalyst. - Model: each agent call resolves a
MastraModelConfigvia buildModel from./model.js. Per-agentmodeloverrides (AgentConfig["model"]or amodelIdstring) flow through buildAgents. - Memory / storage: per-agent, built by createMemoryBuilder
from
./memory.js. Both auto-default totruewhen thelakebaseplugin is registered (unless the caller passedfalseor a custom config). Storage namespaces per agent via agentStorageSchemaName per agent; the vector store is a single shared singleton across every agent. - Server: the Express subapp wiring lives in
./server.js. - HTTP: AppKit mounts this plugin under
/api/mastra. Alongside the Mastra agent routes, the plugin registers/route/history(load + clear a thread’s messages),/route/threads(list the caller’s conversations + delete one),/models,/default-model,/suggestions,/route/feedback(log a thumbs / comment to MLflow when feedback is enabled), and the generic/embed/:type/:idresolver for inline chart / data markers. Each is registered through AppKit’sroute()so it lands in the plugin’s endpoint map, and every outbound call one makes runs throughexecute()(see./defaults.js). The stock@mastra/expresssurface is gated byconfig.apiAccess(default"scoped"): only agent inference, read-only agent metadata, the/route/*routes, and (when enabled) MCP are dispatched to Mastra; admin / mutating / bulk-export routes are refused with403. See isMastraRequestAllowed. - MCP: opt in with
config.mcpto expose the agents (and optionally tools) as a MastraMCPServer. It is registered on theMastrainstance viamcpServers, so@mastra/expressserves the stock MCP transport routes (/mcp/<serverId>/...) under the mount. See./mcp.js.