@mastra/mcp-docs-server 1.3.9-alpha.9 → 1.3.10-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 (425) hide show
  1. package/.docs/docs/agents/code-mode.md +2 -2
  2. package/.docs/docs/agents/guardrails.md +5 -2
  3. package/.docs/docs/agents/human-in-the-loop.md +18 -5
  4. package/.docs/docs/agents/networks.md +1 -1
  5. package/.docs/docs/agents/overview.md +8 -7
  6. package/.docs/docs/agents/processors.md +72 -21
  7. package/.docs/docs/agents/structured-output.md +6 -6
  8. package/.docs/docs/agents/tools.md +10 -10
  9. package/.docs/docs/auth/composite-auth.md +4 -2
  10. package/.docs/docs/auth/custom-auth-provider.md +1 -1
  11. package/.docs/docs/auth/overview.md +3 -1
  12. package/.docs/docs/browser.md +13 -1
  13. package/.docs/docs/channels.md +33 -6
  14. package/.docs/docs/connections/a2a.md +1 -1
  15. package/.docs/docs/connections/acp.md +2 -2
  16. package/.docs/docs/connections/mcp.md +159 -50
  17. package/.docs/docs/connections/overview.md +1 -1
  18. package/.docs/docs/connections/sdk-agents.md +26 -15
  19. package/.docs/docs/develop.md +1 -1
  20. package/.docs/docs/evals/custom-scorers.md +5 -5
  21. package/.docs/docs/evals/experiments.md +29 -4
  22. package/.docs/docs/evals/multi-turn.md +2 -2
  23. package/.docs/docs/evals/overview.md +4 -4
  24. package/.docs/docs/evals/quick-checks.md +2 -2
  25. package/.docs/docs/guides/build-an-eval-loop.md +3 -3
  26. package/.docs/docs/guides/context-engineering.md +13 -6
  27. package/.docs/docs/guides/mcp-authentication-authorization.md +4 -4
  28. package/.docs/docs/guides/streaming.md +1 -1
  29. package/.docs/docs/harness/agent-controller.md +18 -21
  30. package/.docs/docs/harness/background-tasks.md +14 -3
  31. package/.docs/docs/harness/durable-agents.md +15 -9
  32. package/.docs/docs/harness/goals.md +5 -5
  33. package/.docs/docs/harness/overview.md +2 -2
  34. package/.docs/docs/harness/schedules.md +13 -11
  35. package/.docs/docs/index.md +7 -6
  36. package/.docs/docs/mastra-platform/connect/channels.md +1 -1
  37. package/.docs/docs/mastra-platform/connect/tools.md +4 -4
  38. package/.docs/docs/mastra-platform/environments.md +1 -1
  39. package/.docs/docs/mastra-platform/observability.md +1 -1
  40. package/.docs/docs/mastra-platform/server.md +1 -1
  41. package/.docs/docs/mastra-platform/studio.md +1 -1
  42. package/.docs/docs/memory/memory-processors.md +21 -15
  43. package/.docs/docs/memory/message-history.md +5 -5
  44. package/.docs/docs/memory/multi-user-threads.md +1 -1
  45. package/.docs/docs/memory/observational-memory.md +14 -14
  46. package/.docs/docs/memory/semantic-recall.md +22 -2
  47. package/.docs/docs/memory/working-memory.md +3 -3
  48. package/.docs/docs/observability/logging.md +5 -5
  49. package/.docs/docs/observability/tracing/overview.md +1 -0
  50. package/.docs/docs/sandbox/filesystem.md +26 -11
  51. package/.docs/docs/sandbox/overview.md +1 -1
  52. package/.docs/docs/server/mastra-client.md +1 -1
  53. package/.docs/docs/server/middleware.md +1 -1
  54. package/.docs/docs/server/overview.md +27 -0
  55. package/.docs/docs/server/request-context.md +3 -3
  56. package/.docs/docs/server/server-adapters.md +12 -204
  57. package/.docs/docs/signals/notifications.md +233 -0
  58. package/.docs/docs/signals/overview.md +94 -0
  59. package/.docs/docs/signals/running-across-processes.md +132 -0
  60. package/.docs/docs/signals/sending-signals.md +166 -0
  61. package/.docs/docs/signals/signal-providers.md +278 -0
  62. package/.docs/docs/signals/state-signals.md +103 -0
  63. package/.docs/docs/signals/thread-streams.md +94 -0
  64. package/.docs/docs/skills.md +4 -4
  65. package/.docs/docs/storage.md +1 -1
  66. package/.docs/docs/studio/auth.md +2 -2
  67. package/.docs/docs/studio/editor.md +39 -23
  68. package/.docs/docs/studio/observability.md +5 -1
  69. package/.docs/docs/subagents.md +6 -6
  70. package/.docs/docs/workflows/control-flow.md +14 -14
  71. package/.docs/docs/workflows/error-handling.md +1 -1
  72. package/.docs/integrations/agentic-ui/ai-sdk-ui.md +1 -1
  73. package/.docs/integrations/agentic-ui/copilotkit.md +1 -1
  74. package/.docs/integrations/agentic-ui/openui.md +1 -1
  75. package/.docs/integrations/browsers/agent-browser.md +1 -1
  76. package/.docs/integrations/browsers/browser-viewer.md +1 -1
  77. package/.docs/integrations/browsers/firecrawl.md +1 -1
  78. package/.docs/integrations/browsers/stagehand.md +6 -6
  79. package/.docs/integrations/channels/discord.md +1 -1
  80. package/.docs/integrations/channels/github.md +2 -2
  81. package/.docs/integrations/channels/imessage.md +2 -50
  82. package/.docs/integrations/channels/slack.md +1 -1
  83. package/.docs/integrations/channels/teams.md +1 -1
  84. package/.docs/integrations/channels/telegram.md +1 -1
  85. package/.docs/integrations/channels/whatsapp.md +1 -1
  86. package/.docs/integrations/databases/aurora-dsql.md +1 -1
  87. package/.docs/integrations/databases/cloudflare-kv.md +4 -0
  88. package/.docs/integrations/databases/elasticsearch.md +1 -1
  89. package/.docs/integrations/databases/mongodb.md +1 -1
  90. package/.docs/integrations/databases/oracledb.md +1 -1
  91. package/.docs/integrations/databases/postgresql.md +1 -1
  92. package/.docs/integrations/databases/redis.md +1 -1
  93. package/.docs/integrations/databases/upstash.md +1 -1
  94. package/.docs/integrations/deploy/aws-bedrock-agentcore.md +1 -0
  95. package/.docs/integrations/deploy/kubernetes.md +1 -1
  96. package/.docs/integrations/deploy/neon.md +2 -1
  97. package/.docs/integrations/deploy/render.md +2 -2
  98. package/.docs/integrations/file-storage/agentfs.md +1 -1
  99. package/.docs/integrations/file-storage/amazon-s3.md +20 -3
  100. package/.docs/integrations/file-storage/archil.md +1 -1
  101. package/.docs/integrations/file-storage/azure-blob.md +1 -1
  102. package/.docs/integrations/file-storage/google-cloud-storage.md +1 -1
  103. package/.docs/integrations/file-storage/google-drive.md +1 -1
  104. package/.docs/integrations/file-storage/mesa.md +1 -1
  105. package/.docs/integrations/file-storage/neon.md +210 -0
  106. package/.docs/integrations/file-storage/vercel-files.md +5 -1
  107. package/.docs/integrations/frameworks/express.md +0 -64
  108. package/.docs/integrations/observability/langfuse.md +1 -1
  109. package/.docs/integrations/observability/langsmith.md +2 -2
  110. package/.docs/integrations/observability/opentelemetry.md +5 -5
  111. package/.docs/integrations/sandboxes/apple-container.md +1 -1
  112. package/.docs/integrations/sandboxes/blaxel.md +1 -1
  113. package/.docs/integrations/sandboxes/daytona.md +1 -1
  114. package/.docs/integrations/sandboxes/docker.md +1 -1
  115. package/.docs/integrations/sandboxes/e2b-desktop.md +1 -1
  116. package/.docs/integrations/sandboxes/e2b.md +6 -2
  117. package/.docs/integrations/sandboxes/modal.md +1 -1
  118. package/.docs/integrations/sandboxes/railway.md +1 -1
  119. package/.docs/integrations/sandboxes/sprites.md +1 -1
  120. package/.docs/integrations/sandboxes/vercel.md +2 -2
  121. package/.docs/integrations/tools/brightdata.md +1 -1
  122. package/.docs/integrations/tools/firecrawl.md +1 -1
  123. package/.docs/integrations/tools/parallel.md +1 -1
  124. package/.docs/integrations/tools/perplexity.md +1 -1
  125. package/.docs/integrations/tools/tavily.md +1 -1
  126. package/.docs/integrations/voice/livekit.md +2 -2
  127. package/.docs/integrations.md +1 -0
  128. package/.docs/models/embeddings.md +2 -1
  129. package/.docs/models/environment-variables.md +1 -3
  130. package/.docs/models/gateways/custom-gateways.md +3 -3
  131. package/.docs/models/gateways/merge-gateway.md +7 -13
  132. package/.docs/models/gateways/netlify.md +2 -1
  133. package/.docs/models/gateways/openrouter.md +3 -2
  134. package/.docs/models/gateways/vercel.md +8 -5
  135. package/.docs/models/index.md +14 -16
  136. package/.docs/models/providers/302ai.md +3 -3
  137. package/.docs/models/providers/abacus.md +70 -110
  138. package/.docs/models/providers/aimlapi.md +171 -171
  139. package/.docs/models/providers/aixy.md +3 -1
  140. package/.docs/models/providers/aki-io.md +5 -6
  141. package/.docs/models/providers/alibaba-cn.md +9 -57
  142. package/.docs/models/providers/alibaba-coding-plan-cn.md +8 -12
  143. package/.docs/models/providers/alibaba-coding-plan.md +8 -12
  144. package/.docs/models/providers/alibaba-token-plan-cn.md +0 -2
  145. package/.docs/models/providers/alibaba-token-plan.md +29 -30
  146. package/.docs/models/providers/alibaba.md +33 -62
  147. package/.docs/models/providers/ambient.md +1 -9
  148. package/.docs/models/providers/amd.md +13 -9
  149. package/.docs/models/providers/anthropic.md +4 -2
  150. package/.docs/models/providers/arcee.md +6 -4
  151. package/.docs/models/providers/auriko.md +2 -2
  152. package/.docs/models/providers/baseten.md +4 -14
  153. package/.docs/models/providers/berget.md +3 -4
  154. package/.docs/models/providers/bothub.md +4 -4
  155. package/.docs/models/providers/boundless.md +0 -4
  156. package/.docs/models/providers/cline-pass.md +2 -8
  157. package/.docs/models/providers/cloudflare-workers-ai.md +1 -1
  158. package/.docs/models/providers/commandcode.md +0 -1
  159. package/.docs/models/providers/coralbricks.md +1 -1
  160. package/.docs/models/providers/cortecs.md +1 -1
  161. package/.docs/models/providers/crossmodel.md +69 -73
  162. package/.docs/models/providers/crusoe.md +1 -7
  163. package/.docs/models/providers/daoxe.md +1 -1
  164. package/.docs/models/providers/databricks.md +5 -10
  165. package/.docs/models/providers/deepinfra.md +2 -2
  166. package/.docs/models/providers/digitalocean.md +8 -24
  167. package/.docs/models/providers/dinference.md +0 -3
  168. package/.docs/models/providers/edenai.md +29 -5
  169. package/.docs/models/providers/empiriolabs.md +1 -8
  170. package/.docs/models/providers/engy.md +2 -2
  171. package/.docs/models/providers/evroc.md +2 -2
  172. package/.docs/models/providers/fastrouter.md +41 -50
  173. package/.docs/models/providers/fireworks-ai.md +6 -5
  174. package/.docs/models/providers/friendli.md +4 -5
  175. package/.docs/models/providers/frogbot.md +2 -7
  176. package/.docs/models/providers/google.md +5 -5
  177. package/.docs/models/providers/greenpt.md +14 -20
  178. package/.docs/models/providers/groq.md +3 -8
  179. package/.docs/models/providers/huggingface.md +5 -6
  180. package/.docs/models/providers/iflowcn.md +2 -18
  181. package/.docs/models/providers/impossibl.md +2 -9
  182. package/.docs/models/providers/inception.md +3 -2
  183. package/.docs/models/providers/inceptron.md +8 -6
  184. package/.docs/models/providers/inco.md +1 -1
  185. package/.docs/models/providers/inference.md +5 -11
  186. package/.docs/models/providers/infomaniak.md +10 -12
  187. package/.docs/models/providers/io-net.md +11 -17
  188. package/.docs/models/providers/iteracompute.md +5 -5
  189. package/.docs/models/providers/jalapeno.md +14 -19
  190. package/.docs/models/providers/jiekou.md +53 -63
  191. package/.docs/models/providers/kenari.md +35 -54
  192. package/.docs/models/providers/kilo.md +19 -33
  193. package/.docs/models/providers/lilac.md +2 -8
  194. package/.docs/models/providers/liquid.md +77 -0
  195. package/.docs/models/providers/llama.md +2 -11
  196. package/.docs/models/providers/llmgateway-providers.md +10 -27
  197. package/.docs/models/providers/llmgateway.md +12 -21
  198. package/.docs/models/providers/llmtr.md +1 -6
  199. package/.docs/models/providers/longcat.md +6 -5
  200. package/.docs/models/providers/lowrouter.md +1 -1
  201. package/.docs/models/providers/lucidquery.md +2 -2
  202. package/.docs/models/providers/meganova.md +6 -7
  203. package/.docs/models/providers/melious.md +11 -15
  204. package/.docs/models/providers/minimax-cn-coding-plan.md +4 -11
  205. package/.docs/models/providers/minimax-cn.md +4 -10
  206. package/.docs/models/providers/minimax-coding-plan.md +4 -11
  207. package/.docs/models/providers/minimax.md +4 -10
  208. package/.docs/models/providers/mistral.md +7 -6
  209. package/.docs/models/providers/moark.md +0 -2
  210. package/.docs/models/providers/modal.md +11 -7
  211. package/.docs/models/providers/moonshotai-cn.md +2 -2
  212. package/.docs/models/providers/nan.md +1 -1
  213. package/.docs/models/providers/nano-gpt.md +28 -31
  214. package/.docs/models/providers/nearai.md +3 -2
  215. package/.docs/models/providers/neuralwatt.md +1 -4
  216. package/.docs/models/providers/novita-ai.md +2 -1
  217. package/.docs/models/providers/nvidia.md +15 -35
  218. package/.docs/models/providers/oci.md +0 -1
  219. package/.docs/models/providers/ofox.md +149 -157
  220. package/.docs/models/providers/ollama-cloud.md +7 -12
  221. package/.docs/models/providers/openai.md +4 -2
  222. package/.docs/models/providers/opencode-go.md +2 -3
  223. package/.docs/models/providers/opencode.md +85 -87
  224. package/.docs/models/providers/opper.md +1 -4
  225. package/.docs/models/providers/orcarouter.md +14 -16
  226. package/.docs/models/providers/pareto.md +1 -1
  227. package/.docs/models/providers/perplexity-agent.md +43 -29
  228. package/.docs/models/providers/perplexity.md +2 -8
  229. package/.docs/models/providers/pioneer.md +13 -118
  230. package/.docs/models/providers/poe.md +16 -70
  231. package/.docs/models/providers/prime.md +2 -1
  232. package/.docs/models/providers/qihang-ai.md +7 -11
  233. package/.docs/models/providers/qiniu-ai.md +9 -94
  234. package/.docs/models/providers/regolo-ai.md +5 -7
  235. package/.docs/models/providers/requesty.md +0 -4
  236. package/.docs/models/providers/runinfra.md +3 -5
  237. package/.docs/models/providers/sarvam.md +1 -2
  238. package/.docs/models/providers/scaleway.md +12 -13
  239. package/.docs/models/providers/siliconflow-cn.md +35 -41
  240. package/.docs/models/providers/siliconflow.md +3 -6
  241. package/.docs/models/providers/snowflake-cortex.md +22 -22
  242. package/.docs/models/providers/stackit.md +2 -4
  243. package/.docs/models/providers/stepfun-ai.md +5 -7
  244. package/.docs/models/providers/stepfun.md +8 -10
  245. package/.docs/models/providers/submodel.md +1 -1
  246. package/.docs/models/providers/synthetic.md +2 -5
  247. package/.docs/models/providers/tempr.md +1 -4
  248. package/.docs/models/providers/tencent-coding-plan.md +3 -10
  249. package/.docs/models/providers/tensorx.md +0 -13
  250. package/.docs/models/providers/the-grid-ai.md +2 -1
  251. package/.docs/models/providers/thinkingmachines.md +45 -9
  252. package/.docs/models/providers/togetherai.md +17 -23
  253. package/.docs/models/providers/tokengo.md +1 -1
  254. package/.docs/models/providers/umans-ai-coding-plan.md +12 -11
  255. package/.docs/models/providers/umans-ai.md +11 -10
  256. package/.docs/models/providers/unorouter.md +0 -13
  257. package/.docs/models/providers/vancine.md +0 -1
  258. package/.docs/models/providers/vivgrid.md +3 -3
  259. package/.docs/models/providers/volcengine-coding-plan.md +8 -12
  260. package/.docs/models/providers/volcengine.md +12 -18
  261. package/.docs/models/providers/vultr.md +0 -2
  262. package/.docs/models/providers/wafer.ai.md +3 -7
  263. package/.docs/models/providers/wandb.md +1 -1
  264. package/.docs/models/providers/xai.md +21 -4
  265. package/.docs/models/providers/xiaomi-token-plan-ams.md +4 -5
  266. package/.docs/models/providers/xiaomi-token-plan-cn.md +4 -5
  267. package/.docs/models/providers/xiaomi-token-plan-sgp.md +4 -5
  268. package/.docs/models/providers/xiaomi.md +4 -4
  269. package/.docs/models/providers/xpersona.md +0 -1
  270. package/.docs/models/providers/zai-coding-plan.md +0 -4
  271. package/.docs/models/providers/zenmux.md +105 -125
  272. package/.docs/models/providers/zhipuai-coding-plan.md +0 -1
  273. package/.docs/models/providers/zhipuai.md +12 -12
  274. package/.docs/models/providers.md +1 -3
  275. package/.docs/reference/acp/acp-agent.md +4 -4
  276. package/.docs/reference/acp/create-acp-tool.md +1 -1
  277. package/.docs/reference/agent-controller/agent-controller-class.md +18 -23
  278. package/.docs/reference/agent-controller/session.md +8 -8
  279. package/.docs/reference/agents/agent.md +22 -46
  280. package/.docs/reference/agents/channels.md +17 -9
  281. package/.docs/reference/agents/durable-agent.md +14 -10
  282. package/.docs/reference/agents/generate.md +57 -3
  283. package/.docs/reference/agents/generateLegacy.md +2 -2
  284. package/.docs/reference/agents/getLLM.md +2 -2
  285. package/.docs/reference/agents/getMetadata.md +2 -2
  286. package/.docs/reference/agents/getSkill.md +1 -1
  287. package/.docs/reference/agents/inngest-agent.md +1 -1
  288. package/.docs/reference/agents/listSkills.md +1 -4
  289. package/.docs/reference/agents/network.md +1 -1
  290. package/.docs/reference/browser/agent-browser.md +1 -1
  291. package/.docs/reference/browser/browser-viewer.md +1 -1
  292. package/.docs/reference/browser/firecrawl-browser.md +1 -1
  293. package/.docs/reference/browser/mastra-browser.md +2 -2
  294. package/.docs/reference/browser/stagehand-browser.md +4 -4
  295. package/.docs/reference/channels/slack-provider.md +3 -0
  296. package/.docs/reference/cli/mastra.md +26 -0
  297. package/.docs/reference/client-js/agent-controller.md +14 -4
  298. package/.docs/reference/client-js/agents.md +21 -1
  299. package/.docs/reference/client-js/mastra-client.md +1 -1
  300. package/.docs/reference/client-js/observability.md +29 -4
  301. package/.docs/reference/coding-agent/build-base-prompt.md +1 -1
  302. package/.docs/reference/coding-agent/create-coding-agent.md +8 -8
  303. package/.docs/reference/configuration.md +33 -3
  304. package/.docs/reference/connect/tools.md +2 -2
  305. package/.docs/reference/core/getAgentById.md +1 -1
  306. package/.docs/reference/core/mastra-class.md +2 -2
  307. package/.docs/reference/core/mastra-model-gateway.md +34 -5
  308. package/.docs/reference/datasets/delete.md +6 -0
  309. package/.docs/reference/editor/mastra-editor.md +11 -9
  310. package/.docs/reference/editor/tool-provider.md +2 -2
  311. package/.docs/reference/evals/answer-relevancy.md +1 -1
  312. package/.docs/reference/evals/answer-similarity.md +1 -1
  313. package/.docs/reference/evals/bias.md +1 -1
  314. package/.docs/reference/evals/checks.md +1 -1
  315. package/.docs/reference/evals/context-precision.md +3 -3
  316. package/.docs/reference/evals/context-recall.md +3 -3
  317. package/.docs/reference/evals/context-relevance.md +11 -11
  318. package/.docs/reference/evals/create-classifier-scorer.md +6 -2
  319. package/.docs/reference/evals/faithfulness.md +1 -1
  320. package/.docs/reference/evals/hallucination.md +5 -5
  321. package/.docs/reference/evals/multi-turn-judge.md +2 -2
  322. package/.docs/reference/evals/noise-sensitivity.md +12 -12
  323. package/.docs/reference/evals/not-scorable.md +1 -1
  324. package/.docs/reference/evals/prompt-alignment.md +16 -16
  325. package/.docs/reference/evals/rubric.md +5 -5
  326. package/.docs/reference/evals/summarization.md +4 -4
  327. package/.docs/reference/evals/tool-call-accuracy.md +4 -4
  328. package/.docs/reference/evals/toxicity.md +1 -1
  329. package/.docs/reference/file-based-agents/config.md +3 -3
  330. package/.docs/reference/file-based-agents/instructions.md +1 -1
  331. package/.docs/reference/file-based-agents/processors.md +2 -0
  332. package/.docs/reference/file-based-agents/schedules.md +2 -2
  333. package/.docs/reference/file-based-agents/skills.md +1 -1
  334. package/.docs/reference/file-based-agents/subagents.md +5 -5
  335. package/.docs/reference/file-based-agents/workspace.md +1 -1
  336. package/.docs/reference/index.md +2 -0
  337. package/.docs/reference/manual-install.md +3 -2
  338. package/.docs/reference/memory/cloneThread.md +1 -1
  339. package/.docs/reference/memory/copyThread.md +1 -1
  340. package/.docs/reference/memory/deleteMessages.md +4 -1
  341. package/.docs/reference/memory/memory-class.md +5 -3
  342. package/.docs/reference/memory/observational-memory.md +16 -16
  343. package/.docs/reference/memory/serialized-memory-config.md +1 -1
  344. package/.docs/reference/memory/summarizeConversation.md +3 -3
  345. package/.docs/reference/memory/summarizeThread.md +3 -3
  346. package/.docs/reference/migrations/agentnetwork.md +4 -4
  347. package/.docs/reference/migrations/mcp-v2.md +1 -1
  348. package/.docs/reference/migrations/upgrade-to-v1/agent.md +1 -1
  349. package/.docs/reference/migrations/vnext-to-standard-apis.md +2 -2
  350. package/.docs/reference/observability/tracing/advanced-queries.md +131 -41
  351. package/.docs/reference/observability/tracing/exporters/langfuse.md +1 -1
  352. package/.docs/reference/observability/tracing/interfaces.md +2 -0
  353. package/.docs/reference/processors/batch-parts-processor.md +1 -1
  354. package/.docs/reference/processors/classifier-processor.md +2 -2
  355. package/.docs/reference/processors/cyber-refusal-handler.md +1 -1
  356. package/.docs/reference/processors/file-upload-processor.md +1 -1
  357. package/.docs/reference/processors/language-detector.md +1 -1
  358. package/.docs/reference/processors/message-history-processor.md +2 -2
  359. package/.docs/reference/processors/model-selection-processor.md +7 -7
  360. package/.docs/reference/processors/moderation-processor.md +2 -2
  361. package/.docs/reference/processors/pii-detector.md +2 -2
  362. package/.docs/reference/processors/prefill-error-handler.md +2 -2
  363. package/.docs/reference/processors/processor-interface.md +76 -12
  364. package/.docs/reference/processors/prompt-injection-detector.md +1 -1
  365. package/.docs/reference/processors/provider-history-compat.md +1 -1
  366. package/.docs/reference/processors/regex-filter-processor.md +1 -1
  367. package/.docs/reference/processors/response-cache.md +1 -1
  368. package/.docs/reference/processors/semantic-recall-processor.md +2 -2
  369. package/.docs/reference/processors/skill-search-processor.md +1 -1
  370. package/.docs/reference/processors/stream-error-retry-processor.md +3 -3
  371. package/.docs/reference/processors/system-prompt-scrubber.md +1 -1
  372. package/.docs/reference/processors/token-cost-control.md +1 -1
  373. package/.docs/reference/processors/token-limiter-processor.md +3 -3
  374. package/.docs/reference/processors/tool-call-filter.md +2 -2
  375. package/.docs/reference/processors/tool-search-processor.md +3 -3
  376. package/.docs/reference/processors/unicode-normalizer.md +1 -1
  377. package/.docs/reference/processors/working-memory-processor.md +2 -2
  378. package/.docs/reference/pubsub/lease-provider.md +2 -2
  379. package/.docs/reference/pubsub/redis-streams.md +1 -1
  380. package/.docs/reference/rag/chunking-and-embedding.md +1 -1
  381. package/.docs/reference/rag/graph-rag-guide.md +2 -2
  382. package/.docs/reference/rag/metadata-filters.md +1 -1
  383. package/.docs/reference/rag/rerank.md +1 -1
  384. package/.docs/reference/rag/retrieval.md +13 -13
  385. package/.docs/reference/server/nestjs-adapter.md +1 -1
  386. package/.docs/reference/server/routes.md +159 -0
  387. package/.docs/reference/signals/create-notification-inbox-tool.md +4 -4
  388. package/.docs/reference/signals/notifications.md +249 -0
  389. package/.docs/reference/signals/signal-provider.md +2 -0
  390. package/.docs/reference/signals/task-signal-provider.md +3 -3
  391. package/.docs/reference/signals/thread-events.md +69 -0
  392. package/.docs/reference/streaming/ChunkType.md +68 -0
  393. package/.docs/reference/streaming/agents/stream.md +3 -3
  394. package/.docs/reference/tools/create-code-mode.md +1 -1
  395. package/.docs/reference/tools/create-tool.md +17 -0
  396. package/.docs/reference/tools/mcp-client.md +430 -3
  397. package/.docs/reference/tools/mcp-server.md +173 -1
  398. package/.docs/reference/tools/task-tools.md +1 -1
  399. package/.docs/reference/tools/vector-query-tool.md +1 -1
  400. package/.docs/reference/vectors/libsql.md +1 -1
  401. package/.docs/reference/vectors/mongodb.md +2 -2
  402. package/.docs/reference/vectors/oracledb.md +2 -2
  403. package/.docs/reference/vectors/pg.md +1 -1
  404. package/.docs/reference/vectors/upstash.md +1 -1
  405. package/.docs/reference/voice/overview.md +24 -24
  406. package/.docs/reference/voice/speech-to-speech.md +6 -6
  407. package/.docs/reference/voice/speech-to-text.md +1 -1
  408. package/.docs/reference/voice/text-to-speech.md +1 -1
  409. package/.docs/reference/voice/voice.addInstructions.md +1 -1
  410. package/.docs/reference/workflows/workflow-methods/branch.md +1 -1
  411. package/.docs/reference/workspace/filesystem.md +17 -17
  412. package/.docs/reference/workspace/local-filesystem.md +52 -27
  413. package/.docs/reference/workspace/local-sandbox.md +1 -1
  414. package/.docs/reference/workspace/platform-filesystem.md +1 -1
  415. package/.docs/reference/workspace/platform-sandbox.md +23 -2
  416. package/.docs/reference/workspace/process-manager.md +13 -2
  417. package/.docs/reference/workspace/sandbox.md +16 -0
  418. package/.docs/reference/workspace/workspace-class.md +13 -12
  419. package/dist/index.js +1 -2
  420. package/dist/{src-Baf8l9Sp.js → src-DnH_jHt9.js} +2 -3
  421. package/dist/{src-Baf8l9Sp.js.map → src-DnH_jHt9.js.map} +1 -1
  422. package/dist/stdio.js +1 -1
  423. package/package.json +9 -9
  424. package/.docs/docs/harness/signal-providers.md +0 -212
  425. package/.docs/docs/harness/signals.md +0 -546
