@mastra/mcp-docs-server 1.1.7-alpha.0 → 1.1.8-alpha.0

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.
Files changed (276) hide show
  1. package/.docs/docs/agents/agent-approval.md +61 -31
  2. package/.docs/docs/agents/supervisor-agents.md +1 -1
  3. package/.docs/docs/getting-started/manual-install.md +1 -1
  4. package/.docs/docs/index.md +68 -24
  5. package/.docs/docs/mastra-cloud/setup.md +1 -1
  6. package/.docs/docs/memory/observational-memory.md +9 -0
  7. package/.docs/docs/memory/semantic-recall.md +17 -1
  8. package/.docs/docs/workspace/skills.md +7 -5
  9. package/.docs/guides/deployment/aws-lambda.md +76 -165
  10. package/.docs/guides/deployment/azure-app-services.md +38 -61
  11. package/.docs/guides/deployment/cloudflare.md +1 -1
  12. package/.docs/guides/deployment/netlify.md +1 -1
  13. package/.docs/guides/deployment/vercel.md +1 -1
  14. package/.docs/models/gateways/netlify.md +5 -1
  15. package/.docs/models/index.md +1 -1
  16. package/.docs/models/providers/anthropic.md +9 -9
  17. package/.docs/models/providers/deepseek.md +1 -1
  18. package/.docs/models/providers/google.md +11 -11
  19. package/.docs/models/providers/openai.md +19 -19
  20. package/.docs/models/providers/opencode.md +33 -33
  21. package/.docs/models/providers/xai.md +3 -3
  22. package/.docs/reference/agents/agent.md +20 -20
  23. package/.docs/reference/agents/generate.md +200 -66
  24. package/.docs/reference/agents/generateLegacy.md +77 -35
  25. package/.docs/reference/agents/getDefaultGenerateOptions.md +4 -6
  26. package/.docs/reference/agents/getDefaultOptions.md +4 -6
  27. package/.docs/reference/agents/getDefaultStreamOptions.md +4 -6
  28. package/.docs/reference/agents/getDescription.md +1 -1
  29. package/.docs/reference/agents/getInstructions.md +4 -6
  30. package/.docs/reference/agents/getLLM.md +6 -8
  31. package/.docs/reference/agents/getMemory.md +4 -6
  32. package/.docs/reference/agents/getModel.md +4 -6
  33. package/.docs/reference/agents/getTools.md +5 -7
  34. package/.docs/reference/agents/getVoice.md +4 -6
  35. package/.docs/reference/agents/listAgents.md +4 -6
  36. package/.docs/reference/agents/listScorers.md +4 -6
  37. package/.docs/reference/agents/listTools.md +4 -6
  38. package/.docs/reference/agents/listWorkflows.md +4 -6
  39. package/.docs/reference/agents/network.md +69 -23
  40. package/.docs/reference/ai-sdk/chat-route.md +7 -7
  41. package/.docs/reference/ai-sdk/handle-chat-stream.md +12 -12
  42. package/.docs/reference/ai-sdk/handle-network-stream.md +4 -4
  43. package/.docs/reference/ai-sdk/handle-workflow-stream.md +11 -11
  44. package/.docs/reference/ai-sdk/network-route.md +3 -3
  45. package/.docs/reference/ai-sdk/to-ai-sdk-stream.md +9 -9
  46. package/.docs/reference/ai-sdk/to-ai-sdk-v4-messages.md +9 -9
  47. package/.docs/reference/ai-sdk/to-ai-sdk-v5-messages.md +5 -5
  48. package/.docs/reference/ai-sdk/with-mastra.md +12 -12
  49. package/.docs/reference/ai-sdk/workflow-route.md +3 -3
  50. package/.docs/reference/auth/auth0.md +6 -6
  51. package/.docs/reference/auth/better-auth.md +5 -5
  52. package/.docs/reference/auth/clerk.md +5 -5
  53. package/.docs/reference/auth/firebase.md +7 -7
  54. package/.docs/reference/auth/jwt.md +1 -1
  55. package/.docs/reference/auth/supabase.md +4 -4
  56. package/.docs/reference/auth/workos.md +6 -6
  57. package/.docs/reference/cli/create-mastra.md +14 -14
  58. package/.docs/reference/client-js/mastra-client.md +23 -23
  59. package/.docs/reference/client-js/workflows.md +3 -3
  60. package/.docs/reference/core/addGateway.md +2 -2
  61. package/.docs/reference/core/getAgent.md +2 -2
  62. package/.docs/reference/core/getAgentById.md +2 -2
  63. package/.docs/reference/core/getDeployer.md +1 -1
  64. package/.docs/reference/core/getGateway.md +2 -2
  65. package/.docs/reference/core/getGatewayById.md +2 -2
  66. package/.docs/reference/core/getLogger.md +1 -1
  67. package/.docs/reference/core/getMCPServer.md +2 -2
  68. package/.docs/reference/core/getMCPServerById.md +3 -3
  69. package/.docs/reference/core/getMemory.md +2 -2
  70. package/.docs/reference/core/getScorer.md +2 -2
  71. package/.docs/reference/core/getScorerById.md +2 -2
  72. package/.docs/reference/core/getServer.md +1 -1
  73. package/.docs/reference/core/getStorage.md +1 -1
  74. package/.docs/reference/core/getStoredAgentById.md +18 -20
  75. package/.docs/reference/core/getTelemetry.md +1 -1
  76. package/.docs/reference/core/getVector.md +2 -2
  77. package/.docs/reference/core/getWorkflow.md +3 -3
  78. package/.docs/reference/core/listAgents.md +1 -1
  79. package/.docs/reference/core/listGateways.md +1 -1
  80. package/.docs/reference/core/listLogs.md +9 -11
  81. package/.docs/reference/core/listLogsByRunId.md +9 -9
  82. package/.docs/reference/core/listMCPServers.md +1 -1
  83. package/.docs/reference/core/listMemory.md +1 -1
  84. package/.docs/reference/core/listScorers.md +1 -1
  85. package/.docs/reference/core/listStoredAgents.md +9 -11
  86. package/.docs/reference/core/listVectors.md +1 -1
  87. package/.docs/reference/core/listWorkflows.md +2 -2
  88. package/.docs/reference/core/mastra-class.md +17 -17
  89. package/.docs/reference/core/mastra-model-gateway.md +15 -15
  90. package/.docs/reference/core/setLogger.md +2 -4
  91. package/.docs/reference/core/setStorage.md +1 -1
  92. package/.docs/reference/datasets/addItem.md +20 -4
  93. package/.docs/reference/datasets/addItems.md +8 -2
  94. package/.docs/reference/datasets/compareExperiments.md +15 -3
  95. package/.docs/reference/datasets/create.md +6 -6
  96. package/.docs/reference/datasets/dataset.md +1 -1
  97. package/.docs/reference/datasets/delete.md +2 -2
  98. package/.docs/reference/datasets/deleteExperiment.md +2 -2
  99. package/.docs/reference/datasets/deleteItem.md +2 -2
  100. package/.docs/reference/datasets/deleteItems.md +2 -2
  101. package/.docs/reference/datasets/get.md +2 -2
  102. package/.docs/reference/datasets/getDetails.md +9 -9
  103. package/.docs/reference/datasets/getExperiment.md +2 -2
  104. package/.docs/reference/datasets/getItem.md +3 -3
  105. package/.docs/reference/datasets/getItemHistory.md +22 -2
  106. package/.docs/reference/datasets/list.md +7 -3
  107. package/.docs/reference/datasets/listExperimentResults.md +34 -4
  108. package/.docs/reference/datasets/listExperiments.md +41 -3
  109. package/.docs/reference/datasets/listItems.md +18 -6
  110. package/.docs/reference/datasets/listVersions.md +23 -3
  111. package/.docs/reference/datasets/startExperiment.md +62 -12
  112. package/.docs/reference/datasets/startExperimentAsync.md +5 -1
  113. package/.docs/reference/datasets/update.md +6 -6
  114. package/.docs/reference/datasets/updateItem.md +5 -5
  115. package/.docs/reference/deployer.md +8 -8
  116. package/.docs/reference/evals/answer-relevancy.md +11 -11
  117. package/.docs/reference/evals/answer-similarity.md +17 -19
  118. package/.docs/reference/evals/bias.md +10 -10
  119. package/.docs/reference/evals/completeness.md +3 -3
  120. package/.docs/reference/evals/content-similarity.md +6 -6
  121. package/.docs/reference/evals/context-precision.md +4 -4
  122. package/.docs/reference/evals/context-relevance.md +4 -4
  123. package/.docs/reference/evals/create-scorer.md +47 -49
  124. package/.docs/reference/evals/faithfulness.md +11 -11
  125. package/.docs/reference/evals/hallucination.md +17 -21
  126. package/.docs/reference/evals/keyword-coverage.md +4 -4
  127. package/.docs/reference/evals/mastra-scorer.md +14 -14
  128. package/.docs/reference/evals/noise-sensitivity.md +4 -4
  129. package/.docs/reference/evals/prompt-alignment.md +4 -4
  130. package/.docs/reference/evals/run-evals.md +16 -16
  131. package/.docs/reference/evals/scorer-utils.md +3 -3
  132. package/.docs/reference/evals/textual-difference.md +3 -3
  133. package/.docs/reference/evals/tone-consistency.md +3 -3
  134. package/.docs/reference/evals/tool-call-accuracy.md +5 -5
  135. package/.docs/reference/evals/toxicity.md +8 -8
  136. package/.docs/reference/harness/harness-class.md +34 -42
  137. package/.docs/reference/logging/pino-logger.md +5 -5
  138. package/.docs/reference/memory/clone-utilities.md +5 -5
  139. package/.docs/reference/memory/cloneThread.md +17 -21
  140. package/.docs/reference/memory/createThread.md +10 -10
  141. package/.docs/reference/memory/deleteMessages.md +2 -2
  142. package/.docs/reference/memory/getThreadById.md +2 -2
  143. package/.docs/reference/memory/listThreads.md +5 -5
  144. package/.docs/reference/memory/memory-class.md +12 -14
  145. package/.docs/reference/memory/observational-memory.md +102 -94
  146. package/.docs/reference/memory/recall.md +14 -16
  147. package/.docs/reference/observability/tracing/configuration.md +27 -10
  148. package/.docs/reference/observability/tracing/exporters/console-exporter.md +4 -7
  149. package/.docs/reference/processors/batch-parts-processor.md +8 -10
  150. package/.docs/reference/processors/language-detector.md +14 -16
  151. package/.docs/reference/processors/message-history-processor.md +7 -9
  152. package/.docs/reference/processors/moderation-processor.md +13 -15
  153. package/.docs/reference/processors/pii-detector.md +14 -16
  154. package/.docs/reference/processors/processor-interface.md +62 -62
  155. package/.docs/reference/processors/prompt-injection-detector.md +11 -13
  156. package/.docs/reference/processors/semantic-recall-processor.md +14 -16
  157. package/.docs/reference/processors/system-prompt-scrubber.md +12 -14
  158. package/.docs/reference/processors/token-limiter-processor.md +11 -13
  159. package/.docs/reference/processors/tool-call-filter.md +5 -7
  160. package/.docs/reference/processors/tool-search-processor.md +9 -11
  161. package/.docs/reference/processors/unicode-normalizer.md +8 -10
  162. package/.docs/reference/processors/working-memory-processor.md +14 -18
  163. package/.docs/reference/rag/chunk.md +38 -38
  164. package/.docs/reference/rag/database-config.md +11 -7
  165. package/.docs/reference/rag/document.md +2 -2
  166. package/.docs/reference/rag/embeddings.md +12 -12
  167. package/.docs/reference/rag/extract-params.md +23 -23
  168. package/.docs/reference/rag/graph-rag.md +12 -12
  169. package/.docs/reference/rag/rerank.md +25 -17
  170. package/.docs/reference/rag/rerankWithScorer.md +25 -17
  171. package/.docs/reference/server/create-route.md +14 -14
  172. package/.docs/reference/server/express-adapter.md +10 -10
  173. package/.docs/reference/server/fastify-adapter.md +10 -10
  174. package/.docs/reference/server/hono-adapter.md +10 -10
  175. package/.docs/reference/server/koa-adapter.md +10 -10
  176. package/.docs/reference/server/mastra-server.md +10 -10
  177. package/.docs/reference/server/register-api-route.md +13 -13
  178. package/.docs/reference/storage/cloudflare-d1.md +5 -5
  179. package/.docs/reference/storage/cloudflare.md +6 -6
  180. package/.docs/reference/storage/composite.md +9 -9
  181. package/.docs/reference/storage/convex.md +3 -3
  182. package/.docs/reference/storage/dynamodb.md +9 -9
  183. package/.docs/reference/storage/lance.md +3 -3
  184. package/.docs/reference/storage/libsql.md +2 -2
  185. package/.docs/reference/storage/mongodb.md +5 -5
  186. package/.docs/reference/storage/mssql.md +2 -2
  187. package/.docs/reference/storage/postgresql.md +25 -25
  188. package/.docs/reference/storage/upstash.md +3 -3
  189. package/.docs/reference/streaming/ChunkType.md +251 -59
  190. package/.docs/reference/streaming/agents/MastraModelOutput.md +86 -16
  191. package/.docs/reference/streaming/agents/stream.md +155 -43
  192. package/.docs/reference/streaming/agents/streamLegacy.md +79 -39
  193. package/.docs/reference/streaming/workflows/resumeStream.md +18 -8
  194. package/.docs/reference/streaming/workflows/stream.md +21 -9
  195. package/.docs/reference/streaming/workflows/timeTravelStream.md +4 -4
  196. package/.docs/reference/tools/create-tool.md +25 -21
  197. package/.docs/reference/tools/document-chunker-tool.md +7 -7
  198. package/.docs/reference/tools/graph-rag-tool.md +16 -18
  199. package/.docs/reference/tools/mcp-client.md +38 -27
  200. package/.docs/reference/tools/mcp-server.md +45 -45
  201. package/.docs/reference/tools/vector-query-tool.md +34 -22
  202. package/.docs/reference/vectors/astra.md +22 -22
  203. package/.docs/reference/vectors/chroma.md +44 -44
  204. package/.docs/reference/vectors/convex.md +26 -26
  205. package/.docs/reference/vectors/couchbase.md +30 -30
  206. package/.docs/reference/vectors/duckdb.md +29 -29
  207. package/.docs/reference/vectors/elasticsearch.md +27 -27
  208. package/.docs/reference/vectors/lance.md +46 -38
  209. package/.docs/reference/vectors/libsql.md +31 -31
  210. package/.docs/reference/vectors/mongodb.md +32 -32
  211. package/.docs/reference/vectors/opensearch.md +27 -27
  212. package/.docs/reference/vectors/pg.md +60 -44
  213. package/.docs/reference/vectors/pinecone.md +38 -38
  214. package/.docs/reference/vectors/qdrant.md +36 -36
  215. package/.docs/reference/vectors/s3vectors.md +24 -24
  216. package/.docs/reference/vectors/turbopuffer.md +29 -29
  217. package/.docs/reference/vectors/upstash.md +25 -25
  218. package/.docs/reference/vectors/vectorize.md +27 -27
  219. package/.docs/reference/voice/azure.md +19 -15
  220. package/.docs/reference/voice/cloudflare.md +10 -12
  221. package/.docs/reference/voice/composite-voice.md +10 -10
  222. package/.docs/reference/voice/deepgram.md +20 -14
  223. package/.docs/reference/voice/elevenlabs.md +20 -22
  224. package/.docs/reference/voice/google-gemini-live.md +42 -44
  225. package/.docs/reference/voice/google.md +25 -21
  226. package/.docs/reference/voice/mastra-voice.md +20 -20
  227. package/.docs/reference/voice/murf.md +24 -28
  228. package/.docs/reference/voice/openai-realtime.md +26 -26
  229. package/.docs/reference/voice/openai.md +14 -12
  230. package/.docs/reference/voice/playai.md +13 -15
  231. package/.docs/reference/voice/sarvam.md +21 -25
  232. package/.docs/reference/voice/speechify.md +11 -13
  233. package/.docs/reference/voice/voice.addInstructions.md +1 -1
  234. package/.docs/reference/voice/voice.addTools.md +1 -1
  235. package/.docs/reference/voice/voice.answer.md +1 -1
  236. package/.docs/reference/voice/voice.connect.md +3 -3
  237. package/.docs/reference/voice/voice.events.md +11 -11
  238. package/.docs/reference/voice/voice.getSpeakers.md +30 -30
  239. package/.docs/reference/voice/voice.listen.md +9 -9
  240. package/.docs/reference/voice/voice.off.md +2 -2
  241. package/.docs/reference/voice/voice.on.md +2 -2
  242. package/.docs/reference/voice/voice.send.md +1 -1
  243. package/.docs/reference/voice/voice.speak.md +11 -11
  244. package/.docs/reference/voice/voice.updateConfig.md +3 -3
  245. package/.docs/reference/workflows/run-methods/cancel.md +2 -2
  246. package/.docs/reference/workflows/run-methods/restart.md +17 -5
  247. package/.docs/reference/workflows/run-methods/resume.md +23 -9
  248. package/.docs/reference/workflows/run-methods/start.md +22 -8
  249. package/.docs/reference/workflows/run-methods/startAsync.md +12 -6
  250. package/.docs/reference/workflows/run-methods/timeTravel.md +29 -13
  251. package/.docs/reference/workflows/run.md +12 -12
  252. package/.docs/reference/workflows/step.md +24 -26
  253. package/.docs/reference/workflows/workflow-methods/branch.md +2 -2
  254. package/.docs/reference/workflows/workflow-methods/commit.md +1 -1
  255. package/.docs/reference/workflows/workflow-methods/create-run.md +4 -4
  256. package/.docs/reference/workflows/workflow-methods/dountil.md +3 -3
  257. package/.docs/reference/workflows/workflow-methods/dowhile.md +3 -3
  258. package/.docs/reference/workflows/workflow-methods/foreach.md +9 -9
  259. package/.docs/reference/workflows/workflow-methods/map.md +2 -2
  260. package/.docs/reference/workflows/workflow-methods/parallel.md +2 -2
  261. package/.docs/reference/workflows/workflow-methods/sleep.md +2 -2
  262. package/.docs/reference/workflows/workflow-methods/sleepUntil.md +2 -2
  263. package/.docs/reference/workflows/workflow-methods/then.md +2 -2
  264. package/.docs/reference/workflows/workflow.md +40 -50
  265. package/.docs/reference/workspace/daytona-sandbox.md +33 -33
  266. package/.docs/reference/workspace/e2b-sandbox.md +20 -20
  267. package/.docs/reference/workspace/filesystem.md +22 -22
  268. package/.docs/reference/workspace/gcs-filesystem.md +15 -15
  269. package/.docs/reference/workspace/local-filesystem.md +35 -35
  270. package/.docs/reference/workspace/local-sandbox.md +26 -26
  271. package/.docs/reference/workspace/s3-filesystem.md +18 -18
  272. package/.docs/reference/workspace/sandbox.md +8 -8
  273. package/.docs/reference/workspace/workspace-class.md +30 -34
  274. package/CHANGELOG.md +16 -0
  275. package/package.json +6 -6
  276. package/.docs/docs/getting-started/start.md +0 -28
