@mastra/mcp-docs-server 1.0.0-beta.4 → 1.0.0-beta.6
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/organized/changelogs/%40internal%2Fstorage-test-utils.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fconvex.md +29 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +411 -211
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fduckdb.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +52 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flance.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Frag.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Freact.md +89 -1
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +42 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +92 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +67 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +201 -1
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +201 -1
- package/.docs/organized/changelogs/create-mastra.md +201 -1
- package/.docs/organized/changelogs/mastra.md +201 -1
- package/.docs/organized/code-examples/agui.md +1 -0
- package/.docs/organized/code-examples/ai-sdk-v5.md +1 -0
- package/.docs/organized/code-examples/mcp-server-adapters.md +721 -0
- package/.docs/organized/code-examples/memory-with-processors.md +1 -1
- package/.docs/organized/code-examples/quick-start.md +1 -1
- package/.docs/organized/code-examples/server-app-access.md +342 -0
- package/.docs/raw/agents/adding-voice.mdx +7 -10
- package/.docs/raw/agents/agent-approval.mdx +189 -0
- package/.docs/raw/agents/guardrails.mdx +26 -23
- package/.docs/raw/agents/networks.mdx +2 -2
- package/.docs/raw/agents/overview.mdx +27 -62
- package/.docs/raw/agents/processors.mdx +279 -0
- package/.docs/raw/agents/using-tools.mdx +4 -5
- package/.docs/raw/course/01-first-agent/05-running-playground.md +5 -5
- package/.docs/raw/course/01-first-agent/09-testing-your-agent.md +3 -3
- package/.docs/raw/course/01-first-agent/13-testing-your-tool.md +3 -3
- package/.docs/raw/course/01-first-agent/17-testing-memory.md +2 -2
- package/.docs/raw/course/04-workflows/07-using-playground.md +1 -1
- package/.docs/raw/deployment/building-mastra.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/amazon-ec2.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/aws-lambda.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/cloud-providers/index.mdx +20 -27
- package/.docs/raw/deployment/cloud-providers/netlify-deployer.mdx +44 -13
- package/.docs/raw/deployment/mastra-cloud/observability.mdx +19 -17
- package/.docs/raw/deployment/mastra-cloud/setting-up.mdx +1 -1
- package/.docs/raw/deployment/overview.mdx +2 -2
- package/.docs/raw/deployment/web-framework.mdx +5 -5
- package/.docs/raw/evals/custom-scorers.mdx +3 -5
- package/.docs/raw/evals/overview.mdx +2 -3
- package/.docs/raw/evals/running-in-ci.mdx +0 -2
- package/.docs/raw/{guides/guide → getting-started}/manual-install.mdx +2 -2
- package/.docs/raw/getting-started/project-structure.mdx +1 -1
- package/.docs/raw/getting-started/start.mdx +72 -0
- package/.docs/raw/getting-started/studio.mdx +1 -1
- package/.docs/raw/{frameworks/agentic-uis/ai-sdk.mdx → guides/build-your-ui/ai-sdk-ui.mdx} +113 -11
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/astro.mdx +23 -25
- package/.docs/raw/{frameworks/servers → guides/getting-started}/express.mdx +3 -4
- package/.docs/raw/guides/{quickstarts/nextjs.mdx → getting-started/next-js.mdx} +11 -11
- package/.docs/raw/guides/{quickstarts/standalone-server.mdx → getting-started/quickstart.mdx} +7 -7
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/sveltekit.mdx +23 -25
- package/.docs/raw/{frameworks/web-frameworks → guides/getting-started}/vite-react.mdx +7 -7
- package/.docs/raw/guides/guide/ai-recruiter.mdx +2 -3
- package/.docs/raw/guides/guide/chef-michel.mdx +2 -3
- package/.docs/raw/guides/guide/notes-mcp-server.mdx +2 -2
- package/.docs/raw/guides/guide/research-assistant.mdx +7 -8
- package/.docs/raw/guides/guide/stock-agent.mdx +4 -6
- package/.docs/raw/guides/guide/web-search.mdx +12 -10
- package/.docs/raw/guides/guide/whatsapp-chat-bot.mdx +421 -0
- package/.docs/raw/guides/index.mdx +3 -35
- package/.docs/raw/guides/migrations/agentnetwork.mdx +4 -4
- package/.docs/raw/guides/migrations/ai-sdk-v4-to-v5.mdx +1 -1
- package/.docs/raw/guides/migrations/upgrade-to-v1/agent.mdx +40 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/tools.mdx +5 -0
- package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +51 -0
- package/.docs/raw/guides/migrations/vnext-to-standard-apis.mdx +2 -2
- package/.docs/raw/index.mdx +2 -2
- package/.docs/raw/mcp/overview.mdx +3 -5
- package/.docs/raw/memory/memory-processors.mdx +264 -79
- package/.docs/raw/memory/semantic-recall.mdx +7 -7
- package/.docs/raw/memory/storage/memory-with-libsql.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-mongodb.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-pg.mdx +2 -4
- package/.docs/raw/memory/storage/memory-with-upstash.mdx +2 -4
- package/.docs/raw/memory/threads-and-resources.mdx +3 -3
- package/.docs/raw/memory/working-memory.mdx +14 -7
- package/.docs/raw/{logging.mdx → observability/logging.mdx} +1 -1
- package/.docs/raw/observability/overview.mdx +2 -3
- package/.docs/raw/observability/tracing/bridges/otel.mdx +176 -0
- package/.docs/raw/observability/tracing/exporters/arize.mdx +17 -0
- package/.docs/raw/observability/tracing/exporters/braintrust.mdx +19 -0
- package/.docs/raw/observability/tracing/exporters/langfuse.mdx +20 -0
- package/.docs/raw/observability/tracing/exporters/langsmith.mdx +12 -0
- package/.docs/raw/observability/tracing/exporters/otel.mdx +25 -5
- package/.docs/raw/observability/tracing/exporters/posthog.mdx +107 -0
- package/.docs/raw/observability/tracing/overview.mdx +74 -8
- package/.docs/raw/observability/tracing/processors/sensitive-data-filter.mdx +0 -1
- package/.docs/raw/rag/chunking-and-embedding.mdx +16 -17
- package/.docs/raw/rag/overview.mdx +3 -2
- package/.docs/raw/rag/retrieval.mdx +43 -38
- package/.docs/raw/rag/vector-databases.mdx +93 -2
- package/.docs/raw/reference/agents/agent.mdx +7 -10
- package/.docs/raw/reference/agents/generate.mdx +55 -6
- package/.docs/raw/reference/agents/generateLegacy.mdx +2 -2
- package/.docs/raw/reference/agents/getLLM.mdx +1 -1
- package/.docs/raw/reference/agents/network.mdx +46 -3
- package/.docs/raw/reference/cli/mastra.mdx +2 -1
- package/.docs/raw/reference/client-js/agents.mdx +3 -3
- package/.docs/raw/reference/client-js/memory.mdx +43 -0
- package/.docs/raw/reference/client-js/workflows.mdx +92 -63
- package/.docs/raw/reference/core/getLogger.mdx +1 -1
- package/.docs/raw/reference/core/listLogs.mdx +1 -1
- package/.docs/raw/reference/core/listLogsByRunId.mdx +1 -1
- package/.docs/raw/reference/core/mastra-model-gateway.mdx +5 -19
- package/.docs/raw/reference/core/setLogger.mdx +1 -1
- package/.docs/raw/reference/core/setTelemetry.mdx +1 -1
- package/.docs/raw/reference/deployer/netlify.mdx +1 -2
- package/.docs/raw/reference/evals/answer-relevancy.mdx +28 -98
- package/.docs/raw/reference/evals/answer-similarity.mdx +12 -258
- package/.docs/raw/reference/evals/bias.mdx +29 -87
- package/.docs/raw/reference/evals/completeness.mdx +31 -90
- package/.docs/raw/reference/evals/content-similarity.mdx +28 -88
- package/.docs/raw/reference/evals/context-precision.mdx +28 -130
- package/.docs/raw/reference/evals/context-relevance.mdx +11 -11
- package/.docs/raw/reference/evals/faithfulness.mdx +28 -101
- package/.docs/raw/reference/evals/hallucination.mdx +28 -103
- package/.docs/raw/reference/evals/keyword-coverage.mdx +28 -107
- package/.docs/raw/reference/evals/noise-sensitivity.mdx +11 -11
- package/.docs/raw/reference/evals/prompt-alignment.mdx +15 -15
- package/.docs/raw/reference/evals/scorer-utils.mdx +362 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +27 -100
- package/.docs/raw/reference/evals/tone-consistency.mdx +25 -98
- package/.docs/raw/reference/evals/tool-call-accuracy.mdx +7 -7
- package/.docs/raw/reference/evals/toxicity.mdx +29 -92
- package/.docs/raw/reference/index.mdx +1 -0
- package/.docs/raw/reference/memory/memory-class.mdx +5 -7
- package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +150 -0
- package/.docs/raw/reference/observability/tracing/configuration.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +4 -0
- package/.docs/raw/reference/observability/tracing/exporters/langsmith.mdx +17 -1
- package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +6 -0
- package/.docs/raw/reference/observability/tracing/exporters/posthog.mdx +132 -0
- package/.docs/raw/reference/observability/tracing/instances.mdx +0 -4
- package/.docs/raw/reference/observability/tracing/interfaces.mdx +29 -4
- package/.docs/raw/reference/observability/tracing/spans.mdx +0 -4
- package/.docs/raw/reference/processors/batch-parts-processor.mdx +1 -1
- package/.docs/raw/reference/processors/language-detector.mdx +10 -3
- package/.docs/raw/reference/processors/message-history-processor.mdx +131 -0
- package/.docs/raw/reference/processors/moderation-processor.mdx +12 -5
- package/.docs/raw/reference/processors/pii-detector.mdx +12 -5
- package/.docs/raw/reference/processors/processor-interface.mdx +502 -0
- package/.docs/raw/reference/processors/prompt-injection-detector.mdx +10 -3
- package/.docs/raw/reference/processors/semantic-recall-processor.mdx +197 -0
- package/.docs/raw/reference/processors/system-prompt-scrubber.mdx +3 -4
- package/.docs/raw/reference/processors/token-limiter-processor.mdx +2 -2
- package/.docs/raw/reference/processors/tool-call-filter.mdx +125 -0
- package/.docs/raw/reference/processors/unicode-normalizer.mdx +1 -1
- package/.docs/raw/reference/processors/working-memory-processor.mdx +221 -0
- package/.docs/raw/reference/rag/embeddings.mdx +5 -5
- package/.docs/raw/reference/rag/rerank.mdx +1 -2
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +0 -1
- package/.docs/raw/reference/storage/cloudflare-d1.mdx +37 -0
- package/.docs/raw/reference/storage/convex.mdx +164 -0
- package/.docs/raw/reference/storage/lance.mdx +33 -0
- package/.docs/raw/reference/storage/libsql.mdx +37 -0
- package/.docs/raw/reference/storage/mongodb.mdx +39 -0
- package/.docs/raw/reference/storage/mssql.mdx +37 -0
- package/.docs/raw/reference/storage/postgresql.mdx +37 -0
- package/.docs/raw/reference/streaming/ChunkType.mdx +1 -1
- package/.docs/raw/reference/streaming/agents/stream.mdx +64 -2
- package/.docs/raw/reference/streaming/workflows/observeStream.mdx +7 -9
- package/.docs/raw/reference/streaming/workflows/{resumeStreamVNext.mdx → resumeStream.mdx} +51 -11
- package/.docs/raw/reference/streaming/workflows/stream.mdx +83 -24
- package/.docs/raw/reference/templates/overview.mdx +1 -4
- package/.docs/raw/reference/tools/client.mdx +1 -2
- package/.docs/raw/reference/tools/create-tool.mdx +132 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +5 -5
- package/.docs/raw/reference/tools/mcp-client.mdx +76 -21
- package/.docs/raw/reference/tools/mcp-server.mdx +1 -2
- package/.docs/raw/reference/tools/vector-query-tool.mdx +14 -15
- package/.docs/raw/reference/vectors/chroma.mdx +81 -1
- package/.docs/raw/reference/vectors/convex.mdx +429 -0
- package/.docs/raw/reference/vectors/couchbase.mdx +24 -17
- package/.docs/raw/reference/vectors/duckdb.mdx +462 -0
- package/.docs/raw/reference/vectors/elasticsearch.mdx +310 -0
- package/.docs/raw/reference/vectors/lance.mdx +38 -22
- package/.docs/raw/reference/vectors/libsql.mdx +35 -2
- package/.docs/raw/reference/vectors/mongodb.mdx +35 -2
- package/.docs/raw/reference/vectors/opensearch.mdx +37 -16
- package/.docs/raw/reference/vectors/pg.mdx +43 -36
- package/.docs/raw/reference/vectors/pinecone.mdx +48 -1
- package/.docs/raw/reference/vectors/qdrant.mdx +36 -1
- package/.docs/raw/reference/vectors/turbopuffer.mdx +74 -0
- package/.docs/raw/reference/voice/google.mdx +159 -20
- package/.docs/raw/reference/voice/openai-realtime.mdx +2 -2
- package/.docs/raw/reference/voice/voice.addInstructions.mdx +2 -3
- package/.docs/raw/reference/voice/voice.addTools.mdx +1 -1
- package/.docs/raw/reference/voice/voice.answer.mdx +1 -1
- package/.docs/raw/reference/voice/voice.close.mdx +1 -1
- package/.docs/raw/reference/voice/voice.connect.mdx +1 -1
- package/.docs/raw/reference/voice/voice.off.mdx +1 -1
- package/.docs/raw/reference/voice/voice.on.mdx +1 -1
- package/.docs/raw/reference/voice/voice.send.mdx +1 -1
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +1 -1
- package/.docs/raw/reference/workflows/run-methods/restart.mdx +142 -0
- package/.docs/raw/reference/workflows/run-methods/resume.mdx +44 -0
- package/.docs/raw/reference/workflows/run-methods/start.mdx +44 -0
- package/.docs/raw/reference/workflows/run.mdx +13 -5
- package/.docs/raw/reference/workflows/step.mdx +13 -0
- package/.docs/raw/reference/workflows/workflow.mdx +19 -0
- package/.docs/raw/server-db/mastra-client.mdx +1 -2
- package/.docs/raw/server-db/mastra-server.mdx +30 -1
- package/.docs/raw/server-db/request-context.mdx +0 -1
- package/.docs/raw/server-db/storage.mdx +11 -0
- package/.docs/raw/streaming/overview.mdx +26 -15
- package/.docs/raw/streaming/tool-streaming.mdx +48 -5
- package/.docs/raw/streaming/workflow-streaming.mdx +5 -11
- package/.docs/raw/tools-mcp/advanced-usage.mdx +1 -2
- package/.docs/raw/tools-mcp/mcp-overview.mdx +3 -5
- package/.docs/raw/voice/overview.mdx +21 -41
- package/.docs/raw/voice/speech-to-speech.mdx +4 -4
- package/.docs/raw/voice/speech-to-text.mdx +1 -2
- package/.docs/raw/voice/text-to-speech.mdx +1 -2
- package/.docs/raw/workflows/control-flow.mdx +180 -0
- package/.docs/raw/workflows/error-handling.mdx +1 -0
- package/.docs/raw/workflows/human-in-the-loop.mdx +4 -4
- package/.docs/raw/workflows/overview.mdx +56 -44
- package/.docs/raw/workflows/snapshots.mdx +1 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +85 -16
- package/.docs/raw/workflows/time-travel.mdx +313 -0
- package/.docs/raw/workflows/workflow-state.mdx +191 -0
- package/CHANGELOG.md +18 -0
- package/dist/{chunk-5NJC7NRO.js → chunk-4CM2BQNP.js} +24 -4
- package/dist/prepare-docs/package-changes.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.js +1 -1
- package/dist/stdio.js +1 -1
- package/package.json +7 -7
- package/.docs/raw/agents/human-in-the-loop-with-tools.mdx +0 -90
- package/.docs/raw/frameworks/agentic-uis/cedar-os.mdx +0 -102
- package/.docs/raw/frameworks/agentic-uis/openrouter.mdx +0 -179
- package/.docs/raw/frameworks/web-frameworks/next-js.mdx +0 -379
- package/.docs/raw/getting-started/quickstart.mdx +0 -27
- package/.docs/raw/getting-started/templates.mdx +0 -73
- package/.docs/raw/reference/streaming/workflows/observeStreamVNext.mdx +0 -47
- package/.docs/raw/reference/streaming/workflows/streamVNext.mdx +0 -153
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/assistant-ui.mdx +0 -0
- /package/.docs/raw/{frameworks/agentic-uis → guides/build-your-ui}/copilotkit.mdx +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Reference: Run.stream() | Streaming"
|
|
3
|
-
description: Documentation for the `Run.stream()` method in workflows, which
|
|
3
|
+
description: Documentation for the `Run.stream()` method in workflows, which enables real-time streaming of responses.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Run.stream()
|
|
7
7
|
|
|
8
|
-
The `.stream()` method
|
|
8
|
+
The `.stream()` method enables real-time streaming of responses from a workflow.
|
|
9
9
|
|
|
10
10
|
## Usage example
|
|
11
11
|
|
|
12
12
|
```typescript showLineNumbers copy
|
|
13
13
|
const run = await workflow.createRun();
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const stream = run.stream({
|
|
16
16
|
inputData: {
|
|
17
17
|
value: "initial data",
|
|
18
18
|
},
|
|
@@ -40,7 +40,7 @@ const { stream } = await run.stream({
|
|
|
40
40
|
type: "TracingContext",
|
|
41
41
|
isOptional: true,
|
|
42
42
|
description:
|
|
43
|
-
"Tracing context for creating child spans and adding metadata.
|
|
43
|
+
"Tracing context for creating child spans and adding metadata.",
|
|
44
44
|
properties: [
|
|
45
45
|
{
|
|
46
46
|
parameters: [
|
|
@@ -49,7 +49,7 @@ const { stream } = await run.stream({
|
|
|
49
49
|
type: "Span",
|
|
50
50
|
isOptional: true,
|
|
51
51
|
description:
|
|
52
|
-
"Current span for creating child spans and adding metadata.
|
|
52
|
+
"Current span for creating child spans and adding metadata.",
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
},
|
|
@@ -67,13 +67,63 @@ const { stream } = await run.stream({
|
|
|
67
67
|
name: "metadata",
|
|
68
68
|
type: "Record<string, any>",
|
|
69
69
|
isOptional: true,
|
|
70
|
+
description: "Metadata to add to the root trace span.",
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
parameters: [
|
|
76
|
+
{
|
|
77
|
+
name: "requestContextKeys",
|
|
78
|
+
type: "string[]",
|
|
79
|
+
isOptional: true,
|
|
80
|
+
description:
|
|
81
|
+
"Additional RequestContext keys to extract as metadata for this trace. Supports dot notation for nested values (e.g., 'user.id').",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
parameters: [
|
|
87
|
+
{
|
|
88
|
+
name: "traceId",
|
|
89
|
+
type: "string",
|
|
90
|
+
isOptional: true,
|
|
91
|
+
description:
|
|
92
|
+
"Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.",
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
parameters: [
|
|
98
|
+
{
|
|
99
|
+
name: "parentSpanId",
|
|
100
|
+
type: "string",
|
|
101
|
+
isOptional: true,
|
|
70
102
|
description:
|
|
71
|
-
"
|
|
103
|
+
"Parent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
parameters: [
|
|
109
|
+
{
|
|
110
|
+
name: "tags",
|
|
111
|
+
type: "string[]",
|
|
112
|
+
isOptional: true,
|
|
113
|
+
description:
|
|
114
|
+
"Tags to apply to this trace. String labels for categorizing and filtering traces.",
|
|
72
115
|
},
|
|
73
116
|
],
|
|
74
117
|
},
|
|
75
118
|
],
|
|
76
119
|
},
|
|
120
|
+
{
|
|
121
|
+
name: "closeOnSuspend",
|
|
122
|
+
type: "boolean",
|
|
123
|
+
description:
|
|
124
|
+
"Whether to close the stream when the workflow is suspended, or to keep the stream open until the workflow is finished (by success or error). Default value is true.",
|
|
125
|
+
isOptional: true,
|
|
126
|
+
},
|
|
77
127
|
]}
|
|
78
128
|
/>
|
|
79
129
|
|
|
@@ -83,22 +133,31 @@ const { stream } = await run.stream({
|
|
|
83
133
|
content={[
|
|
84
134
|
{
|
|
85
135
|
name: "stream",
|
|
86
|
-
type: "
|
|
136
|
+
type: "MastraWorkflowStream<ChunkType>",
|
|
87
137
|
description:
|
|
88
|
-
"A
|
|
138
|
+
"A custom stream that extends ReadableStream<ChunkType> with additional workflow-specific properties",
|
|
89
139
|
},
|
|
90
140
|
{
|
|
91
|
-
name: "
|
|
92
|
-
type: "
|
|
93
|
-
description:
|
|
94
|
-
|
|
141
|
+
name: "stream.status",
|
|
142
|
+
type: "Promise<RunStatus>",
|
|
143
|
+
description: "A promise that resolves to the current workflow run status",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "stream.result",
|
|
147
|
+
type: "Promise<WorkflowResult<TState, TOutput, TSteps>>",
|
|
148
|
+
description: "A promise that resolves to the final workflow result",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "stream.usage",
|
|
152
|
+
type: "Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>",
|
|
153
|
+
description: "A promise that resolves to token usage statistics",
|
|
95
154
|
},
|
|
96
155
|
{
|
|
97
|
-
name: "traceId",
|
|
156
|
+
name: "stream.traceId",
|
|
98
157
|
type: "string",
|
|
99
158
|
isOptional: true,
|
|
100
159
|
description:
|
|
101
|
-
"The trace ID associated with this execution when Tracing is enabled.
|
|
160
|
+
"The trace ID associated with this execution when Tracing is enabled.",
|
|
102
161
|
},
|
|
103
162
|
]}
|
|
104
163
|
/>
|
|
@@ -106,29 +165,29 @@ const { stream } = await run.stream({
|
|
|
106
165
|
## Extended usage example
|
|
107
166
|
|
|
108
167
|
```typescript showLineNumbers copy
|
|
109
|
-
const
|
|
168
|
+
const run = await workflow.createRun();
|
|
169
|
+
|
|
170
|
+
const stream = run.stream({
|
|
110
171
|
inputData: {
|
|
111
172
|
value: "initial data",
|
|
112
173
|
},
|
|
113
174
|
});
|
|
114
175
|
|
|
115
|
-
const result = await
|
|
176
|
+
const result = await stream.result;
|
|
116
177
|
```
|
|
117
178
|
|
|
118
179
|
## Stream Events
|
|
119
180
|
|
|
120
181
|
The stream emits various event types during workflow execution. Each event has a `type` field and a `payload` containing relevant data:
|
|
121
182
|
|
|
122
|
-
- **`start`**: Workflow execution begins
|
|
123
|
-
- **`step-start`**: A step begins execution
|
|
124
|
-
- **`
|
|
125
|
-
- **`
|
|
126
|
-
- **`
|
|
127
|
-
- **`step-result`**: A step completes with results
|
|
128
|
-
- **`step-finish`**: A step finishes execution
|
|
129
|
-
- **`finish`**: Workflow execution completes
|
|
183
|
+
- **`workflow-start`**: Workflow execution begins
|
|
184
|
+
- **`workflow-step-start`**: A step begins execution
|
|
185
|
+
- **`workflow-step-output`**: Custom output from a step
|
|
186
|
+
- **`workflow-step-result`**: A step completes with results
|
|
187
|
+
- **`workflow-finish`**: Workflow execution completes with usage statistics
|
|
130
188
|
|
|
131
189
|
## Related
|
|
132
190
|
|
|
133
191
|
- [Workflows overview](/docs/v1/workflows/overview#running-workflows)
|
|
134
192
|
- [Workflow.createRun()](/reference/v1/workflows/workflow-methods/create-run)
|
|
193
|
+
- [Run.resumeStream()](./resumeStream)
|
|
@@ -118,13 +118,10 @@ We recommend using OpenAI, Anthropic, or Google model providers for templates. C
|
|
|
118
118
|
|
|
119
119
|
```typescript title="src/mastra/agents/example-agent.ts"
|
|
120
120
|
import { Agent } from "@mastra/core/agent";
|
|
121
|
-
import { openai } from "@ai-sdk/openai";
|
|
122
|
-
// Or use: import { anthropic } from '@ai-sdk/anthropic';
|
|
123
|
-
// Or use: import { google } from '@ai-sdk/google';
|
|
124
121
|
|
|
125
122
|
const agent = new Agent({
|
|
126
123
|
name: "example-agent",
|
|
127
|
-
model: openai
|
|
124
|
+
model: "openai/gpt-5.1", // or other provider strings
|
|
128
125
|
instructions: "Your agent instructions here",
|
|
129
126
|
// ... other configuration
|
|
130
127
|
});
|
|
@@ -230,7 +230,6 @@ Returns an object mapping tool names to their corresponding Mastra tool implemen
|
|
|
230
230
|
```typescript
|
|
231
231
|
import { Agent } from "@mastra/core/agent";
|
|
232
232
|
import { MastraMCPClient } from "@mastra/mcp";
|
|
233
|
-
import { openai } from "@ai-sdk/openai";
|
|
234
233
|
|
|
235
234
|
// Initialize the MCP client using mcp/fetch as an example https://hub.docker.com/r/mcp/fetch
|
|
236
235
|
// Visit https://github.com/docker/mcp-servers for other reference docker mcp servers
|
|
@@ -250,7 +249,7 @@ const agent = new Agent({
|
|
|
250
249
|
name: "Fetch agent",
|
|
251
250
|
instructions:
|
|
252
251
|
"You are able to fetch data from URLs on demand and discuss the response data with the user.",
|
|
253
|
-
model: openai
|
|
252
|
+
model: "openai/gpt-5.1",
|
|
254
253
|
});
|
|
255
254
|
|
|
256
255
|
try {
|
|
@@ -131,6 +131,34 @@ export const tool = createTool({
|
|
|
131
131
|
},
|
|
132
132
|
],
|
|
133
133
|
},
|
|
134
|
+
{
|
|
135
|
+
name: "onInputStart",
|
|
136
|
+
type: "function",
|
|
137
|
+
description:
|
|
138
|
+
"Optional callback invoked when the tool call input streaming begins. Receives `toolCallId`, `messages`, and `abortSignal`.",
|
|
139
|
+
isOptional: true,
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "onInputDelta",
|
|
143
|
+
type: "function",
|
|
144
|
+
description:
|
|
145
|
+
"Optional callback invoked for each incremental chunk of input text as it streams in. Receives `inputTextDelta`, `toolCallId`, `messages`, and `abortSignal`.",
|
|
146
|
+
isOptional: true,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "onInputAvailable",
|
|
150
|
+
type: "function",
|
|
151
|
+
description:
|
|
152
|
+
"Optional callback invoked when the complete tool input is available and parsed. Receives the validated `input` object, `toolCallId`, `messages`, and `abortSignal`.",
|
|
153
|
+
isOptional: true,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "onOutput",
|
|
157
|
+
type: "function",
|
|
158
|
+
description:
|
|
159
|
+
"Optional callback invoked after the tool has successfully executed and returned output. Receives the tool's `output`, `toolCallId`, `messages`, and `abortSignal`.",
|
|
160
|
+
isOptional: true,
|
|
161
|
+
},
|
|
134
162
|
]}
|
|
135
163
|
/>
|
|
136
164
|
|
|
@@ -149,8 +177,112 @@ The `createTool()` function returns a `Tool` object.
|
|
|
149
177
|
]}
|
|
150
178
|
/>
|
|
151
179
|
|
|
180
|
+
## Tool Lifecycle Hooks
|
|
181
|
+
|
|
182
|
+
Tools support lifecycle hooks that allow you to monitor and react to different stages of tool execution. These hooks are particularly useful for logging, analytics, validation, and real-time updates during streaming.
|
|
183
|
+
|
|
184
|
+
### Available Hooks
|
|
185
|
+
|
|
186
|
+
#### onInputStart
|
|
187
|
+
|
|
188
|
+
Called when tool call input streaming begins, before any input data is received.
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
export const tool = createTool({
|
|
192
|
+
id: "example-tool",
|
|
193
|
+
description: "Example tool with hooks",
|
|
194
|
+
onInputStart: ({ toolCallId, messages, abortSignal }) => {
|
|
195
|
+
console.log(`Tool ${toolCallId} input streaming started`);
|
|
196
|
+
},
|
|
197
|
+
// ... other properties
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### onInputDelta
|
|
202
|
+
|
|
203
|
+
Called for each incremental chunk of input text as it streams in. Useful for showing real-time progress or parsing partial JSON.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
export const tool = createTool({
|
|
207
|
+
id: "example-tool",
|
|
208
|
+
description: "Example tool with hooks",
|
|
209
|
+
onInputDelta: ({ inputTextDelta, toolCallId, messages, abortSignal }) => {
|
|
210
|
+
console.log(`Received input chunk: ${inputTextDelta}`);
|
|
211
|
+
},
|
|
212
|
+
// ... other properties
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### onInputAvailable
|
|
217
|
+
|
|
218
|
+
Called when the complete tool input is available and has been parsed and validated against the `inputSchema`.
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
export const tool = createTool({
|
|
222
|
+
id: "example-tool",
|
|
223
|
+
description: "Example tool with hooks",
|
|
224
|
+
inputSchema: z.object({
|
|
225
|
+
city: z.string(),
|
|
226
|
+
}),
|
|
227
|
+
onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => {
|
|
228
|
+
console.log(`Tool received complete input:`, input);
|
|
229
|
+
// input is fully typed based on inputSchema
|
|
230
|
+
},
|
|
231
|
+
// ... other properties
|
|
232
|
+
});
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### onOutput
|
|
236
|
+
|
|
237
|
+
Called after the tool has successfully executed and returned output. Useful for logging results, triggering follow-up actions, or analytics.
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
export const tool = createTool({
|
|
241
|
+
id: "example-tool",
|
|
242
|
+
description: "Example tool with hooks",
|
|
243
|
+
outputSchema: z.object({
|
|
244
|
+
result: z.string(),
|
|
245
|
+
}),
|
|
246
|
+
execute: async (input) => {
|
|
247
|
+
return { result: "Success" };
|
|
248
|
+
},
|
|
249
|
+
onOutput: ({ output, toolCallId, toolName, abortSignal }) => {
|
|
250
|
+
console.log(`${toolName} execution completed:`, output);
|
|
251
|
+
// output is fully typed based on outputSchema
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Hook Execution Order
|
|
257
|
+
|
|
258
|
+
For a typical streaming tool call, the hooks are invoked in this order:
|
|
259
|
+
|
|
260
|
+
1. **onInputStart** - Input streaming begins
|
|
261
|
+
2. **onInputDelta** - Called multiple times as chunks arrive
|
|
262
|
+
3. **onInputAvailable** - Complete input is parsed and validated
|
|
263
|
+
4. Tool's **execute** function runs
|
|
264
|
+
5. **onOutput** - Tool has completed successfully
|
|
265
|
+
|
|
266
|
+
### Hook Parameters
|
|
267
|
+
|
|
268
|
+
All hooks receive a parameter object with these common properties:
|
|
269
|
+
|
|
270
|
+
- `toolCallId` (string): Unique identifier for this specific tool call
|
|
271
|
+
- `abortSignal` (AbortSignal): Signal for detecting if the operation should be cancelled
|
|
272
|
+
|
|
273
|
+
Additionally:
|
|
274
|
+
- `onInputStart`, `onInputDelta`, and `onInputAvailable` receive `messages` (array): The conversation messages at the time of the tool call
|
|
275
|
+
- `onInputDelta` receives `inputTextDelta` (string): The incremental text chunk
|
|
276
|
+
- `onInputAvailable` receives `input`: The validated input data (typed according to `inputSchema`)
|
|
277
|
+
- `onOutput` receives `output`: The tool's return value (typed according to `outputSchema`) and `toolName` (string): The name of the tool
|
|
278
|
+
|
|
279
|
+
### Error Handling
|
|
280
|
+
|
|
281
|
+
Hook errors are caught and logged automatically, but do not prevent tool execution from continuing. If a hook throws an error, it will be logged to the console but will not fail the tool call.
|
|
282
|
+
|
|
152
283
|
## Related
|
|
153
284
|
|
|
154
285
|
- [MCP Overview](/docs/v1/mcp/overview)
|
|
155
286
|
- [Using Tools with Agents](/docs/v1/agents/using-tools)
|
|
287
|
+
- [Tool Streaming](/docs/v1/streaming/tool-streaming)
|
|
156
288
|
- [Request Context](/docs/v1/server-db/request-context#accessing-values-with-tools)
|
|
@@ -10,13 +10,13 @@ The `createGraphRAGTool()` creates a tool that enhances RAG by building a graph
|
|
|
10
10
|
## Usage Example
|
|
11
11
|
|
|
12
12
|
```typescript
|
|
13
|
-
import { openai } from "@ai-sdk/openai";
|
|
14
13
|
import { createGraphRAGTool } from "@mastra/rag";
|
|
14
|
+
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
15
15
|
|
|
16
16
|
const graphTool = createGraphRAGTool({
|
|
17
17
|
vectorStoreName: "pinecone",
|
|
18
18
|
indexName: "docs",
|
|
19
|
-
model:
|
|
19
|
+
model: new ModelRouterEmbeddingModel("openai/text-embedding-3-small"),
|
|
20
20
|
graphOptions: {
|
|
21
21
|
dimension: 1536,
|
|
22
22
|
threshold: 0.7,
|
|
@@ -193,7 +193,7 @@ The default description focuses on:
|
|
|
193
193
|
const graphTool = createGraphRAGTool({
|
|
194
194
|
vectorStoreName: "pinecone",
|
|
195
195
|
indexName: "docs",
|
|
196
|
-
model:
|
|
196
|
+
model: new ModelRouterEmbeddingModel("openai/text-embedding-3-small"),
|
|
197
197
|
graphOptions: {
|
|
198
198
|
dimension: 1536,
|
|
199
199
|
threshold: 0.8, // Higher similarity threshold
|
|
@@ -209,7 +209,7 @@ const graphTool = createGraphRAGTool({
|
|
|
209
209
|
const graphTool = createGraphRAGTool({
|
|
210
210
|
vectorStoreName: "pinecone",
|
|
211
211
|
indexName: "docs",
|
|
212
|
-
model: openai
|
|
212
|
+
model: "openai/text-embedding-3-small ",
|
|
213
213
|
description:
|
|
214
214
|
"Analyze document relationships to find complex patterns and connections in our company's historical data",
|
|
215
215
|
});
|
|
@@ -223,7 +223,7 @@ This example shows how to customize the tool description for a specific use case
|
|
|
223
223
|
const graphTool = createGraphRAGTool({
|
|
224
224
|
vectorStoreName: "pinecone",
|
|
225
225
|
indexName: "docs",
|
|
226
|
-
model: openai
|
|
226
|
+
model: "openai/text-embedding-3-small ",
|
|
227
227
|
});
|
|
228
228
|
```
|
|
229
229
|
|
|
@@ -291,23 +291,6 @@ mcpClient.resources.onListChanged("myWeatherServer", () => {
|
|
|
291
291
|
});
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
### `prompts` Property
|
|
295
|
-
|
|
296
|
-
The `MCPClient` instance has a `prompts` property that provides access to prompt-related operations.
|
|
297
|
-
|
|
298
|
-
```typescript
|
|
299
|
-
const mcpClient = new MCPClient({
|
|
300
|
-
/* ...servers configuration... */
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
// Access prompt methods via mcpClient.prompts
|
|
304
|
-
const allPromptsByServer = await mcpClient.prompts.list();
|
|
305
|
-
const { prompt, messages } = await mcpClient.prompts.get({
|
|
306
|
-
serverName: "myWeatherServer",
|
|
307
|
-
name: "current",
|
|
308
|
-
});
|
|
309
|
-
```
|
|
310
|
-
|
|
311
294
|
### `elicitation` Property
|
|
312
295
|
|
|
313
296
|
The `MCPClient` instance has an `elicitation` property that provides access to elicitation-related operations. Elicitation allows MCP servers to request structured information from users.
|
|
@@ -451,6 +434,23 @@ await mcpClient.elicitation.onRequest("interactiveServer", async (request) => {
|
|
|
451
434
|
});
|
|
452
435
|
```
|
|
453
436
|
|
|
437
|
+
### `prompts` Property
|
|
438
|
+
|
|
439
|
+
The `MCPClient` instance has a `prompts` property that provides access to prompt-related operations.
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
const mcpClient = new MCPClient({
|
|
443
|
+
/* ...servers configuration... */
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Access prompt methods via mcpClient.prompts
|
|
447
|
+
const allPromptsByServer = await mcpClient.prompts.list();
|
|
448
|
+
const { prompt, messages } = await mcpClient.prompts.get({
|
|
449
|
+
serverName: "myWeatherServer",
|
|
450
|
+
name: "current",
|
|
451
|
+
});
|
|
452
|
+
```
|
|
453
|
+
|
|
454
454
|
#### `prompts.list()`
|
|
455
455
|
|
|
456
456
|
Retrieves all available prompts from all connected MCP servers, grouped by server name.
|
|
@@ -516,6 +516,63 @@ mcpClient.prompts.onListChanged("myWeatherServer", () => {
|
|
|
516
516
|
});
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
+
### `progress` Property
|
|
520
|
+
|
|
521
|
+
The `MCPClient` instance has a `progress` property for subscribing to progress notifications emitted by MCP servers while tools execute.
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
const mcpClient = new MCPClient({
|
|
525
|
+
servers: {
|
|
526
|
+
myServer: {
|
|
527
|
+
url: new URL('http://localhost:4111/api/mcp/myServer/mcp'),
|
|
528
|
+
// Enabled by default; set to false to disable
|
|
529
|
+
enableProgressTracking: true,
|
|
530
|
+
},
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Subscribe to progress updates for a specific server
|
|
535
|
+
await mcpClient.progress.onUpdate('myServer', (params) => {
|
|
536
|
+
console.log('📊 Progress:', params.progress, '/', params.total);
|
|
537
|
+
if (params.message) console.log('Message:', params.message);
|
|
538
|
+
if (params.progressToken) console.log('Token:', params.progressToken);
|
|
539
|
+
});
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### `progress.onUpdate(serverName: string, handler)`
|
|
543
|
+
|
|
544
|
+
Registers a handler function to receive progress updates from the specified server.
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
async onUpdate(
|
|
548
|
+
serverName: string,
|
|
549
|
+
handler: (params: {
|
|
550
|
+
progressToken: string;
|
|
551
|
+
progress: number;
|
|
552
|
+
total?: number;
|
|
553
|
+
message?: string;
|
|
554
|
+
}) => void,
|
|
555
|
+
): Promise<void>
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
Notes:
|
|
559
|
+
|
|
560
|
+
- When `enableProgressTracking` is true (default), tool calls include a `progressToken` so you can correlate updates to a specific run.
|
|
561
|
+
- If you pass a `runId` when executing a tool, it will be used as the `progressToken`.
|
|
562
|
+
|
|
563
|
+
To disable progress tracking for a server:
|
|
564
|
+
|
|
565
|
+
```typescript
|
|
566
|
+
const mcpClient = new MCPClient({
|
|
567
|
+
servers: {
|
|
568
|
+
myServer: {
|
|
569
|
+
url: new URL('http://localhost:4111/api/mcp/myServer/mcp'),
|
|
570
|
+
enableProgressTracking: false,
|
|
571
|
+
},
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
```
|
|
575
|
+
|
|
519
576
|
## Elicitation
|
|
520
577
|
|
|
521
578
|
Elicitation is a feature that allows MCP servers to request structured information from users. When a server needs additional data, it can send an elicitation request that the client handles by prompting the user. A common example is during a tool call.
|
|
@@ -632,7 +689,6 @@ For tools where you have a single connection to the MCP server for you entire ap
|
|
|
632
689
|
```typescript
|
|
633
690
|
import { MCPClient } from "@mastra/mcp";
|
|
634
691
|
import { Agent } from "@mastra/core/agent";
|
|
635
|
-
import { openai } from "@ai-sdk/openai";
|
|
636
692
|
|
|
637
693
|
const mcp = new MCPClient({
|
|
638
694
|
servers: {
|
|
@@ -657,7 +713,7 @@ const mcp = new MCPClient({
|
|
|
657
713
|
const agent = new Agent({
|
|
658
714
|
name: "Multi-tool Agent",
|
|
659
715
|
instructions: "You have access to multiple tool servers.",
|
|
660
|
-
model: openai
|
|
716
|
+
model: "openai/gpt-5.1",
|
|
661
717
|
tools: await mcp.listTools(),
|
|
662
718
|
});
|
|
663
719
|
|
|
@@ -707,13 +763,12 @@ When you need a new MCP connection for each user, use `listToolsets()` and add t
|
|
|
707
763
|
```typescript
|
|
708
764
|
import { Agent } from "@mastra/core/agent";
|
|
709
765
|
import { MCPClient } from "@mastra/mcp";
|
|
710
|
-
import { openai } from "@ai-sdk/openai";
|
|
711
766
|
|
|
712
767
|
// Create the agent first, without any tools
|
|
713
768
|
const agent = new Agent({
|
|
714
769
|
name: "Multi-tool Agent",
|
|
715
770
|
instructions: "You help users check stocks and weather.",
|
|
716
|
-
model: openai
|
|
771
|
+
model: "openai/gpt-5.1",
|
|
717
772
|
});
|
|
718
773
|
|
|
719
774
|
// Later, configure MCP with user-specific settings
|
|
@@ -16,7 +16,6 @@ It supports both [stdio (subprocess) and SSE (HTTP) MCP transports](https://mode
|
|
|
16
16
|
To create a new `MCPServer`, you need to provide some basic information about your server, the tools it will offer, and optionally, any agents you want to expose as tools.
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { openai } from "@ai-sdk/openai";
|
|
20
19
|
import { Agent } from "@mastra/core/agent";
|
|
21
20
|
import { createTool } from "@mastra/core/tools";
|
|
22
21
|
import { MCPServer } from "@mastra/mcp";
|
|
@@ -28,7 +27,7 @@ const myAgent = new Agent({
|
|
|
28
27
|
name: "MyExampleAgent",
|
|
29
28
|
description: "A generalist to help with basic questions."
|
|
30
29
|
instructions: "You are a helpful assistant.",
|
|
31
|
-
model: openai
|
|
30
|
+
model: "openai/gpt-5.1",
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
const weatherTool = createTool({
|