@@ -47,7 +47,7 @@ export const shopAgent = new Agent({
47
47
  id: 'shop-assistant',
48
48
  name: 'shop-assistant',
49
49
  instructions: ['You are a helpful shopping assistant.', instructions],
50
- model: 'openai/gpt-5.6-sol',
50
+ model: 'openai/gpt-6.1-sol',
51
51
  tools: { execute_typescript: tool },
52
52
  })
53
53
  ```
@@ -35,6 +35,21 @@ export const weatherTool = createTool({
35
35
 
36
36
  The first `execute` parameter is the validated value from `inputSchema`. Destructure schema fields directly in the function signature, as shown with `{ location }`. The optional second parameter contains the execution context.
37
37
 
38
+ ### Display-only tools
39
+
40
+ For a tool that only asks the client to display something, set `renderOnly: true` instead of defining `execute`:
41
+
42
+ ```typescript
43
+ const showCard = createTool({
44
+ id: 'show-card',
45
+ description: 'Display a product card',
46
+ inputSchema: z.object({ productId: z.string() }),
47
+ renderOnly: true,
48
+ })
49
+ ```
50
+
51
+ Mastra streams the tool call and returns `{ acknowledged: true }` as its result, allowing the agent to continue generating text without a client round trip. This also works for tools owned by sub-agents. Their calls appear as nested `tool-output` stream events. Don't set an incompatible `outputSchema` on a render-only tool. The acknowledgement means the call was emitted, **not** that the browser rendered it. Don't use this for client actions whose outcome matters to the agent. For those, omit `execute` and return the result from the client, or use a suspending server tool when a sub-agent needs user input.
52
+
38
53
  ## Parameters
39
54
 
40
55
  **id** (`string`): A unique identifier for the tool.
@@ -47,6 +62,8 @@ The first `execute` parameter is the validated value from `inputSchema`. Destruc
47
62
 
48
63
  **outputSchema** (`StandardJSONSchemaV1`): A Standard JSON Schema defining the expected output structure of the tool's execute function.
49
64
 
65
+ **renderOnly** (`boolean`): When true, streams a display-only tool call and automatically returns { acknowledged: true } to the model so it can continue. Cannot be used with execute. The acknowledgement does not confirm that the client rendered the call.
66
+
50
67
  **strict** (`boolean`): When true, Mastra enables strict tool input generation on model adapters that support it. This helps supported providers return arguments that match the tool schema more closely.
51
68
 
52
69
  **outputValidation** (`'strict' | 'warn'`): How a result that fails outputSchema validation is handled. Both modes log a warning. 'strict' replaces the result with a validation error object. 'warn' returns the tool's actual result unchanged, for tools whose side effects have already happened. (Default: `'strict'`)
@@ -17,7 +17,9 @@ constructor({
17
17
  id?: string;
18
18
  servers: Record<string, MastraMCPServerDefinition>;
19
19
  timeout?: number;
20
+ typegen?: { outFile: string };
20
21
  clientInfo?: { name?: string; version?: string };
22
+ registerProcessHooks?: boolean;
21
23
  }: MCPClientOptions)
22
24
  ```