@@ -1,10 +1,29 @@
1
- # Agent Approval
1
+ # Agent approval
2
2
 
3
- Agents sometimes require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in workflows when calling tools that handle sensitive operations, like deleting resources or performing running long processes. With agent approval you can suspend a tool call and provide feedback to the user, or approve or decline a tool call based on targeted application conditions.
3
+ Agents sometimes require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in workflows when calling tools that handle sensitive operations, like deleting resources or running long processes. With agent approval you can suspend a tool call before it executes so a human can approve or decline it, or let tools suspend themselves to request additional context from the user.
4
4
 
5
- ## Tool call approval
5
+ ## How approval works
6
6
 
7
- Tool call approval can be enabled at the agent level and apply to every tool the agent uses, or at the tool level providing more granular control over individual tool calls.
7
+ Mastra offers two distinct mechanisms for pausing tool calls: **pre-execution approval** and **runtime suspension**.
8
+
9
+ ### Pre-execution approval
10
+
11
+ Pre-execution approval pauses a tool call _before_ its `execute` function runs. The LLM still decides which tool to call and provides arguments, but `execute` doesn't run until you explicitly approve.
12
+
13
+ Two flags control this, combined with OR logic. If _either_ is `true`, the call pauses:
14
+
15
+ | Flag | Where to set it | Scope |
16
+ | --------------------------- | --------------------------------- | ------------------------------------------- |
17
+ | `requireToolApproval: true` | `stream()` / `generate()` options | Pauses **every** tool call for that request |
18
+ | `requireApproval: true` | `createTool()` definition | Pauses calls to **that specific tool** |
19
+
20
+ The stream emits a `tool-call-approval` chunk when a call is paused this way. You then call `approveToolCall()` or `declineToolCall()` to continue.
21
+
22
+ ### Runtime suspension with `suspend()`
23
+
24
+ A tool can also pause _during_ its `execute` function by calling `suspend()`. This is useful when the tool starts running and then discovers it needs additional user input or confirmation before it can finish.
25
+
26
+ The stream emits a `tool-call-suspended` chunk with a custom payload defined by the tool's `suspendSchema`. You resume by calling `resumeStream()` with data matching the tool's `resumeSchema`.
8
27
 
