@mastra/mcp-docs-server 1.1.42-alpha.8 → 1.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agent-builder/memory.md +1 -1
- package/.docs/docs/agents/a2a.md +1 -1
- package/.docs/docs/agents/acp.md +4 -4
- package/.docs/docs/agents/adding-voice.md +7 -7
- package/.docs/docs/agents/agent-approval.md +1 -1
- package/.docs/docs/agents/background-tasks.md +2 -2
- package/.docs/docs/agents/channels.md +1 -1
- package/.docs/docs/agents/code-mode.md +3 -3
- package/.docs/docs/agents/guardrails.md +2 -2
- package/.docs/docs/agents/networks.md +1 -1
- package/.docs/docs/agents/overview.md +1 -1
- package/.docs/docs/agents/processors.md +3 -3
- package/.docs/docs/agents/response-caching.md +1 -1
- package/.docs/docs/agents/sdk-agents.md +261 -0
- package/.docs/docs/agents/signals.md +1 -1
- package/.docs/docs/agents/structured-output.md +5 -5
- package/.docs/docs/agents/supervisor-agents.md +2 -2
- package/.docs/docs/agents/using-tools.md +5 -5
- package/.docs/docs/browser/agent-browser.md +1 -1
- package/.docs/docs/browser/browser-viewer.md +1 -1
- package/.docs/docs/browser/overview.md +1 -1
- package/.docs/docs/browser/stagehand.md +5 -5
- package/.docs/docs/editor/overview.md +1 -1
- package/.docs/docs/evals/custom-scorers.md +1 -1
- package/.docs/docs/evals/datasets/running-experiments.md +1 -1
- package/.docs/docs/evals/overview.md +2 -2
- package/.docs/docs/mcp/mcp-apps.md +3 -3
- package/.docs/docs/mcp/overview.md +1 -1
- package/.docs/docs/memory/memory-processors.md +6 -6
- package/.docs/docs/memory/multi-user-threads.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +1 -1
- package/.docs/docs/memory/storage.md +2 -1
- package/.docs/docs/memory/working-memory.md +1 -1
- package/.docs/docs/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/docs/observability/tracing/exporters/langsmith.md +2 -2
- package/.docs/docs/rag/graph-rag.md +2 -2
- package/.docs/docs/rag/retrieval.md +12 -12
- package/.docs/docs/server/auth/fga.md +2 -0
- package/.docs/docs/server/mastra-client.md +1 -1
- package/.docs/docs/server/request-context.md +3 -3
- package/.docs/docs/streaming/overview.md +1 -1
- package/.docs/docs/streaming/tool-streaming.md +1 -1
- package/.docs/docs/voice/overview.md +25 -25
- package/.docs/docs/voice/speech-to-speech.md +4 -4
- package/.docs/docs/voice/speech-to-text.md +1 -1
- package/.docs/docs/voice/text-to-speech.md +1 -1
- package/.docs/docs/workspace/filesystem.md +2 -2
- package/.docs/docs/workspace/overview.md +1 -1
- package/.docs/docs/workspace/sandbox.md +1 -1
- package/.docs/guides/build-your-ui/ai-sdk-ui.md +1 -1
- package/.docs/guides/guide/ai-recruiter.md +1 -1
- package/.docs/guides/guide/chef-michel.md +1 -1
- package/.docs/guides/guide/code-review-bot.md +1 -1
- package/.docs/guides/guide/dev-assistant.md +1 -1
- package/.docs/guides/guide/docs-manager.md +1 -1
- package/.docs/guides/guide/firecrawl.md +1 -1
- package/.docs/guides/guide/github-actions-pr-description.md +1 -1
- package/.docs/guides/guide/research-assistant.md +1 -1
- package/.docs/guides/guide/research-coordinator.md +2 -2
- package/.docs/guides/guide/slack-assistant.md +1 -1
- package/.docs/guides/guide/stock-agent.md +2 -2
- package/.docs/guides/guide/whatsapp-chat-bot.md +2 -2
- package/.docs/guides/migrations/agentnetwork.md +4 -4
- package/.docs/guides/migrations/upgrade-to-v1/agent.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +2 -2
- package/.docs/reference/agents/agent.md +4 -4
- package/.docs/reference/agents/channels.md +47 -5
- package/.docs/reference/agents/generateLegacy.md +1 -1
- package/.docs/reference/agents/getLLM.md +2 -2
- package/.docs/reference/agents/getMetadata.md +2 -2
- package/.docs/reference/agents/network.md +1 -1
- package/.docs/reference/browser/agent-browser.md +1 -1
- package/.docs/reference/browser/browser-viewer.md +1 -1
- package/.docs/reference/browser/mastra-browser.md +1 -1
- package/.docs/reference/browser/stagehand-browser.md +5 -5
- package/.docs/reference/configuration.md +1 -1
- package/.docs/reference/evals/answer-relevancy.md +1 -1
- package/.docs/reference/evals/answer-similarity.md +1 -1
- package/.docs/reference/evals/bias.md +1 -1
- package/.docs/reference/evals/context-precision.md +3 -3
- package/.docs/reference/evals/context-relevance.md +11 -11
- package/.docs/reference/evals/faithfulness.md +1 -1
- package/.docs/reference/evals/hallucination.md +5 -5
- package/.docs/reference/evals/noise-sensitivity.md +11 -11
- package/.docs/reference/evals/prompt-alignment.md +15 -15
- package/.docs/reference/evals/tool-call-accuracy.md +3 -3
- package/.docs/reference/evals/toxicity.md +1 -1
- package/.docs/reference/memory/memory-class.md +3 -3
- package/.docs/reference/memory/observational-memory.md +4 -4
- package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
- package/.docs/reference/processors/batch-parts-processor.md +1 -1
- package/.docs/reference/processors/cost-guard-processor.md +1 -1
- package/.docs/reference/processors/language-detector.md +1 -1
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +2 -2
- package/.docs/reference/processors/pii-detector.md +2 -2
- package/.docs/reference/processors/prefill-error-handler.md +2 -2
- package/.docs/reference/processors/processor-interface.md +2 -2
- package/.docs/reference/processors/prompt-injection-detector.md +1 -1
- package/.docs/reference/processors/regex-filter-processor.md +1 -1
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/skill-search-processor.md +1 -1
- package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +3 -3
- package/.docs/reference/processors/tool-call-filter.md +2 -2
- package/.docs/reference/processors/tool-search-processor.md +2 -2
- package/.docs/reference/processors/unicode-normalizer.md +1 -1
- package/.docs/reference/processors/working-memory-processor.md +1 -1
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/storage/dsql.md +1 -1
- package/.docs/reference/storage/mongodb.md +1 -1
- package/.docs/reference/storage/postgresql.md +1 -1
- package/.docs/reference/storage/redis.md +1 -1
- package/.docs/reference/storage/spanner.md +5 -0
- package/.docs/reference/storage/upstash.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/templates/overview.md +1 -1
- package/.docs/reference/tools/mcp-client.md +2 -2
- package/.docs/reference/tools/mcp-server.md +33 -1
- package/.docs/reference/tools/vector-query-tool.md +1 -1
- package/.docs/reference/vectors/libsql.md +1 -1
- package/.docs/reference/vectors/mongodb.md +1 -1
- package/.docs/reference/vectors/pg.md +1 -1
- package/.docs/reference/vectors/upstash.md +1 -1
- package/.docs/reference/voice/voice.addInstructions.md +1 -1
- package/.docs/reference/workspace/agentfs-filesystem.md +1 -1
- package/.docs/reference/workspace/azure-blob-filesystem.md +1 -1
- package/.docs/reference/workspace/docker-sandbox.md +1 -1
- package/.docs/reference/workspace/e2b-sandbox.md +9 -5
- package/.docs/reference/workspace/files-sdk-filesystem.md +1 -1
- package/.docs/reference/workspace/gcs-filesystem.md +1 -1
- package/.docs/reference/workspace/google-drive-filesystem.md +1 -1
- package/.docs/reference/workspace/local-filesystem.md +1 -1
- package/.docs/reference/workspace/local-sandbox.md +1 -1
- package/.docs/reference/workspace/modal-sandbox.md +1 -1
- package/.docs/reference/workspace/s3-filesystem.md +1 -1
- package/CHANGELOG.md +30 -0
- package/package.json +6 -6
package/.docs/docs/agents/a2a.md
CHANGED
|
@@ -81,7 +81,7 @@ export const supportAgent = new Agent({
|
|
|
81
81
|
id: 'support-agent',
|
|
82
82
|
name: 'Support Agent',
|
|
83
83
|
instructions: 'Answer user questions and delegate weather questions when needed.',
|
|
84
|
-
model: 'openai/gpt-5.
|
|
84
|
+
model: 'openai/gpt-5.5',
|
|
85
85
|
agents: {
|
|
86
86
|
remoteWeatherAgent,
|
|
87
87
|
},
|
package/.docs/docs/agents/acp.md
CHANGED
|
@@ -84,7 +84,7 @@ export const codeSupervisor = new Agent({
|
|
|
84
84
|
id: 'code-supervisor',
|
|
85
85
|
name: 'Code Supervisor',
|
|
86
86
|
instructions: 'Delegate code editing tasks to the code-agent subagent.',
|
|
87
|
-
model: 'openai/gpt-5.
|
|
87
|
+
model: 'openai/gpt-5.5',
|
|
88
88
|
agents: {
|
|
89
89
|
codeAgent,
|
|
90
90
|
},
|
|
@@ -113,7 +113,7 @@ export const codeSupervisor = new Agent({
|
|
|
113
113
|
id: 'code-supervisor',
|
|
114
114
|
name: 'Code Supervisor',
|
|
115
115
|
instructions: 'Use the code-agent tool when a task requires repository inspection or code edits.',
|
|
116
|
-
model: 'openai/gpt-5.
|
|
116
|
+
model: 'openai/gpt-5.5',
|
|
117
117
|
tools: {
|
|
118
118
|
codeAgentTool,
|
|
119
119
|
},
|
|
@@ -178,14 +178,14 @@ export const codeAgent = new AcpAgent({
|
|
|
178
178
|
description: 'An ACP-compatible coding agent',
|
|
179
179
|
command: 'claude',
|
|
180
180
|
args: ['--acp'],
|
|
181
|
-
model: '
|
|
181
|
+
model: 'claude-sonnet-4-6',
|
|
182
182
|
})
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
You can also change the model at runtime with `setModel()`:
|
|
186
186
|
|
|
187
187
|
```typescript
|
|
188
|
-
await codeAgent.setModel('
|
|
188
|
+
await codeAgent.setModel('claude-sonnet-4-6')
|
|
189
189
|
```
|
|
190
190
|
|
|
191
191
|
If the ACP agent advertises available models and your model ID doesn't match any of them, Mastra throws an error listing the valid options:
|
|
@@ -20,7 +20,7 @@ export const agent = new Agent({
|
|
|
20
20
|
id: 'voice-agent',
|
|
21
21
|
name: 'Voice Agent',
|
|
22
22
|
instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
|
|
23
|
-
model: 'openai/gpt-5.
|
|
23
|
+
model: 'openai/gpt-5.5',
|
|
24
24
|
voice,
|
|
25
25
|
})
|
|
26
26
|
|
|
@@ -109,7 +109,7 @@ export const agent = new Agent({
|
|
|
109
109
|
id: 'speech-to-speech-agent',
|
|
110
110
|
name: 'Speech-to-Speech Agent',
|
|
111
111
|
instructions: `You are a helpful assistant with speech-to-speech capabilities.`,
|
|
112
|
-
model: 'openai/gpt-5.
|
|
112
|
+
model: 'openai/gpt-5.5',
|
|
113
113
|
tools: {
|
|
114
114
|
// Tools configured on Agent are passed to voice provider
|
|
115
115
|
search,
|
|
@@ -146,7 +146,7 @@ export const agent = new Agent({
|
|
|
146
146
|
id: 'support-line',
|
|
147
147
|
name: 'Support Line',
|
|
148
148
|
instructions: ({ requestContext }) => `Help user ${requestContext.get('user')}.`,
|
|
149
|
-
model: 'openai/gpt-5.
|
|
149
|
+
model: 'openai/gpt-5.5',
|
|
150
150
|
voice: ({ requestContext }) => new OpenAIRealtimeVoice({ apiKey: requestContext.get('apiKey') }),
|
|
151
151
|
})
|
|
152
152
|
|
|
@@ -240,7 +240,7 @@ export const convertToText = async (input: string | NodeJS.ReadableStream): Prom
|
|
|
240
240
|
export const hybridVoiceAgent = new Agent({
|
|
241
241
|
id: 'hybrid-voice-agent',
|
|
242
242
|
name: 'Hybrid Voice Agent',
|
|
243
|
-
model: 'openai/gpt-5.
|
|
243
|
+
model: 'openai/gpt-5.5',
|
|
244
244
|
instructions: 'You can speak and listen using different providers.',
|
|
245
245
|
voice: new CompositeVoice({
|
|
246
246
|
input: new OpenAIVoice(),
|
|
@@ -252,7 +252,7 @@ export const unifiedVoiceAgent = new Agent({
|
|
|
252
252
|
id: 'unified-voice-agent',
|
|
253
253
|
name: 'Unified Voice Agent',
|
|
254
254
|
instructions: 'You are an agent with both STT and TTS capabilities.',
|
|
255
|
-
model: 'openai/gpt-5.
|
|
255
|
+
model: 'openai/gpt-5.5',
|
|
256
256
|
voice: new OpenAIVoice(),
|
|
257
257
|
})
|
|
258
258
|
|
|
@@ -294,7 +294,7 @@ export const agent = new Agent({
|
|
|
294
294
|
id: 'voice-agent',
|
|
295
295
|
name: 'Voice Agent',
|
|
296
296
|
instructions: `You are a helpful assistant with both STT and TTS capabilities.`,
|
|
297
|
-
model: 'openai/gpt-5.
|
|
297
|
+
model: 'openai/gpt-5.5',
|
|
298
298
|
|
|
299
299
|
// Create a composite voice using OpenAI for listening and PlayAI for speaking
|
|
300
300
|
voice: new CompositeVoice({
|
|
@@ -319,7 +319,7 @@ export const agent = new Agent({
|
|
|
319
319
|
id: 'aisdk-voice-agent',
|
|
320
320
|
name: 'AI SDK Voice Agent',
|
|
321
321
|
instructions: `You are a helpful assistant with voice capabilities.`,
|
|
322
|
-
model: 'openai/gpt-5.
|
|
322
|
+
model: 'openai/gpt-5.5',
|
|
323
323
|
|
|
324
324
|
// Pass AI SDK models directly to CompositeVoice
|
|
325
325
|
voice: new CompositeVoice({
|
|
@@ -412,7 +412,7 @@ const supervisorAgent = new Agent({
|
|
|
412
412
|
name: 'Supervisor Agent',
|
|
413
413
|
instructions: `You coordinate data retrieval tasks.
|
|
414
414
|
Delegate to data-agent for user lookups.`,
|
|
415
|
-
model: 'openai/gpt-5.
|
|
415
|
+
model: 'openai/gpt-5.5',
|
|
416
416
|
agents: { dataAgent },
|
|
417
417
|
memory: new Memory(),
|
|
418
418
|
})
|
|
@@ -80,7 +80,7 @@ import { Agent } from '@mastra/core/agent'
|
|
|
80
80
|
export const researcher = new Agent({
|
|
81
81
|
id: 'researcher',
|
|
82
82
|
instructions: 'You research topics and answer questions.',
|
|
83
|
-
model: 'openai/gpt-5.
|
|
83
|
+
model: 'openai/gpt-5.5',
|
|
84
84
|
tools: { researchTool, summarizeTool },
|
|
85
85
|
backgroundTasks: {
|
|
86
86
|
tools: {
|
|
@@ -175,7 +175,7 @@ import { Agent } from '@mastra/core/agent'
|
|
|
175
175
|
const supervisor = new Agent({
|
|
176
176
|
id: 'supervisor',
|
|
177
177
|
instructions: 'Coordinate research and writing using the available agents.',
|
|
178
|
-
model: 'openai/gpt-5.
|
|
178
|
+
model: 'openai/gpt-5.5',
|
|
179
179
|
agents: { researchAgent, writingAgent },
|
|
180
180
|
backgroundTasks: {
|
|
181
181
|
tools: {
|
|
@@ -23,7 +23,7 @@ export const supportAgent = new Agent({
|
|
|
23
23
|
id: 'support-agent',
|
|
24
24
|
name: 'Support Agent',
|
|
25
25
|
instructions: 'You are a helpful support assistant.',
|
|
26
|
-
model: 'openai/gpt-5.
|
|
26
|
+
model: 'openai/gpt-5.5',
|
|
27
27
|
channels: {
|
|
28
28
|
adapters: {
|
|
29
29
|
slack: createSlackAdapter(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Code mode
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Alpha:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
|
|
4
4
|
|
|
5
5
|
Code mode gives an agent a single tool that runs a short TypeScript program in a sandbox. Instead of calling tools one at a time, the model writes a program that orchestrates your existing tools as `external_*` functions, batching calls with `Promise.all`, aggregating with `reduce`, branching, and doing math in a real runtime, then returns a single result.
|
|
6
6
|
|
|
@@ -56,7 +56,7 @@ const { tool, instructions } = createCodeMode({
|
|
|
56
56
|
const agent = new Agent({
|
|
57
57
|
name: 'shop-assistant',
|
|
58
58
|
instructions: ['You are a helpful shopping assistant.', instructions],
|
|
59
|
-
model: 'openai/gpt-5.
|
|
59
|
+
model: 'openai/gpt-5.5',
|
|
60
60
|
tools: { execute_typescript: tool },
|
|
61
61
|
})
|
|
62
62
|
```
|
|
@@ -144,7 +144,7 @@ const inventory = createCodeMode({
|
|
|
144
144
|
const agent = new Agent({
|
|
145
145
|
name: 'ops-assistant',
|
|
146
146
|
instructions: ['You are an ops assistant.', sales.instructions, inventory.instructions],
|
|
147
|
-
model: 'openai/gpt-5.
|
|
147
|
+
model: 'openai/gpt-5.5',
|
|
148
148
|
tools: { sales_code: sales.tool, inventory_code: inventory.tool },
|
|
149
149
|
})
|
|
150
150
|
```
|
|
@@ -246,7 +246,7 @@ costGuard.onViolation = ({ processorId, message, detail }) => {
|
|
|
246
246
|
|
|
247
247
|
// Log moderation violations
|
|
248
248
|
const moderation = new ModerationProcessor({
|
|
249
|
-
model: '
|
|
249
|
+
model: 'openai/gpt-5-nano',
|
|
250
250
|
strategy: 'block',
|
|
251
251
|
})
|
|
252
252
|
|
|
@@ -360,7 +360,7 @@ See [workflows as processors](https://mastra.ai/docs/agents/processors) for more
|
|
|
360
360
|
Guardrail processors don't need your primary model. Use a small, fast model for classification tasks:
|
|
361
361
|
|
|
362
362
|
```typescript
|
|
363
|
-
const GUARDRAIL_MODEL = '
|
|
363
|
+
const GUARDRAIL_MODEL = 'openai/gpt-5-nano'
|
|
364
364
|
|
|
365
365
|
new ModerationProcessor({ model: GUARDRAIL_MODEL })
|
|
366
366
|
new PIIDetector({ model: GUARDRAIL_MODEL })
|
|
@@ -27,7 +27,7 @@ export const routingAgent = new Agent({
|
|
|
27
27
|
name: 'Routing Agent',
|
|
28
28
|
instructions: `
|
|
29
29
|
You are a network of writers and researchers. The user will ask you to research a topic. Always respond with a complete report—no bullet points. Write in full paragraphs, like a blog post. Do not answer with incomplete or uncertain information.`,
|
|
30
|
-
model: 'openai/gpt-5.
|
|
30
|
+
model: 'openai/gpt-5.5',
|
|
31
31
|
agents: {
|
|
32
32
|
researchAgent,
|
|
33
33
|
writingAgent,
|
|
@@ -382,7 +382,7 @@ import { TokenLimiter } from '@mastra/core/processors'
|
|
|
382
382
|
|
|
383
383
|
const agent = new Agent({
|
|
384
384
|
name: 'my-agent',
|
|
385
|
-
model: 'openai/gpt-5.
|
|
385
|
+
model: 'openai/gpt-5.5',
|
|
386
386
|
inputProcessors: [new TokenLimiter(127000)],
|
|
387
387
|
})
|
|
388
388
|
```
|
|
@@ -647,7 +647,7 @@ const moderationWorkflow = createWorkflow({
|
|
|
647
647
|
const agent = new Agent({
|
|
648
648
|
id: 'moderated-agent',
|
|
649
649
|
name: 'Moderated Agent',
|
|
650
|
-
model: 'openai/gpt-5.
|
|
650
|
+
model: 'openai/gpt-5.5',
|
|
651
651
|
inputProcessors: [moderationWorkflow],
|
|
652
652
|
})
|
|
653
653
|
```
|
|
@@ -686,7 +686,7 @@ export class QualityChecker implements Processor {
|
|
|
686
686
|
const agent = new Agent({
|
|
687
687
|
id: 'quality-agent',
|
|
688
688
|
name: 'Quality Agent',
|
|
689
|
-
model: 'openai/gpt-5.
|
|
689
|
+
model: 'openai/gpt-5.5',
|
|
690
690
|
outputProcessors: [new QualityChecker()],
|
|
691
691
|
maxProcessorRetries: 3, // Maximum retry attempts. If unset, retries are disabled (unless errorProcessors are configured, in which case it defaults to 10).
|
|
692
692
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Response Caching
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Alpha:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
|
|
4
4
|
|
|
5
5
|
Response caching skips the LLM call and replays a previously cached response when an agent receives an identical request. Use it to reduce latency and avoid paying for repeated calls.
|
|
6
6
|
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# SDK agents
|
|
2
|
+
|
|
3
|
+
SDK agents let you use other agent SDK frameworks inside Mastra. Use them to register SDK-backed agents in a Mastra project while the provider SDK keeps its own runtime, tools, permissions, and agent loop.
|
|
4
|
+
|
|
5
|
+
## When to use SDK agents
|
|
6
|
+
|
|
7
|
+
- A vendor SDK already owns the agent loop, tools, permissions, or local runtime.
|
|
8
|
+
- You want to register that SDK-backed agent in a Mastra project.
|
|
9
|
+
- You need Mastra-compatible `generate()` and `stream()` outputs.
|
|
10
|
+
- You want usage, cost, and tool activity from the SDK run to appear in Mastra observability.
|
|
11
|
+
|
|
12
|
+
## Supported SDK agents
|
|
13
|
+
|
|
14
|
+
- [Claude Agent SDK](#claude-agent-sdk): Use `@mastra/claude` to register a Claude SDK agent and call it with Mastra `generate()` and `stream()`.
|
|
15
|
+
- [Cursor Agent SDK](#cursor-agent-sdk): Use `@mastra/cursor` to register a Cursor SDK agent and call it with Mastra `generate()` and `stream()`.
|
|
16
|
+
|
|
17
|
+
## Claude Agent SDK
|
|
18
|
+
|
|
19
|
+
Use `@mastra/claude` for Claude Code runtime configuration, permissions, tools, and agent-loop behavior.
|
|
20
|
+
|
|
21
|
+
### Install Claude packages
|
|
22
|
+
|
|
23
|
+
Install the Mastra package and the Claude Agent SDK peer dependency:
|
|
24
|
+
|
|
25
|
+
**npm**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**pnpm**:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Yarn**:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
yarn add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Bun**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
bun add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Set the Claude SDK credential:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
export ANTHROPIC_API_KEY="..."
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Create a Claude SDK agent
|
|
56
|
+
|
|
57
|
+
Configure Claude Agent SDK through `sdkOptions`.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { ClaudeSDKAgent } from '@mastra/claude'
|
|
61
|
+
|
|
62
|
+
export const claudeSDKAgent = new ClaudeSDKAgent({
|
|
63
|
+
id: 'claude-sdk-agent',
|
|
64
|
+
name: 'Claude SDK Agent',
|
|
65
|
+
description: 'Use Claude Agent SDK through Mastra.',
|
|
66
|
+
sdkOptions: {
|
|
67
|
+
model: 'claude-sonnet-4-6',
|
|
68
|
+
cwd: process.cwd(),
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Add Claude SDK tools
|
|
74
|
+
|
|
75
|
+
Claude Agent SDK tools are provided through Claude SDK Model Context Protocol (MCP) servers. Create the server with the Claude SDK, then pass it through `sdkOptions.mcpServers`.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk'
|
|
79
|
+
import { ClaudeSDKAgent } from '@mastra/claude'
|
|
80
|
+
import { getTemperature } from '../tools/get-temperature'
|
|
81
|
+
|
|
82
|
+
const weatherServer = createSdkMcpServer({
|
|
83
|
+
name: 'weather',
|
|
84
|
+
version: '1.0.0',
|
|
85
|
+
tools: [getTemperature],
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export const claudeSDKAgent = new ClaudeSDKAgent({
|
|
89
|
+
id: 'claude-sdk-agent',
|
|
90
|
+
name: 'Claude SDK Agent',
|
|
91
|
+
description: 'Use Claude Agent SDK through Mastra.',
|
|
92
|
+
sdkOptions: {
|
|
93
|
+
model: 'claude-sonnet-4-6',
|
|
94
|
+
cwd: process.cwd(),
|
|
95
|
+
mcpServers: {
|
|
96
|
+
weather: weatherServer,
|
|
97
|
+
},
|
|
98
|
+
allowedTools: ['mcp__weather__get_temperature'],
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The `allowedTools` value uses Claude Agent SDK MCP tool naming: `mcp__<server name>__<tool name>`.
|
|
104
|
+
|
|
105
|
+
## Cursor Agent SDK
|
|
106
|
+
|
|
107
|
+
Use `@mastra/cursor` to register a Cursor SDK agent in Mastra while keeping Cursor-specific setup in Cursor SDK options.
|
|
108
|
+
|
|
109
|
+
### Install Cursor packages
|
|
110
|
+
|
|
111
|
+
Install the Mastra package and the Cursor SDK peer dependency:
|
|
112
|
+
|
|
113
|
+
**npm**:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install @mastra/cursor @cursor/sdk
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**pnpm**:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm add @mastra/cursor @cursor/sdk
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Yarn**:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
yarn add @mastra/cursor @cursor/sdk
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Bun**:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bun add @mastra/cursor @cursor/sdk
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Set the Cursor SDK credential:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
export CURSOR_API_KEY="..."
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Create a Cursor SDK agent
|
|
144
|
+
|
|
145
|
+
Configure Cursor Agent SDK through `sdkOptions`.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
149
|
+
|
|
150
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
151
|
+
id: 'cursor-sdk-agent',
|
|
152
|
+
name: 'Cursor SDK Agent',
|
|
153
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
154
|
+
sdkOptions: {
|
|
155
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
156
|
+
model: {
|
|
157
|
+
id: 'gpt-5.5',
|
|
158
|
+
},
|
|
159
|
+
local: {
|
|
160
|
+
cwd: process.cwd(),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Cursor local agents require an explicit model. Set it in `sdkOptions.model`.
|
|
167
|
+
|
|
168
|
+
### Use an existing Cursor SDK agent
|
|
169
|
+
|
|
170
|
+
If your app already creates a Cursor SDK agent, pass that agent to `CursorSDKAgent` instead:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { Agent as CursorAgent } from '@cursor/sdk'
|
|
174
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
175
|
+
|
|
176
|
+
const cursorAgent = CursorAgent.create({
|
|
177
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
178
|
+
model: {
|
|
179
|
+
id: 'gpt-5.5',
|
|
180
|
+
},
|
|
181
|
+
local: {
|
|
182
|
+
cwd: process.cwd(),
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
187
|
+
id: 'cursor-sdk-agent',
|
|
188
|
+
name: 'Cursor SDK Agent',
|
|
189
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
190
|
+
agent: cursorAgent,
|
|
191
|
+
})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Add Cursor SDK tools
|
|
195
|
+
|
|
196
|
+
Cursor Agent SDK tools are configured with Cursor SDK options. Pass Model Context Protocol (MCP) servers through `sdkOptions.mcpServers`:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
200
|
+
import { mcpServers } from '../mcp/cursor'
|
|
201
|
+
|
|
202
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
203
|
+
id: 'cursor-sdk-agent',
|
|
204
|
+
name: 'Cursor SDK Agent',
|
|
205
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
206
|
+
sdkOptions: {
|
|
207
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
208
|
+
model: {
|
|
209
|
+
id: 'gpt-5.5',
|
|
210
|
+
},
|
|
211
|
+
local: {
|
|
212
|
+
cwd: process.cwd(),
|
|
213
|
+
},
|
|
214
|
+
mcpServers,
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Register SDK agents
|
|
220
|
+
|
|
221
|
+
Register SDK agents in the Mastra instance like other agents:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { Mastra } from '@mastra/core'
|
|
225
|
+
import { claudeSDKAgent } from './agents/claude-sdk-agent'
|
|
226
|
+
import { cursorSDKAgent } from './agents/cursor-sdk-agent'
|
|
227
|
+
|
|
228
|
+
export const mastra = new Mastra({
|
|
229
|
+
agents: {
|
|
230
|
+
claudeSDKAgent,
|
|
231
|
+
cursorSDKAgent,
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
After registration, call them with `mastra.getAgentById()`:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import { mastra } from './index'
|
|
240
|
+
|
|
241
|
+
const agent = mastra.getAgentById('cursor-sdk-agent')
|
|
242
|
+
const stream = await agent.stream('Inspect this project and describe the test setup.')
|
|
243
|
+
|
|
244
|
+
for await (const chunk of stream.textStream) {
|
|
245
|
+
process.stdout.write(chunk)
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Observability
|
|
250
|
+
|
|
251
|
+
SDK agents create Mastra agent and model spans for `generate()` and `stream()` calls. Mastra records SDK-provided usage, tool activity, and provider metadata when the vendor SDK exposes those events.
|
|
252
|
+
|
|
253
|
+
Claude SDK runs can include SDK-estimated cost from the Claude result message. Cursor SDK runs include token usage from Cursor interaction updates.
|
|
254
|
+
|
|
255
|
+
For storage and dashboard setup, see [Observability](https://mastra.ai/docs/observability/overview).
|
|
256
|
+
|
|
257
|
+
## Related
|
|
258
|
+
|
|
259
|
+
- [Agents overview](https://mastra.ai/docs/agents/overview)
|
|
260
|
+
- [Tools](https://mastra.ai/docs/agents/using-tools)
|
|
261
|
+
- [Observability](https://mastra.ai/docs/observability/overview)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Signals
|
|
2
2
|
|
|
3
|
-
> **
|
|
3
|
+
> **Alpha:** This feature is in alpha. Breaking changes may occur without a major version bump until the API is stable.
|
|
4
4
|
|
|
5
5
|
Signals are a way to interact with an agent through a thread. Instead of starting every interaction with `agent.stream()`, subscribe to a thread and send messages or signals. Mastra either wakes the agent when the thread is idle, drops input into the running agent loop, or queues input for the next turn.
|
|
6
6
|
|
|
@@ -178,7 +178,7 @@ const response = await testAgent.generate('Analyze the TypeScript programming la
|
|
|
178
178
|
differentiators: z.array(z.string()),
|
|
179
179
|
}),
|
|
180
180
|
}),
|
|
181
|
-
model: 'openai/gpt-5.
|
|
181
|
+
model: 'openai/gpt-5.5',
|
|
182
182
|
},
|
|
183
183
|
})
|
|
184
184
|
|
|
@@ -248,7 +248,7 @@ When `model` is provided to the `structuredOutput` property, Mastra uses a separ
|
|
|
248
248
|
const response = await testAgent.generate('Tell me about TypeScript.', {
|
|
249
249
|
structuredOutput: {
|
|
250
250
|
schema: yourSchema,
|
|
251
|
-
model: 'openai/gpt-5.
|
|
251
|
+
model: 'openai/gpt-5.5',
|
|
252
252
|
},
|
|
253
253
|
})
|
|
254
254
|
```
|
|
@@ -267,7 +267,7 @@ const response = await testAgent.generate('Return my profile as structured data.
|
|
|
267
267
|
hometown: z.string(),
|
|
268
268
|
petName: z.string(),
|
|
269
269
|
}),
|
|
270
|
-
model: 'openai/gpt-5.
|
|
270
|
+
model: 'openai/gpt-5.5',
|
|
271
271
|
useAgent: true,
|
|
272
272
|
},
|
|
273
273
|
})
|
|
@@ -284,7 +284,7 @@ const result = await agent.stream('weather in vancouver?', {
|
|
|
284
284
|
prepareStep: async ({ stepNumber }) => {
|
|
285
285
|
if (stepNumber === 0) {
|
|
286
286
|
return {
|
|
287
|
-
model: 'openai/gpt-5.
|
|
287
|
+
model: 'openai/gpt-5.5',
|
|
288
288
|
tools: {
|
|
289
289
|
weatherTool,
|
|
290
290
|
},
|
|
@@ -292,7 +292,7 @@ const result = await agent.stream('weather in vancouver?', {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
return {
|
|
295
|
-
model: 'openai/gpt-5.
|
|
295
|
+
model: 'openai/gpt-5.5',
|
|
296
296
|
tools: undefined,
|
|
297
297
|
structuredOutput: {
|
|
298
298
|
schema: z.object({
|
|
@@ -41,7 +41,7 @@ const supervisor = new Agent({
|
|
|
41
41
|
id: 'supervisor',
|
|
42
42
|
instructions: `You coordinate research and writing using specialized agents.
|
|
43
43
|
Delegate to research-agent for facts, then writing-agent for content.`,
|
|
44
|
-
model: 'openai/gpt-5.
|
|
44
|
+
model: 'openai/gpt-5.5',
|
|
45
45
|
agents: { researchAgent, writingAgent },
|
|
46
46
|
memory: new Memory({
|
|
47
47
|
storage: new LibSQLStore({ id: 'storage', url: 'file:mastra.db' }),
|
|
@@ -326,7 +326,7 @@ Enable the [backgroundTasks manager](https://mastra.ai/reference/configuration)
|
|
|
326
326
|
const supervisor = new Agent({
|
|
327
327
|
id: 'supervisor',
|
|
328
328
|
instructions: 'Coordinate research and writing using the available agents.',
|
|
329
|
-
model: 'openai/gpt-5.
|
|
329
|
+
model: 'openai/gpt-5.5',
|
|
330
330
|
agents: { researchAgent, writingAgent },
|
|
331
331
|
backgroundTasks: {
|
|
332
332
|
tools: {
|
|
@@ -52,7 +52,7 @@ export const weatherAgent = new Agent({
|
|
|
52
52
|
instructions: `
|
|
53
53
|
You are a helpful weather assistant.
|
|
54
54
|
Use the weatherTool to fetch current weather data.`,
|
|
55
|
-
model: 'openai/gpt-5.
|
|
55
|
+
model: 'openai/gpt-5.5',
|
|
56
56
|
tools: { weatherTool },
|
|
57
57
|
})
|
|
58
58
|
```
|
|
@@ -145,7 +145,7 @@ export const weatherAgent = new Agent({
|
|
|
145
145
|
You are a helpful weather assistant.
|
|
146
146
|
Use the weatherTool to fetch current weather data.
|
|
147
147
|
Use the hazardsTool to provide information about potential weather hazards.`,
|
|
148
|
-
model: 'openai/gpt-5.
|
|
148
|
+
model: 'openai/gpt-5.5',
|
|
149
149
|
tools: { weatherTool, hazardsTool },
|
|
150
150
|
})
|
|
151
151
|
```
|
|
@@ -162,14 +162,14 @@ const writer = new Agent({
|
|
|
162
162
|
name: 'Writer',
|
|
163
163
|
description: 'Drafts and edits written content',
|
|
164
164
|
instructions: 'You are a skilled writer.',
|
|
165
|
-
model: 'openai/gpt-5.
|
|
165
|
+
model: 'openai/gpt-5.5',
|
|
166
166
|
})
|
|
167
167
|
|
|
168
168
|
export const supervisor = new Agent({
|
|
169
169
|
id: 'supervisor',
|
|
170
170
|
name: 'Supervisor',
|
|
171
171
|
instructions: 'Coordinate the writer to produce content.',
|
|
172
|
-
model: 'openai/gpt-5.
|
|
172
|
+
model: 'openai/gpt-5.5',
|
|
173
173
|
agents: { writer },
|
|
174
174
|
})
|
|
175
175
|
```
|
|
@@ -186,7 +186,7 @@ export const researchAgent = new Agent({
|
|
|
186
186
|
id: 'research-agent',
|
|
187
187
|
name: 'Research Agent',
|
|
188
188
|
instructions: 'You are a research assistant.',
|
|
189
|
-
model: 'openai/gpt-5.
|
|
189
|
+
model: 'openai/gpt-5.5',
|
|
190
190
|
workflows: { researchWorkflow },
|
|
191
191
|
})
|
|
192
192
|
```
|
|
@@ -73,7 +73,7 @@ const workspace = new Workspace({
|
|
|
73
73
|
|
|
74
74
|
const browserAgent = new Agent({
|
|
75
75
|
id: 'browser-agent',
|
|
76
|
-
model: 'openai/gpt-5.
|
|
76
|
+
model: 'openai/gpt-5.5',
|
|
77
77
|
workspace,
|
|
78
78
|
instructions: `You are a web automation assistant.
|
|
79
79
|
Use browser-use commands to navigate and interact with websites.`,
|
|
@@ -72,7 +72,7 @@ export const webAgent = new Agent({
|
|
|
72
72
|
id: 'web-agent',
|
|
73
73
|
name: 'Web Agent',
|
|
74
74
|
description: 'A web automation assistant that can navigate websites and complete tasks.',
|
|
75
|
-
model: 'openai/gpt-5.
|
|
75
|
+
model: 'openai/gpt-5.5',
|
|
76
76
|
browser,
|
|
77
77
|
instructions:
|
|
78
78
|
'You are a web automation assistant. Use browser tools to navigate websites and complete tasks.',
|