23
25
 
@@ -29,8 +31,174 @@ constructor({
29
31
 
30
32
  **timeout** (`number`): Global timeout value in milliseconds for all servers unless overridden in individual server configs. (Default: `60000`)
31
33
 
34
+ **typegen** (`{ outFile: string }`): Enables optional CLI generation for this client. outFile must be a nonempty path, resolved from the command working directory. Construction stores readonly metadata and does not generate files.
35
+
32
36
  **clientInfo** (`{ name?: string; version?: string }`): Client name and version every server receives on connect and with each request, so servers can attribute traffic to your application. Defaults to the server key as name and '1.0.0' as version. Individual server configs can override either field with their own clientInfo. Doesn't change tool name prefixes, which always use the server key.
33
37
 
38
+ **registerProcessHooks** (`boolean`): Install process exit and signal hooks that disconnect servers and end the process. Set to false when your application handles shutdown, and call disconnect() from that handler. See Handle shutdown yourself. (Default: `true`)
39
+
40
+ **webhook** (`MCPClientWebhookOptions`): Experimental. Enables webhook delivery for MCP events. Servers POST occurrences to webhook.url, which must route to events.handleWebhook().
41
+
42
+ ### Typed client contracts
43
+
44
+ Pass an explicit server-map type to `MCPClient<TServers>` to check configured server names, discovered tool names, and direct-call arguments. `MCPClientOptions<TServers>` accepts the same map. All declared servers are required. Use `Pick<TServers, 'weather'>` to configure a subset. Without a type argument, discovery keeps its existing broad types.
45
+
46
+ The map describes each server's `tools`, with `input` and `output` types for each tool. This example assumes a running weather server at `WEATHER_MCP_URL`:
47
+
48
+ ```typescript
49
+ import { MCPClient } from '@mastra/mcp'
50
+
51
+ interface MCPServers {
52
+ weather: {
53
+ tools: {
54
+ get_weather: {
55
+ input: { location: string }
56
+ output: { temperature: number; conditions: string }
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ const mcp = new MCPClient<MCPServers>({
63
+ servers: { weather: { url: new URL(process.env.WEATHER_MCP_URL!) } },
64
+ })
65
+
66
+ try {
67
+ const tools = await mcp.listTools()
68
+ const weather = tools.weather_get_weather
69
+ if (weather?.execute) {
70
+ const result = await weather.execute({ location: 'Paris' })
71
+ if (result && 'temperature' in result && typeof result.temperature === 'number') {
72
+ console.log(result.temperature)
73
+ }
74
+ }
75
+ } finally {
76
+ await mcp.disconnect()
77
+ }
78
+ ```
79
+
80
+ `listTools()` and `listToolsWithErrors().tools` expose exact `server_tool` keys. `listToolsets()` and `listToolsetsWithErrors().toolsets` expose server keys containing raw tool names. Both forms are partial: a server or tool can be absent. Check availability before calling a tool. Error maps, error details, and optional discovery durations keep their existing types.
81
+
82
+ Execution can return the structured output, a protocol result envelope, a validation error, or `undefined`. Check the shape and property types before reading success fields. Protocol envelopes can have additional properties. Set `output: unknown` for tools without an output schema.
83
+
84
+ These contracts describe a schema snapshot. Live servers can differ from that snapshot. Update them when server schemas change, using equivalent permissions. Extra live tools remain available at runtime but aren't included in the snapshot's known keys. Runtime discovery, validation, and execution are unchanged.
85
+
86
+ ### Generate client types
87
+
88
+ Generate concrete TypeScript interfaces from live tool input and output schemas with the command included in `@mastra/mcp`. Export your existing client and set `typegen.outFile`:
89
+
90
+ ```typescript
91
+ import { MCPClient } from '@mastra/mcp'
92
+ import type { MCPServers } from './mcp-types.generated'
93
+
94
+ export const mcp = new MCPClient<MCPServers>({
95
+ id: 'weather-client',
96
+ servers: { weather: { url: new URL(process.env.WEATHER_MCP_URL!) } },
97
+ typegen: { outFile: 'src/mcp/mcp-types.generated.ts' },
98
+ })
99
+ ```
100
+
101
+ Set the environment variables and authentication credentials your module needs, then run this command from your project root:
102
+
103
+ **npm**:
104
+
105
+ ```bash
106
+ npx @mastra/mcp generate ./src/mcp/client.ts
107
+ ```
108
+
109
+ **pnpm**:
110
+
111
+ ```bash
112
+ pnpm dlx @mastra/mcp generate ./src/mcp/client.ts
113
+ ```
114
+
115
+ **Yarn**:
116
+
117
+ ```bash
118
+ yarn dlx @mastra/mcp generate ./src/mcp/client.ts
119
+ ```
120
+
121
+ **Bun**:
122
+
123
+ ```bash
124
+ bun x @mastra/mcp generate ./src/mcp/client.ts
125
+ ```
126
+
127
+ The generated type-only import can be missing on the first run. The loader handles TypeScript and transitive imports without typechecking. Run your typecheck after generation.
128
+
129
+ Use the generated names and check runtime availability and result shape. This example assumes the server publishes `get_weather` with a required string `location` and a numeric `temperature` output:
130
+
131
+ ```typescript
132
+ import { mcp } from './client'
133
+
134
+ try {
135
+ const tools = await mcp.listTools()
136
+ const weather = tools.weather_get_weather
137
+ if (weather?.execute) {
138
+ const result = await weather.execute({ location: 'Paris' })
139
+ if (result && 'temperature' in result && typeof result.temperature === 'number') {
140
+ console.log(result.temperature)
141
+ }
142
+ }
143
+ } finally {
144
+ await mcp.disconnect()
145
+ }
146
+ ```
147
+
148
+ The command accepts one or more file paths. Both input files and `outFile` paths are relative to the command's working directory. It selects direct named and default exports of typegen-enabled clients. It doesn't scan your source tree, invoke factories, or inspect nested exported objects. Repeated files, symlink aliases, and exports of the same client are processed once. A file without an eligible client fails.
149
+
150
+ For independent clients with identical server configurations, use distinct IDs and output paths:
151
+
152
+ ```typescript
153
+ import { MCPClient } from '@mastra/mcp'
154
+
155
+ const servers = { weather: { url: new URL(process.env.WEATHER_MCP_URL!) } }
156
+ export const first = new MCPClient({
157
+ id: 'first',
158
+ servers,
159
+ typegen: { outFile: 'first.generated.ts' },
160
+ })
161
+ export const second = new MCPClient({
162
+ id: 'second',
163
+ servers,
164
+ typegen: { outFile: 'second.generated.ts' },
165
+ })
166
+ ```
167
+
168
+ **npm**:
169
+
170
+ ```bash
171
+ npx @mastra/mcp generate ./src/mcp/clients.ts
172
+ ```
173
+
174
+ **pnpm**:
175
+
176
+ ```bash
177
+ pnpm dlx @mastra/mcp generate ./src/mcp/clients.ts
178
+ ```
179
+
180
+ **Yarn**:
181
+
182
+ ```bash
183
+ yarn dlx @mastra/mcp generate ./src/mcp/clients.ts
184
+ ```
185
+
186
+ **Bun**:
187
+
188
+ ```bash
189
+ bun x @mastra/mcp generate ./src/mcp/clients.ts
190
+ ```
191
+
192
+ The existing instance cache still applies. Constructing a client with the same explicit ID, server configuration, and `typegen.outFile` returns the existing object. A different server configuration or `outFile` replaces the cached instance instead, so a later constructor never silently keeps an output file it wasn't given.
193
+
194
+ Generation lists tool definitions without calling tools. It fails on discovery errors, missing authentication, timeouts, output collisions, outputs that overwrite supplied input files, and schemas that can't be represented at all, such as reference cycles, excessive depth, or unresolved local references. Each failure names the client file, server, or tool it concerns. It prepares all sources before replacing files and disconnects selected clients on success or failure. Discovery and preflight failures preserve existing outputs. Each replacement is atomic, but multiple replacements aren't one transaction. A filesystem failure during replacement can leave earlier files updated.
195
+
196
+ Tools without output schemas use `unknown`. Constraints such as string formats, length limits, and numeric bounds retain their base TypeScript types and remain runtime validation rules. Unsupported schema portions, including conditional schemas and `prefixItems` tuples, widen to `unknown` with a warning. A keyword whose value is outside its allowed shape widens that schema to `unknown` with a warning too, so one unusable tool doesn't stop generation for other servers. Warnings name the server, tool, and schema position they concern. External schema references aren't fetched. Unresolved local references and reference cycles fail generation. Schemas nested deeper than 128 levels fail generation too, matching the protocol depth limit. A schema that exceeds the protocol node budget of 10,000 widens to `unknown` with a warning, as does any schema or catalogue that exceeds the larger budgets generation applies to raw JSON values. Generation measures those budgets before it copies or converts a schema, so a server that advertises large schemas can't stall the command.
197
+
198
+ > **Module execution and credentials:** The command executes the supplied modules and their imports. Use trusted modules without application startup side effects. Provide credentials before invoking the command. It doesn't load dotenv files or launch interactive authentication. Existing client timeout and discovery settings apply.
199
+ >
200
+ > Generator diagnostics omit raw schemas, transport errors, and credentials. Logs emitted by your imported application, custom log handlers, or server subprocesses remain outside that guarantee.
201
+
34
202
  ### `MastraMCPServerDefinition`
35
203
 
36
204
  Each server in the `servers` map is configured using the `MastraMCPServerDefinition` type. The transport type is detected based on the provided parameters:
@@ -761,6 +929,240 @@ Notes:
761
929
  - When `enableProgressTracking` is true, tool calls include a `progressToken` so you can correlate updates to a specific run. Servers only send progress for requests that carry a token.
762
930
  - If you pass a `runId` when executing a tool, it will be used as the `progressToken`.
763
931
 
932
+ ### `events` Property (experimental)
933
+
934
+ The `events` property lists and subscribes to server events from servers that implement the [MCP Events extension (SEP-3415)](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/3415). Use it to react to things that happen on the server, such as a push to a repository, without polling a tool. Delivery is at least once. After a reconnect or a resume, the server can resend an occurrence, and the client drops repeats by `eventId` within `dedupWindow` of recent ids.
935
+
936
+ For an end-to-end walkthrough, see [MCP events](https://mastra.ai/docs/connections/mcp).
937
+
938
+ > **Warning:** SEP-3415 is a draft. This API may change in any release.
939
+
940
+ ```typescript
941
+ const events = await mcpClient.events.list('github')
942
+
943
+ const subscription = await mcpClient.events.subscribe(
944
+ 'github',
945
+ 'repo.push',
946
+ { repo: 'mastra-ai/mastra' },
947
+ { cursor: await loadCursor() },
948
+ )
949
+
950
+ for await (const event of subscription) {
951
+ await handlePush(event.data)
952
+ // Safe to persist after each handled occurrence
953
+ await saveCursor(subscription.cursor)
954
+ }
955
+ ```
956
+
957
+ Servers that don't advertise the `io.modelcontextprotocol/events` extension receive no `events/*` requests. `list()` rejects with a `MastraError` whose id is `MCP_CLIENT_LIST_EVENTS_FAILED`, and `subscribe()` rejects with `MCP_CLIENT_SUBSCRIBE_EVENT_FAILED`. In both cases `error.cause.id` is `MCP_EVENTS_NOT_SUPPORTED`. Other `list()` and `subscribe()` failures use the same two ids, with the specific reason in `error.cause`.
958
+
959
+ #### `events.list(serverName: string)`
960
+
961
+ Returns every event type the server offers, following pagination. Each descriptor has a `name`, an optional `description`, the `delivery` modes the server supports, and optional `inputSchema` and `payloadSchema`.
962
+
963
+ ```typescript
964
+ async list(serverName: string): Promise<MCPEventDescriptor[]>
965
+ ```
966
+
967
+ The client doesn't receive notifications when the server's event list changes yet. Call `list()` again to pick up new event types.
968
+
969
+ #### `events.subscribe(serverName, eventName, args?, options?)`
970
+
971
+ Starts a subscription and resolves once the server confirms it. Errors such as an unknown event, invalid arguments, or a forbidden subscription reject the returned promise. A new subscription starts at the point the server accepts it, so occurrences from before that point are not delivered unless `options.cursor` resumes from an earlier position. Under webhook delivery the promise can resolve after that point: the client answers `503` for a delivery it can't route yet, and the server retries it.
972
+
973
+ ```typescript
974
+ async subscribe(
975
+ serverName: string,
976
+ eventName: string,
977
+ args?: Record<string, unknown>,
978
+ options?: MCPEventSubscribeOptions,
979
+ ): Promise<MCPEventSubscription>
980
+ ```
981
+
982
+ The client picks the first mode the event offers in this order: `webhook` (only when the client has [`webhook` settings](#webhook-delivery)), `push` (a long-lived `events/stream` request), then `poll` (repeated `events/poll` requests). Pass `options.delivery` to force a mode.
983
+
984
+ **delivery** (`'webhook' | 'push' | 'poll'`): Forces a delivery mode. When the event doesn't offer it, or for webhook without client webhook settings, subscribe() rejects with MCP\_CLIENT\_SUBSCRIBE\_EVENT\_FAILED and error.cause.id is MCP\_EVENTS\_NO\_COMPATIBLE\_DELIVERY\_MODE or MCP\_EVENTS\_WEBHOOK\_NOT\_CONFIGURED.
985
+
986
+ **cursor** (`string | null`): Resumes from a cursor saved earlier. Omit or pass null to start from now.
987
+
988
+ **maxAgeMs** (`number`): Asks the server not to replay occurrences older than this.
989
+
990
+ **maxEvents** (`number`): Maximum occurrences per poll response. Poll mode only.
991
+
992
+ **minPollIntervalMs** (`number`): Lower bound for the wait between polls, applied to the server-suggested nextPollMs. (Default: `1000`)
993
+
994
+ **heartbeatTimeoutMs** (`number`): Push mode reopens the stream from the last cursor after this long without any message from the server. (Default: `60000`)
995
+
996
+ **streamOpenTimeoutMs** (`number`): How long to wait for the server to confirm a push stream. Defaults to the server request timeout.
997
+
998
+ **dedupWindow** (`number`): Number of recent event ids remembered to drop duplicate occurrences. (Default: `1000`)
999
+
1000
+ **maxBufferedEvents** (`number`): Most occurrences held while your loop isn't reading. When full, the oldest unread occurrence is dropped, the next one has truncated set, and onError receives MCP\_EVENTS\_BUFFER\_OVERFLOW. (Default: `1000`)
1001
+
1002
+ **retry** (`{ initialDelayMs?: number; maxDelayMs?: number; factor?: number; maxAttempts?: number }`): Backoff with full jitter for transient failures. Defaults to 1000 ms initial delay, 30000 ms maximum, factor 2, unlimited retries.
1003
+
1004
+ **signal** (`AbortSignal`): Aborting it cancels the subscription.
1005
+
1006
+ The returned `MCPEventSubscription` is an async iterable of occurrences (`eventId`, `name`, `timestamp`, `data`) with these members:
1007
+
1008
+ - `cursor`: The latest position that's safe to persist. It never moves past an occurrence your loop hasn't received yet. It's `null` when the event type doesn't support replay.
1009
+ - `truncated`: `true` when the server reported a gap right before the occurrence your loop received last, for example because the saved cursor was older than its retention window. Read it inside the loop: it's `true` for the first occurrence after the gap and `false` for the ones after it.
1010
+ - `mode`: The delivery mode in use, `'webhook'`, `'push'`, or `'poll'`.
1011
+ - `deliveryStatus`: Webhook mode only. The server's latest report on delivery to your webhook URL (`active`, `lastDeliveryAt`, `lastError`, `failedSince`), updated on each refresh.
1012
+ - `onError(handler)`: Receives recoverable errors, such as a dropped stream that the client is reopening. Returns a function that removes the handler.
1013
+ - `cancel()`: Stops the subscription and ends the iterator. Breaking out of a `for await` loop also cancels it.
1014
+
1015
+ The iterator throws a `MastraError` directly (not wrapped) when the subscription can't continue: `MCP_EVENTS_SUBSCRIPTION_FAILED` for a non-retryable server error, `MCP_EVENTS_SUBSCRIPTION_TERMINATED` when the server ends a push or webhook subscription, or `MCP_EVENTS_RETRIES_EXHAUSTED` after `retry.maxAttempts` failed attempts in a row. The client reopens dropped streams and resumes polling from the last cursor after a reconnect, including after `reconnectServer()`. `disconnect()` ends all subscriptions.
1016
+
1017
+ #### `events.handleWebhook(request: Request)`
1018
+
1019
+ Handles one webhook delivery and returns the response to send back. Mount it on the route that `webhook.url` points at.
1020
+
1021
+ ```typescript
1022
+ async handleWebhook(request: Request): Promise<Response>
1023
+ ```
1024
+
1025
+ It verifies the Standard Webhooks signature on the raw body before parsing it, answers the server's verification handshake, and routes occurrences to their subscription by the `X-MCP-Subscription-Id` header. It responds with:
1026
+
1027
+ - `200` after the occurrence is handed to its subscription, or with the echoed challenge for a verification request.
1028
+ - `401` when the signature is invalid or the timestamp is more than 5 minutes old.
1029
+ - `503` when the subscription id isn't known yet. The server retries in that case, covering deliveries that arrive before the subscribe response.
1030
+ - `400` for a signed but malformed body, and `405` for methods other than `POST`.
1031
+ - `413` for a body over 1 MiB. The body is read only up to that limit, before any other check.
1032
+ - `404` when the client has no `webhook` settings.
1033
+
1034
+ #### Webhook delivery
1035
+
1036
+ With `webhook` settings, the client registers each subscription with `events/subscribe` and the server POSTs occurrences to your URL. The server must authenticate the client, and the URL must be publicly reachable over `https`.
1037
+
1038
+ ```typescript
1039
+ import { Mastra } from '@mastra/core'
1040
+ import { registerApiRoute } from '@mastra/core/server'
1041
+ import { MCPClient } from '@mastra/mcp'
1042
+
1043
+ export const mcpClient = new MCPClient({
1044
+ servers: {
1045
+ github: {
1046
+ url: new URL('https://mcp.example.com/mcp'),
1047
+ requestInit: { headers: { Authorization: `Bearer ${process.env.GITHUB_MCP_TOKEN}` } },
1048
+ },
1049
+ },
1050
+ webhook: { url: 'https://agent.example.com/mcp/webhook' },
1051
+ })
1052
+
1053
+ export const mastra = new Mastra({
1054
+ server: {
1055
+ apiRoutes: [
1056
+ registerApiRoute('/mcp/webhook', {
1057
+ method: 'POST',
1058
+ // Deliveries are authenticated by their signature, not by Mastra auth
1059
+ requiresAuth: false,
1060
+ handler: c => mcpClient.events.handleWebhook(c.req.raw),
1061
+ }),
1062
+ ],
1063
+ },
1064
+ })
1065
+ ```
1066
+
1067
+ **url** (`string`): Public https URL that routes to events.handleWebhook().
1068
+
1069
+ **secret** (`string`): A whsec\_ signing secret used for every subscription. By default the client generates a fresh secret for each subscription, so one server can't sign deliveries for another server's subscriptions.
1070
+
1071
+ **ttlMs** (`number | null`): Suggested subscription lifetime. null asks for no expiry, which the server may decline. Defaults to the server default.
1072
+
1073
+ **refreshMarginMs** (`number`): How long before the server-granted refreshBefore time to refresh the subscription. Defaults to the smaller of 60 seconds and 20% of the grant.
1074
+
1075
+ The client refreshes each subscription before it expires by repeating `events/subscribe` with the latest cursor. When the server reports failing delivery in `deliveryStatus`, for example because your endpoint timed out, `onError` receives `MCP_EVENTS_WEBHOOK_DELIVERY_FAILING` with `lastError` in its details. The `cursor` in each webhook delivery only covers occurrences your endpoint has acknowledged, so resuming from a saved cursor can deliver the last handled occurrence again. The next refresh resumes a suspended subscription. `cancel()` sends `events/unsubscribe`.
1076
+
1077
+ Webhook state lives in this process: run the receiving route in the same process as the `MCPClient` that subscribed.
1078
+
1079
+ Webhook delivery needs an authenticated HTTP connection to the server, because the server ties each webhook subscription to the caller. Over stdio, or over HTTP without authentication, the server rejects `events/subscribe`. It also rejects new subscriptions once its webhook subscription cap is reached (`-32025`). A subscription that didn't force a mode then falls back to `push` or `poll`, and the first `onError` handler receives `MCP_EVENTS_WEBHOOK_UNAVAILABLE` with the rejection `code` and the `fallback` mode in its details. Forcing `delivery: 'webhook'` rejects instead.
1080
+
1081
+ Subscriptions on one server with the same event name and arguments share a single server-side webhook subscription. Each one gets every occurrence through its own iterator, and the client sends `events/unsubscribe` only when the last of them is cancelled.
1082
+
1083
+ ### Events in agents and workflows (experimental)
1084
+
1085
+ `MCPEventsSignalProvider` delivers MCP server events to agent threads as notifications. Add it to an agent's `signals`, then subscribe threads to events. The agent needs a notifications storage domain, which `InMemoryStore` and the standard storage adapters provide.
1086
+
1087
+ > **Warning:** SEP-3415 is a draft. This API may change in any release.
1088
+
1089
+ ```typescript
1090
+ import { Agent } from '@mastra/core/agent'
1091
+ import { MCPClient, MCPEventsSignalProvider } from '@mastra/mcp'
1092
+
1093
+ const mcp = new MCPClient({
1094
+ servers: { github: { url: new URL('https://example.com/mcp') } },
1095
+ })
1096
+
1097
+ export const repoEvents = new MCPEventsSignalProvider({
1098
+ client: mcp,
1099
+ subscribeOptions: { maxAgeMs: 60 * 60 * 1000 },
1100
+ })
1101
+
1102
+ export const repoAgent = new Agent({
1103
+ id: 'repo-agent',
1104
+ name: 'Repo Agent',
1105
+ instructions: 'Triage repository activity.',
1106
+ model: 'openai/gpt-6.1-sol',
1107
+ signals: [repoEvents],
1108
+ })
1109
+
1110
+ await repoEvents.subscribeThread(
1111
+ { resourceId: 'user-1', threadId: 'thread-1' },
1112
+ { server: 'github', event: 'repo.push', args: { repo: 'mastra-ai/mastra' } },
1113
+ )
1114
+ ```
1115
+
1116
+ Threads that subscribe to the same server, event and arguments share one MCP subscription regardless of argument key order. Each occurrence becomes a notification with `kind: 'mcp-event'` and `attributes: { server, event }`. The raw occurrence is in `payload`. The notification `summary`, which is the only part the model reads, labels the event as untrusted and wraps its data, together with the server-advertised event name, in an `<untrusted-mcp-event-data>` block that the content can't close. When the server reports a gap, `attributes.truncated` is `true` and the summary says that events may have been skipped.
1117
+
1118
+ If the subscription ends, for example because the server terminates it, each subscribed thread receives a `high` priority notification with `kind: 'mcp-event-subscription-ended'` and the threads are unsubscribed.
1119
+
1120
+ **client** (`Pick<MCPClient, 'events'>`): The client used to list and subscribe to events.
1121
+
1122
+ **id** (`string`): Provider id, used as the notification source. (Default: `'mcp-events'`)
1123
+
1124
+ **name** (`string`): Display name. (Default: `'MCP Events'`)
1125
+
1126
+ **cursorStore** (`MCPEventCursorStore`): Stores the resume cursor for each subscription. Implement get(key), set(key, cursor) and delete(key) with durable storage so a subscription continues from its last cursor when a thread is subscribed again after a restart. Only cursors are stored, not which threads are subscribed. Only non-null cursors are stored. (Default: `InMemoryMCPEventCursorStore`)
1127
+
1128
+ **subscribeOptions** (`Omit<MCPEventSubscribeOptions, 'cursor' | 'signal'>`): Options for every MCP subscription, for example maxAgeMs to bound the backlog replayed on resume.
1129
+
1130
+ **priority** (`NotificationPriority`): Priority of event notifications. (Default: `'medium'`)
1131
+
1132
+ **coalesce** (`boolean`): Sets coalesceKey: 'mcp-events:\<key>' on event notifications, whatever the provider id. Pending notifications from one subscription then merge, so a burst that arrives before the agent reads its inbox keeps only the latest occurrence. When off, every occurrence is its own notification. (Default: `false`)
1133
+
1134
+ **tools** (`boolean | { servers: string[] }`): Gives the agent the mcp\_events\_list, mcp\_events\_subscribe and mcp\_events\_unsubscribe tools, which act on the current thread and require memory. Event descriptions and error messages from the server reach the model inside the same untrusted-data block as event data. Subscriptions made through the tools are lost on restart. Pass servers to limit them to those servers. (Default: `false`)
1135
+
1136
+ **onError** (`(error: unknown, info: { server: string; event: string; key: string }) => void`): Receives delivery, cursor store and subscription errors.
1137
+
1138
+ The provider has these methods:
1139
+
1140
+ - `subscribeThread(thread, { server, event, args? })`: Subscribes a thread and resolves once the MCP subscription is confirmed. It resumes from the stored cursor. If the server rejects the subscription, the thread isn't subscribed and the promise rejects. Thread subscriptions are kept in memory only: after a restart, call `subscribeThread()` again for each thread that should keep receiving events.
1141
+ - `unsubscribeThread(thread, { server, event, args? })`: Resolves to `true` when the thread was subscribed. When the last thread leaves, the MCP subscription is cancelled and its stored cursor is deleted.
1142
+ - `stop()`: Cancels every MCP subscription and keeps the stored cursors, so a new provider with the same `cursorStore` resumes where this one stopped.
1143
+ - `MCPEventsSignalProvider.key({ server, event, args? })`: Returns the subscription key used by the cursor store.
1144
+
1145
+ Delivery is at least once. The provider stores the cursor after it notifies the threads, so an occurrence notified right before a crash is replayed after the restart. The notification's `dedupeKey` includes the event id: if the first notification is still pending, the replay merges into it. If it was already delivered, the thread is notified again.
1146
+
1147
+ To start a workflow run for each occurrence, iterate a subscription directly:
1148
+
1149
+ ```typescript
1150
+ const subscription = await mcp.events.subscribe(
1151
+ 'github',
1152
+ 'repo.push',
1153
+ { repo: 'mastra-ai/mastra' },
1154
+ { cursor: await loadCursor() },
1155
+ )
1156
+
1157
+ process.once('SIGTERM', () => void subscription.cancel())
1158
+
1159
+ for await (const event of subscription) {
1160
+ const run = await triagePushWorkflow.createRun()
1161
+ await run.start({ inputData: { eventId: event.eventId, push: event.data } })
1162
+ if (subscription.cursor) await saveCursor(subscription.cursor)
1163
+ }
1164
+ ```
1165
+
764
1166
  ## Answering input requests
765
1167
 
766
1168
  A server tool, resource or prompt that needs something from the user ends its call with an `input_required` result instead of a value. The result carries one or more embedded requests, each with a server-chosen `key` and either a form (`requestedSchema`) or a URL the user must visit. Configure `inputRequests` on the server definition to answer them: the client calls the handler once per embedded request, retries the original call with the answers, and resolves the tool call with the final result. Without a handler an `input_required` result surfaces as an error.
@@ -998,7 +1400,7 @@ const client = new MCPClient({
998
1400
 
999
1401
  ### Custom Token Storage
1000
1402
 
1001
- For persistent token storage across sessions, implement the `OAuthStorage` interface. The provider stores tokens (both the latest set and one entry per authorization-server issuer), discovery state, and the PKCE verifier under string keys, so the backend only needs a key-value contract:
1403
+ For persistent token storage across sessions, implement the `OAuthStorage` interface. The provider stores tokens (both the latest set and one entry per authorization-server issuer), discovery state, and the PKCE verifier under string keys. The backend only needs a key-value contract:
1002
1404
 
1003
1405
  ```typescript
1004
1406
  import { MCPOAuthClientProvider, OAuthStorage } from '@mastra/mcp'
@@ -1074,7 +1476,7 @@ const agent = new Agent({
1074
1476
  id: 'multi-tool-agent',
1075
1477
  name: 'Multi-tool Agent',
1076
1478
  instructions: 'You have access to multiple tool servers.',
1077
- model: 'openai/gpt-5.6-sol',
1479
+ model: 'openai/gpt-6.1-sol',
1078
1480
  tools: await mcp.listTools(),
1079
1481
  })
1080
1482
 
@@ -1125,7 +1527,7 @@ const agent = new Agent({
1125
1527
  id: 'multi-tool-agent',
1126
1528
  name: 'Multi-tool Agent',
1127
1529
  instructions: 'You help users check stocks and weather.',
1128
- model: 'openai/gpt-5.6-sol',
1530
+ model: 'openai/gpt-6.1-sol',
1129
1531
  })
1130
1532
 
1131
1533
  // Later, configure MCP with user-specific settings
@@ -1200,6 +1602,31 @@ MCPClient handles server connections gracefully:
1200
1602
  2. Graceful server shutdown to prevent error messages during development
1201
1603
  3. Proper cleanup of resources when disconnecting
1202
1604
 
1605
+ ### Handle shutdown yourself
1606
+
1607
+ By default, a connected client installs hooks for `SIGINT`, `SIGTERM`, `SIGHUP`, and `beforeExit` that disconnect its servers and end the process. These hooks can interrupt your application's awaited cleanup, such as draining HTTP requests.
1608
+
1609
+ Set `registerProcessHooks: false` to let your application own shutdown. Call `disconnect()` after requests that use the client have finished:
1610
+
1611
+ ```typescript
1612
+ import { MCPClient } from '@mastra/mcp'
1613
+
1614
+ const mcp = new MCPClient({
1615
+ servers: { weather: { url: new URL('https://example.com/mcp') } },
1616
+ registerProcessHooks: false,
1617
+ })
1618
+
1619
+ process.once('SIGTERM', async () => {
1620
+ // Finish your application's cleanup before disconnecting the client.
1621
+ await mcp.disconnect()
1622
+ process.exit(0)
1623
+ })
1624
+ ```
1625
+
1626
+ Set the option on every `MCPClient` in the process before connecting. Once any client registers the default hooks, the global `SIGINT` and `SIGTERM` listeners remain until the process exits, even after `disconnect()`.
1627
+
1628
+ With hooks disabled, your application is responsible for closing MCP connections. In a Mastra server, coordinate `disconnect()` with your server's shutdown lifecycle so in-flight requests can finish using the client.
1629
+
1203
1630
  ## Using custom fetch for runtime-defined authentication
1204
1631
 
1205
1632
  For HTTP servers, you can provide a custom `fetch` function to handle runtime-defined authentication or request interception. It can also handle other custom behavior. This is particularly useful when you need to refresh tokens on each request or forward user credentials from the incoming request to the MCP server.