9
28
  ### Storage
10
29
 
@@ -24,7 +43,7 @@ export const mastra = new Mastra({
24
43
 
25
44
  ## Agent-level approval
26
45
 
27
- When calling an agent using `.stream()` set `requireToolApproval` to `true` which will prevent the agent from calling any of the tools defined in its configuration.
46
+ Pass `requireToolApproval: true` to `stream()` or `generate()` to pause every tool call before execution. The LLM still decides which tools to call and with what arguments but no tool runs until you approve or decline.
28
47
 
29
48
  ```typescript
30
49
  const stream = await agent.stream("What's the weather in London?", {
@@ -32,9 +51,20 @@ const stream = await agent.stream("What's the weather in London?", {
32
51
  })
33
52
  ```
34
53
 
54
+ When a tool call is paused, the stream emits a `tool-call-approval` chunk containing the `toolCallId`, `toolName`, and `args`. Use this to inspect the pending call and decide whether to approve or decline:
55
+
56
+ ```typescript
57
+ for await (const chunk of stream.fullStream) {
58
+ if (chunk.type === 'tool-call-approval') {
59
+ console.log('Tool:', chunk.payload.toolName)
60
+ console.log('Args:', chunk.payload.args)
61
+ }
62
+ }
63
+ ```
64
+
35
65
  ### Approving tool calls
36
66
 
37
- To approve a tool call, access `approveToolCall` from the `agent`, passing in the `runId` of the stream. This will let the agent know its now OK to call its tools.
67
+ Call `approveToolCall()` on the agent with the `runId` of the stream to resume the suspended tool call and let it execute:
38
68
 
39
69
  ```typescript
40
70
  const handleApproval = async () => {
@@ -49,7 +79,7 @@ const handleApproval = async () => {
49
79
 
50
80
  ### Declining tool calls
51
81
 
52
- To decline a tool call, access the `declineToolCall` from the `agent`. You will see the streamed response from the agent, but it won't call its tools.
82
+ Call `declineToolCall()` on the agent to skip the tool call. The agent continues without executing the tool and responds accordingly:
53
83
 
54
84
  ```typescript
55
85
  const handleDecline = async () => {
@@ -64,19 +94,19 @@ const handleDecline = async () => {
64
94
 
65
95
  ## Tool approval with generate()
66
96
 
67
- Tool approval also works with the `generate()` method for non-streaming use cases. When using `generate()` with `requireToolApproval: true`, the method returns immediately when a tool requires approval instead of executing it.
97
+ Tool approval also works with the `generate()` method for non-streaming use cases. When a tool requires approval during a `generate()` call, the method returns immediately instead of executing the tool.
68
98
 
69
99
  ### How it works
70
100
 
71
101
  When a tool requires approval during a `generate()` call, the response includes:
72
102
 
73
- - `finishReason: 'suspended'` - indicates the agent is waiting for approval
74
- - `suspendPayload` - contains tool call details (`toolCallId`, `toolName`, `args`)
75
- - `runId` - needed to approve or decline the tool call
103
+ - `finishReason: 'suspended'`: Indicates the agent is waiting for approval
104
+ - `suspendPayload`: Contains tool call details (`toolCallId`, `toolName`, `args`)
105
+ - `runId`: Needed to approve or decline the tool call
76
106
 
77
107
  ### Approving tool calls
78
108
 
79
- To approve a tool call with `generate()`, use the `approveToolCallGenerate` method:
109
+ Use `approveToolCallGenerate()` to approve the tool call and get the final result:
80
110
 
81
111
  ```typescript
82
112
  const output = await agent.generate('Find user John', {
@@ -99,7 +129,7 @@ if (output.finishReason === 'suspended') {
99
129
 
100
130
  ### Declining tool calls
101
131
 
102
- To decline a tool call, use the `declineToolCallGenerate` method:
132
+ Use `declineToolCallGenerate()` to skip the tool call:
103
133
 
104
134
  ```typescript
105
135
  if (output.finishReason === 'suspended') {
@@ -108,12 +138,12 @@ if (output.finishReason === 'suspended') {
108
138
  toolCallId: output.suspendPayload.toolCallId,
109
139
  })
110
140
 
111
- // Agent will respond acknowledging the declined tool
141
+ // Agent responds acknowledging the declined tool
112
142
  console.log(result.text)
113
143
  }
114
144
  ```
115
145
 
116
- ### Stream vs Generate comparison
146
+ ### Stream vs generate comparison
117
147
 
118
148
  | Aspect | `stream()` | `generate()` |
119
149
  | ------------------ | ---------------------------- | ------------------------------------------------ |
@@ -125,11 +155,11 @@ if (output.finishReason === 'suspended') {
125
155
 
126
156
  ## Tool-level approval
127
157
 
128
- There are two types of tool call approval. The first uses `requireApproval`, which is a property on the tool definition, while `requireToolApproval` is a parameter passed to `agent.stream()`. The second uses `suspend` and lets the agent provide context or confirmation prompts so the user can decide whether the tool call should continue.
158
+ Instead of pausing every tool call at the agent level, you can mark individual tools as requiring approval. This gives you granular control only specific tools pause, while others execute immediately.
129
159
 
130
- ### Tool approval using `requireToolApproval`
160
+ ### Approval using `requireApproval`
131
161
 
132
- In this approach, `requireApproval` is configured on the tool definition (shown below) rather than on the agent.
162
+ Set `requireApproval: true` on a tool definition. The tool pauses before execution regardless of whether `requireToolApproval` is set on the agent:
133
163
 
134
164
  ```typescript
135
165
  export const testTool = createTool({
@@ -154,30 +184,30 @@ export const testTool = createTool({
154
184
  })
155
185
  ```
156
186
 
157
- When `requireApproval` is true for a tool, the stream will include chunks of type `tool-call-approval` to indicate that the call is paused. To continue the call, invoke `resumeStream` with the required `resumeSchema` and the `runId`.
187
+ When `requireApproval` is `true`, the stream emits `tool-call-approval` chunks the same way agent-level approval does. Use `approveToolCall()` or `declineToolCall()` to continue:
158
188
 
159
189
  ```typescript
160
190
  const stream = await agent.stream("What's the weather in London?")
161
191
 
162
192
  for await (const chunk of stream.fullStream) {
163
193
  if (chunk.type === 'tool-call-approval') {
164
- console.log('Approval required.')
194
+ console.log('Approval required for:', chunk.payload.toolName)
165
195
  }
166
196
  }
167
197
 
168
- const handleResume = async () => {
169
- const resumedStream = await agent.resumeStream({ approved: true }, { runId: stream.runId })
198
+ const handleApproval = async () => {
199
+ const approvedStream = await agent.approveToolCall({ runId: stream.runId })
170
200
 
171
- for await (const chunk of resumedStream.textStream) {
201
+ for await (const chunk of approvedStream.textStream) {
172
202
  process.stdout.write(chunk)
173
203
  }
174
204
  process.stdout.write('\n')
175
205
  }
176
206
  ```
177
207
 
178
- ### Tool approval using `suspend`
208
+ ### Approval using `suspend`
179
209
 
180
- With this approach, neither the agent nor the tool uses `requireApproval`. Instead, the tool implementation calls `suspend` to pause execution and return context or confirmation prompts to the user.
210
+ With this approach, neither the agent nor the tool uses `requireApproval`. Instead, the tool's `execute` function calls `suspend` to pause at a specific point and return context or confirmation prompts to the user. This is useful when approval depends on runtime conditions rather than being unconditional.
181
211
 
182
212
  ```typescript
183
213
  export const testToolB = createTool({
@@ -210,7 +240,7 @@ export const testToolB = createTool({
210
240
  })
211
241
  ```
212
242
 
213
- With this approach the stream will include a `tool-call-suspended` chunk, and the `suspendPayload` will contain the `reason` defined by the tool's `suspendSchema`. To continue the call, invoke `resumeStream` with the required `resumeSchema` and the `runId`.
243
+ With this approach the stream includes a `tool-call-suspended` chunk, and the `suspendPayload` contains the `reason` defined by the tool's `suspendSchema`. Call `resumeStream` with the `resumeSchema` data and `runId` to continue:
214
244
 
215
245
  ```typescript
216
246
  const stream = await agent.stream("What's the weather in London?")
@@ -349,7 +379,7 @@ User: "San Francisco"
349
379
  Agent: "The weather in San Francisco is: San Francisco: ☀️ +72°F"
350
380
  ```
351
381
 
352
- The second message automatically resumes the suspended tool - the agent extracts `{ city: "San Francisco" }` from the user's message and passes it as `resumeData`.
382
+ The second message automatically resumes the suspended tool, the agent extracts `{ city: "San Francisco" }` from the user's message and passes it as `resumeData`.
353
383
 
354
384
  ### Requirements
355
385
 
@@ -370,7 +400,7 @@ Both approaches work with the same tool definitions. Automatic resumption trigge
370
400
 
371
401
  ## Tool approval: Supervisor pattern
372
402
 
373
- The [supervisor pattern](https://mastra.ai/docs/agents/networks) lets a supervisor agent coordinate multiple subagents using `.stream()` or `.generate()`. The supervisor delegates tasks to subagents, which may use tools that require approval. When this happens, tool approvals properly propagate through the delegation chain -- the approval request surfaces at the supervisor level where you can handle it, regardless of which subagent triggered it.
403
+ The [supervisor pattern](https://mastra.ai/docs/agents/networks) lets a supervisor agent coordinate multiple subagents using `.stream()` or `.generate()`. The supervisor delegates tasks to subagents, which may use tools that require approval. When this happens, tool approvals properly propagate through the delegation chain the approval request surfaces at the supervisor level where you can handle it, regardless of which subagent triggered it.
374
404
 
375
405
  ### How it works
376
406
 
@@ -453,7 +483,7 @@ for await (const chunk of stream.fullStream) {
453
483
 
454
484
  ### Declining tool calls in supervisor pattern
455
485
 
456
- You can also decline tool calls at the supervisor level by calling `declineToolCall`. The supervisor will respond acknowledging the declined tool without executing it:
486
+ Decline tool calls at the supervisor level by calling `declineToolCall`. The supervisor responds acknowledging the declined tool without executing it:
457
487
 
458
488
  ```typescript
459
489
  for await (const chunk of stream.fullStream) {
@@ -466,7 +496,7 @@ for await (const chunk of stream.fullStream) {
466
496
  toolCallId: chunk.payload.toolCallId,
467
497
  })
468
498
 
469
- // The supervisor will respond acknowledging the declined tool
499
+ // The supervisor responds acknowledging the declined tool
470
500
  for await (const declineChunk of declineStream.textStream) {
471
501
  process.stdout.write(declineChunk)
472
502
  }
@@ -476,7 +506,7 @@ for await (const chunk of stream.fullStream) {
476
506
 
477
507
  ### Using suspend() in supervisor pattern
478
508
 
479
- Tools can also use [`suspend()`](#tool-approval-using-suspend) to pause execution and return context to the user. This approach works through the supervisor delegation chain the same way `requireApproval` does -- the suspension surfaces at the supervisor level:
509
+ Tools can also use [`suspend()`](#approval-using-suspend) to pause execution and return context to the user. This approach works through the supervisor delegation chain the same way `requireApproval` does the suspension surfaces at the supervisor level:
480
510
 
481
511
  ```typescript
482
512
  const conditionalTool = createTool({
@@ -192,7 +192,7 @@ const stream = await supervisor.stream('Research AI trends', {
192
192
  })
193
193
  ```
194
194
 
195
- Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to add guidance that's visible to the next iteration.
195
+ Return `{ continue: true }` to keep iterating, or `{ continue: false }` to stop. Include optional `feedback` to inject guidance into the conversation. When `feedback` is combined with `continue: false`, the model may get one final turn to produce a text response incorporating the feedback, but only if the current iteration is still active (e.g., after tool calls) — otherwise no extra turn is granted.
196
196
 
197
197
  ## Memory isolation
198
198
 
@@ -1,6 +1,6 @@
1
1
  # Manual Install
2
2
 
3
- > **Info:** Use this guide to manually build a standalone Mastra server step by step. In most cases, it's quicker to follow a [getting-started guide](https://mastra.ai/docs/getting-started/start), which achieves the same result using the [`mastra create`](https://mastra.ai/reference/cli/create-mastra) command. For existing projects, you can also use [`mastra init`](https://mastra.ai/reference/cli/mastra).
3
+ > **Info:** Use this guide to manually build a standalone Mastra server step by step. In most cases, it's quicker to follow the [quickstart guide](https://mastra.ai/guides/getting-started/quickstart), which achieves the same result using the [`mastra create`](https://mastra.ai/reference/cli/create-mastra) command. For existing projects, you can also use [`mastra init`](https://mastra.ai/reference/cli/mastra).
4
4
 
5
5
  If you prefer not to use our automatic CLI tool, you can set up your project yourself by following the guide below.
6
6
 
@@ -1,43 +1,87 @@
1
- # About Mastra
1
+ # Get Started
2
2
 
3
- Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
3
+ Mastra is a TypeScript framework for building AI agents, workflows, and tools. Create your first project in seconds and start building.
4
4
 
5
- It includes everything you need to go from early prototypes to production-ready applications. Mastra integrates with frontend and backend frameworks like React, Next.js, and Node, or you can deploy it anywhere as a standalone server. It's the easiest way to build, tune, and scale reliable AI products.
5
+ ## Quickstart
6
6
 
7
- [YouTube video player](https://www.youtube-nocookie.com/embed/1qnmnRICX50)
7
+ Run the command below to create a new Mastra project with an example agent:
8
8
 
9
- ## Why Mastra?
9
+ **npm**:
10
10
 
11
- Purpose-built for TypeScript and designed around established AI patterns, Mastra gives you everything you need to build great AI applications out-of-the-box.
11
+ ```bash
12
+ npm create mastra@latest
13
+ ```
12
14
 
13
- Some highlights include:
15
+ **pnpm**:
14
16
 
15
- - [**Model routing**](https://mastra.ai/models): Connect to 40+ providers through one standard interface. Use models from OpenAI, Anthropic, Gemini, and more.
17
+ ```bash
18
+ pnpm create mastra
19
+ ```
16
20
 
17
- - [**Agents**](https://mastra.ai/docs/agents/overview): Build autonomous agents that use LLMs and tools to solve open-ended tasks. Agents reason about goals, decide which tools to use, and iterate internally until the model emits a final answer or an optional stopping condition is met.
21
+ **Yarn**:
18
22
 
19
- - [**Workflows**](https://mastra.ai/docs/workflows/overview): When you need explicit control over execution, use Mastra's graph-based workflow engine to orchestrate complex multi-step processes. Mastra workflows use an intuitive syntax for control flow (`.then()`, `.branch()`, `.parallel()`).
23
+ ```bash
24
+ yarn create mastra
25
+ ```
20
26
 
21
- - [**Human-in-the-loop**](https://mastra.ai/docs/workflows/suspend-and-resume): Suspend an agent or workflow and await user input or approval before resuming. Mastra uses storage to remember execution state, so you can pause indefinitely and resume where you left off.
27
+ **Bun**:
22
28
 
23
- - **Context management**: Give your agents the right context at the right time. Provide [message history](https://mastra.ai/docs/memory/message-history), [retrieve](https://mastra.ai/docs/rag/overview) data from your sources (APIs, databases, files), and add human-like [working](https://mastra.ai/docs/memory/working-memory) and [semantic](https://mastra.ai/docs/memory/semantic-recall) memory so your agents behave coherently.
29
+ ```bash
30
+ bunx create-mastra
31
+ ```
24
32
 
25
- - **Integrations**: Bundle agents and workflows into existing React, Next.js, or Node.js apps, or ship them as standalone endpoints. When building UIs, integrate with agentic libraries like Vercel's AI SDK UI and CopilotKit to bring your AI assistant to life on the web.
33
+ This sets up a project you can test immediately in [Studio](https://mastra.ai/docs/getting-started/studio). See the [quickstart guide](https://mastra.ai/guides/getting-started/quickstart) for a full walkthrough.
26
34
 
27
- - **Production essentials**: Shipping reliable agents takes ongoing insight, evaluation, and iteration. With built-in [scorers](https://mastra.ai/docs/evals/overview) and [observability](https://mastra.ai/docs/observability/overview), Mastra gives you the tools to observe, measure, and refine continuously.
35
+ ## Integrate with your framework
28
36
 
29
- ## What can you build?
37
+ Add Mastra to an existing project or create a new app with your preferred framework.
30
38
 
31
- - AI-powered applications that combine language understanding, reasoning, and action to solve real-world tasks.
32
- - Conversational agents for customer support, onboarding, or internal queries.
33
- - Domain-specific copilots for coding, legal, finance, research, or creative work.
34
- - Workflow automations that trigger, route, and complete multi-step processes.
35
- - Decision-support tools that analyse data and provide actionable recommendations.
39
+ - [Next.js](https://mastra.ai/guides/getting-started/next-js)
40
+ - [React](https://mastra.ai/guides/getting-started/vite-react)
41
+ - [Astro](https://mastra.ai/guides/getting-started/astro)
42
+ - [Express](https://mastra.ai/guides/getting-started/express)
43
+ - [SvelteKit](https://mastra.ai/guides/getting-started/sveltekit)
44
+ - [Hono](https://mastra.ai/guides/getting-started/hono)
36
45
 
37
- ## Get started
46
+ For other frameworks, see the [framework integration guides](https://mastra.ai/guides/getting-started/next-js).
38
47
 
39
- Choose a [getting started guide](https://mastra.ai/docs/getting-started/start) to get started, or see the [manual installation guide](https://mastra.ai/docs/getting-started/manual-install) if you need more control over your setup.
48
+ ## What you can do
40
49
 
41
- If you're new to AI agents, check out our [templates](https://mastra.ai/templates), [course](https://mastra.ai/course), and [YouTube videos](https://youtube.com/@mastra-ai). You can also join our [Discord](https://discord.gg/BTYqqHKUrf) community to get help and share your projects.
50
+ <details>
51
+ **Conversational agents**
42
52
 
43
- We can't wait to see what you build ✌️
53
+ Customer support, onboarding, or internal query bots. Agents maintain context across sessions with thread-based message history and observational memory — background agents that compress conversation history into dense observation logs, keeping the context window small while preserving long-term recall. Stream responses token-by-token for responsive chat UIs. Attach tools so agents can look up orders, create tickets, or call APIs mid-conversation.
54
+
55
+ </details>
56
+
57
+ <details>
58
+ **Domain-specific copilots**
59
+
60
+ Assistants for coding, legal, finance, research, or creative work. Ground agents in your own data with a full RAG pipeline — chunking, embedding, vector storage across 12+ providers, metadata filtering, and re-ranking. Customize behavior with dynamic instructions that adapt per user or request. Connect to external services through typed tools and MCP servers. Add voice interaction with 12+ speech providers, and measure output quality with built-in evaluation scorers.
61
+
62
+ </details>
63
+
64
+ <details>
65
+ **Workflow automations**
66
+
67
+ Multi-step processes that trigger, route, and complete tasks. Define type-safe steps with Zod-validated inputs and outputs, then compose them with sequential chaining, parallel fan-out, conditional branching, loops, and iteration with concurrency control. Suspend workflows mid-execution to wait for human approval or external events, then resume from where they left off. Nest workflows inside other workflows for reusable sub-pipelines.
68
+
69
+ </details>
70
+
71
+ <details>
72
+ **Decision-support tools**
73
+
74
+ Systems that analyze data and provide actionable recommendations. Compose multiple tools so agents can query databases, call APIs, and run analysis functions in a single interaction. Use structured output with Zod schemas to return validated, typed results. Coordinate specialist agents through supervisor patterns, with task-completion scoring to verify recommendation quality before finalizing. Add human-in-the-loop gates for high-stakes decisions.
75
+
76
+ </details>
77
+
78
+ <details>
79
+ **AI-powered applications**
80
+
81
+ Products that combine language understanding, reasoning, and action. Orchestrate multiple agents with supervisor delegation and multi-agent networks. Deploy to any Node.js runtime, cloud provider, or framework — Vercel, Cloudflare, Next.js, Astro, and more. Monitor production behavior with AI-specific tracing that captures token usage, latency, and decision paths. Choose from 10+ storage providers and configure composite backends optimized per workload. Test everything interactively in Studio before shipping.
82
+
83
+ </details>
84
+
85
+ Browse [templates](https://mastra.ai/templates) from Mastra and the community to see working examples of these use cases.
86
+
87
+ [YouTube video player](https://www.youtube-nocookie.com/embed/1qnmnRICX50)
@@ -5,7 +5,7 @@ Import your Mastra project to [Mastra Cloud](https://cloud.mastra.ai) to use [St
5
5
  ## Before you begin
6
6
 
7
7
  - [Sign in](https://cloud.mastra.ai) to Cloud
8
- - Push your [Mastra project](https://mastra.ai/docs/getting-started/start) to GitHub
8
+ - Push your [Mastra project](https://mastra.ai/docs) to GitHub
9
9
 
10
10
  ## Options
11
11
 
@@ -170,6 +170,15 @@ const memory = new Memory({
170
170
  })
171
171
  ```
172
172
 
173
+ ### Token counting cache
174
+
175
+ OM caches tiktoken part estimates in message metadata to reduce repeat counting work during threshold checks and buffering decisions.
176
+
177
+ - Per-part estimates are stored on `part.providerMetadata.mastra` and reused on subsequent passes when the cache version/tokenizer source matches.
178
+ - For string-only message content (without parts), OM uses a message-level metadata fallback cache.
179
+ - Message and conversation overhead are still recalculated on every pass. The cache only stores payload estimates, so counting semantics stay the same.
180
+ - `data-*` and `reasoning` parts are still skipped and are not cached.
181
+
173
182
  ## Async Buffering
174
183
 
175
184
  Without async buffering, the Observer runs synchronously when the message threshold is reached — the agent pauses mid-conversation while the Observer LLM call completes. With async buffering (enabled by default), observations are pre-computed in the background as the conversation grows. When the threshold is hit, buffered observations activate instantly with no pause.
@@ -147,8 +147,24 @@ Supported embedding models:
147
147
 
148
148
  - **OpenAI**: `text-embedding-3-small`, `text-embedding-3-large`, `text-embedding-ada-002`
149
149
  - **Google**: `gemini-embedding-001`
150
+ - **OpenRouter**: Access embedding models from various providers
150
151
 
151
- The model router automatically handles API key detection from environment variables (`OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`).
152
+ ```ts
153
+ import { Agent } from '@mastra/core/agent'
154
+ import { Memory } from '@mastra/memory'
155
+ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
156
+
157
+ const agent = new Agent({
158
+ memory: new Memory({
159
+ embedder: new ModelRouterEmbeddingModel({
160
+ providerId: 'openrouter',
161
+ modelId: 'openai/text-embedding-3-small',
162
+ }),
163
+ }),
164
+ })
165
+ ```
166
+
167
+ The model router automatically handles API key detection from environment variables (`OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `OPENROUTER_API_KEY`).
152
168
 
153
169
  ### Using AI SDK Packages
154
170
 
@@ -117,13 +117,15 @@ const workspace = new Workspace({
117
117
 
118
118
  ## How agents use skills
119
119
 
120
- When an agent activates a skill, the skill's instructions are added to the conversation context. The agent can then follow those instructions and access the skill's references and scripts.
120
+ When a workspace has skills configured, agents automatically get access to skill tools. Available skills are listed in the system message so the agent knows what's available, and the agent can load any skill on demand.
121
121
 
122
- Under the hood this involves:
122
+ The agent has three skill tools:
123
123
 
124
- 1. Lists available skills in the system message
125
- 2. Allows agents to activate skills during conversation
126
- 3. Provides access to skill references and scripts
124
+ - **`skill`** Loads a skill's full instructions and returns them in the tool result. The agent calls this whenever it needs a skill's guidance.
125
+ - **`skill_read`** Reads a file from a skill's `references/`, `scripts/`, or `assets/` directory.
126
+ - **`skill_search`** — Searches across all skill content. Uses BM25 or vector search when configured, otherwise falls back to simple text matching.
127
+
128
+ This design is stateless — there is no activation state to track. If the skill instructions leave the conversation context (due to context window limits or compaction), the agent can call `skill` again to reload them.
127
129
 
128
130
  ## Skill search
129
131