Mastra Voice Agent in Node.js
@micdrop/mastra answers a call with an agent built with
Mastra. It keeps everything the agent already has: its
instructions, model, tools, workflows and memory.
Installation
npm install @micdrop/mastra @mastra/coreUsage
import { Agent } from '@mastra/core/agent'import { MastraAgent } from '@micdrop/mastra'import { endCallTool, MicdropServer } from '@micdrop/server'
const supportAgent = new Agent({ id: 'support', name: 'Support', instructions: 'You help customers with their orders. Answer in short spoken sentences.', model: 'openai/gpt-5-mini', tools: { getOrder },})
new MicdropServer(socket, { stt, tts, agent: new MastraAgent({ agent: supportAgent, tools: [endCallTool()], }),})The answer reaches the voice as the agent writes it. The tools the Mastra agent
runs are recorded in the conversation of the call, so the client and your
transcripts see them. The tools of the call, such as endCallTool(),
handoffTool() or MCP tools, are added to the agent’s
own.
Memory
With memory, the call goes into a thread of the agent’s memory. Mastra holds
the history, and each answer sends only what was said since the last one:
new MastraAgent({ agent: supportAgent, memory: { thread: callId, resource: customerId },})Working memory and semantic recall then work during the call as they do in
chat. Without memory, the whole conversation is sent at each answer.
Options
| Option | Type | Description |
|---|---|---|
agent | Agent of Mastra | The agent answering |
systemPrompt | string | Added to its instructions for this call |
memory | { thread, resource } | Keeps the call in a thread of the agent’s memory |
streamOptions | options of stream() | Any other option, such as maxSteps or modelSettings |
tools | Tool[] | Tools of the call, added to the agent’s own |
transforms | AnswerTransform[] | Rework the answers, see extract |
A spoken answer starts sooner with reasoning off: set it in modelSettings or
in the providerOptions of streamOptions, as the model accepts.