@mastra/mcp-docs-server 1.3.12 → 1.3.13-alpha.2

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 (177) hide show
  1. package/.docs/docs/agents/resumable-streams.md +140 -0
  2. package/.docs/docs/agents/tools.md +2 -2
  3. package/.docs/docs/auth/overview.md +1 -0
  4. package/.docs/docs/auth/simple-auth.md +8 -8
  5. package/.docs/docs/channels.md +34 -1
  6. package/.docs/docs/connections/mcp.md +66 -1
  7. package/.docs/docs/guides/authentication-identity.md +4 -0
  8. package/.docs/docs/harness/background-tasks.md +2 -1
  9. package/.docs/docs/harness/durable-agents.md +6 -6
  10. package/.docs/docs/harness/goals.md +1 -1
  11. package/.docs/docs/harness/schedules.md +2 -0
  12. package/.docs/docs/knowledge/agents-and-tools.md +122 -0
  13. package/.docs/docs/knowledge/load-your-content.md +86 -0
  14. package/.docs/docs/knowledge/overview.md +106 -0
  15. package/.docs/docs/knowledge/patterns.md +167 -0
  16. package/.docs/docs/knowledge/pinned-context.md +177 -0
  17. package/.docs/docs/knowledge/scopes-and-access.md +202 -0
  18. package/.docs/docs/knowledge/search.md +63 -0
  19. package/.docs/docs/mastra-platform/connect.md +231 -0
  20. package/.docs/docs/mastra-platform/overview.md +1 -1
  21. package/.docs/docs/memory/observational-memory.md +23 -23
  22. package/.docs/docs/memory/overview.md +19 -7
  23. package/.docs/docs/observability/tracing/overview.md +0 -2
  24. package/.docs/docs/server/custom-adapters.md +4 -0
  25. package/.docs/docs/server/request-context.md +6 -6
  26. package/.docs/docs/server/server-adapters.md +12 -12
  27. package/.docs/docs/signals/sending-signals.md +3 -1
  28. package/.docs/docs/studio/knowledge.md +45 -24
  29. package/.docs/docs/studio/overview.md +3 -1
  30. package/.docs/integrations/auth/clerk.md +46 -7
  31. package/.docs/integrations/auth/neon.md +217 -0
  32. package/.docs/integrations/auth/supabase.md +46 -7
  33. package/.docs/integrations/auth/workos.md +54 -15
  34. package/.docs/integrations/channels/discord.md +84 -6
  35. package/.docs/integrations/channels/github.md +63 -24
  36. package/.docs/integrations/channels/slack.md +89 -8
  37. package/.docs/integrations/channels/teams.md +79 -5
  38. package/.docs/integrations/channels/telegram.md +47 -6
  39. package/.docs/integrations/crm/attio.md +42 -0
  40. package/.docs/integrations/crm/clay.md +42 -0
  41. package/.docs/integrations/crm/hubspot.md +41 -0
  42. package/.docs/integrations/databases/neon.md +37 -1
  43. package/.docs/integrations/databases/postgresql.md +46 -0
  44. package/.docs/integrations/deploy/render.md +59 -18
  45. package/.docs/integrations/documents/google-docs.md +41 -0
  46. package/.docs/integrations/documents/google-sheet.md +41 -0
  47. package/.docs/integrations/documents/microsoft-excel.md +43 -0
  48. package/.docs/integrations/documents/microsoft-powerpoint.md +41 -0
  49. package/.docs/integrations/documents/microsoft-word.md +41 -0
  50. package/.docs/integrations/documents/notion.md +41 -0
  51. package/.docs/integrations/documents/one-drive.md +41 -0
  52. package/.docs/integrations/documents/sharepoint-online.md +41 -0
  53. package/.docs/integrations/email-calendar/google-calendar.md +41 -0
  54. package/.docs/integrations/email-calendar/google-mail.md +41 -0
  55. package/.docs/integrations/email-calendar/outlook.md +41 -0
  56. package/.docs/integrations/file-storage/amazon-s3.md +1 -1
  57. package/.docs/integrations/file-storage/google-drive.md +54 -15
  58. package/.docs/integrations/observability/posthog.md +50 -11
  59. package/.docs/integrations/other/canva.md +42 -0
  60. package/.docs/integrations/other/fireflies.md +41 -0
  61. package/.docs/integrations/other/incident-io.md +41 -0
  62. package/.docs/integrations/other/resend.md +43 -0
  63. package/.docs/integrations/other/robinhood.md +44 -0
  64. package/.docs/integrations/other/sanity.md +42 -0
  65. package/.docs/integrations/other/snowflake.md +41 -0
  66. package/.docs/integrations/project-management/jira.md +41 -0
  67. package/.docs/integrations/project-management/linear.md +41 -0
  68. package/.docs/integrations/voice/openai.md +40 -0
  69. package/.docs/integrations.md +40 -1
  70. package/.docs/models/gateways/custom-gateways.md +2 -0
  71. package/.docs/models/gateways/netlify.md +8 -3
  72. package/.docs/models/gateways/openrouter.md +7 -8
  73. package/.docs/models/gateways/vercel.md +418 -418
  74. package/.docs/models/index.md +46 -2
  75. package/.docs/models/providers/aiand.md +1 -1
  76. package/.docs/models/providers/baseten.md +2 -1
  77. package/.docs/models/providers/chutes.md +2 -1
  78. package/.docs/models/providers/edenai.md +5 -9
  79. package/.docs/models/providers/empiriolabs.md +3 -3
  80. package/.docs/models/providers/hyper.md +7 -13
  81. package/.docs/models/providers/inceptron.md +3 -3
  82. package/.docs/models/providers/kilo.md +20 -25
  83. package/.docs/models/providers/llmgateway-providers.md +22 -10
  84. package/.docs/models/providers/llmgateway.md +5 -5
  85. package/.docs/models/providers/modular.md +6 -6
  86. package/.docs/models/providers/nano-gpt.md +18 -21
  87. package/.docs/models/providers/opencode-go.md +3 -1
  88. package/.docs/models/providers/opencode.md +3 -2
  89. package/.docs/models/providers/ovhcloud.md +1 -2
  90. package/.docs/models/providers/prime.md +1 -1
  91. package/.docs/models/providers/tencent-token-plan.md +2 -1
  92. package/.docs/models/providers/tencent-tokenhub.md +2 -1
  93. package/.docs/models/providers/tinfoil.md +2 -2
  94. package/.docs/models/providers/togetherai.md +2 -1
  95. package/.docs/models/providers/wandb.md +5 -4
  96. package/.docs/reference/agents/agent.md +3 -1
  97. package/.docs/reference/agents/channels.md +38 -1
  98. package/.docs/reference/agents/durable-agent.md +37 -26
  99. package/.docs/reference/agents/generate.md +1 -1
  100. package/.docs/reference/agents/getLLM.md +1 -1
  101. package/.docs/reference/agents/getMetadata.md +1 -1
  102. package/.docs/reference/agents/getModel.md +4 -2
  103. package/.docs/reference/agents/getSkill.md +1 -1
  104. package/.docs/reference/agents/listScorers.md +1 -1
  105. package/.docs/reference/agents/listTools.md +1 -1
  106. package/.docs/reference/auth/better-auth.md +2 -2
  107. package/.docs/reference/auth/neon.md +24 -15
  108. package/.docs/reference/channels/slack-provider.md +1 -1
  109. package/.docs/reference/cli/mastra.md +10 -1
  110. package/.docs/reference/client-js/agents.md +4 -4
  111. package/.docs/reference/client-js/observability.md +90 -3
  112. package/.docs/reference/connect/channels.md +55 -1
  113. package/.docs/reference/connect/providers.md +5 -3
  114. package/.docs/reference/connect/tools.md +34 -3
  115. package/.docs/reference/core/addDynamicWorkflow.md +1 -1
  116. package/.docs/reference/core/addGateway.md +1 -1
  117. package/.docs/reference/core/getAgent.md +4 -2
  118. package/.docs/reference/core/getEditor.md +1 -1
  119. package/.docs/reference/core/getGateway.md +1 -1
  120. package/.docs/reference/core/getGatewayById.md +14 -1
  121. package/.docs/reference/core/getMemory.md +2 -2
  122. package/.docs/reference/core/getStorage.md +1 -1
  123. package/.docs/reference/core/listMemory.md +3 -3
  124. package/.docs/reference/core/listScorers.md +2 -2
  125. package/.docs/reference/core/listVectors.md +1 -1
  126. package/.docs/reference/evals/completeness.md +0 -1
  127. package/.docs/reference/evals/content-similarity.md +1 -3
  128. package/.docs/reference/evals/create-scorer.md +5 -3
  129. package/.docs/reference/evals/faithfulness.md +1 -1
  130. package/.docs/reference/evals/hallucination.md +2 -2
  131. package/.docs/reference/evals/noise-sensitivity.md +8 -1
  132. package/.docs/reference/evals/scorer-utils.md +1 -1
  133. package/.docs/reference/index.md +7 -0
  134. package/.docs/reference/knowledge/knowledge-class.md +296 -0
  135. package/.docs/reference/knowledge/knowledge-memory-scopes.md +78 -0
  136. package/.docs/reference/knowledge/knowledge-tools.md +299 -0
  137. package/.docs/reference/knowledge/limits.md +44 -0
  138. package/.docs/reference/knowledge/scope-declarations.md +275 -0
  139. package/.docs/reference/knowledge/tool-instructions.md +56 -0
  140. package/.docs/reference/logging/pino-logger.md +1 -1
  141. package/.docs/reference/memory/observational-memory.md +9 -7
  142. package/.docs/reference/observability/feedback.md +3 -1
  143. package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
  144. package/.docs/reference/processors/batch-parts-processor.md +0 -2
  145. package/.docs/reference/processors/message-history-processor.md +1 -1
  146. package/.docs/reference/processors/moderation-processor.md +1 -1
  147. package/.docs/reference/processors/semantic-recall-processor.md +1 -1
  148. package/.docs/reference/processors/stream-error-retry-processor.md +1 -1
  149. package/.docs/reference/processors/token-limiter-processor.md +1 -1
  150. package/.docs/reference/processors/tool-search-processor.md +1 -1
  151. package/.docs/reference/pubsub/redis-streams.md +2 -0
  152. package/.docs/reference/schedules/overview.md +3 -3
  153. package/.docs/reference/server/invoke-route.md +86 -0
  154. package/.docs/reference/server/koa-adapter.md +1 -1
  155. package/.docs/reference/server/routes.md +63 -0
  156. package/.docs/reference/streaming/ChunkType.md +3 -1
  157. package/.docs/reference/streaming/agents/MastraModelOutput.md +6 -4
  158. package/.docs/reference/streaming/agents/stream.md +1 -1
  159. package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
  160. package/.docs/reference/tools/mcp-client.md +4 -0
  161. package/.docs/reference/tools/mcp-server.md +6 -2
  162. package/.docs/reference/tools/vector-query-tool.md +3 -3
  163. package/.docs/reference/workflows/run-methods/start.md +1 -1
  164. package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
  165. package/.docs/reference/workflows/workflow.md +2 -0
  166. package/.docs/reference/workspace/sandbox.md +1 -1
  167. package/dist/index.js +1 -1
  168. package/dist/{src-BDrEqwuY.js → src-CwUXyWAK.js} +3 -3
  169. package/dist/src-CwUXyWAK.js.map +1 -0
  170. package/dist/stdio.js +1 -1
  171. package/dist/tools/embedded-docs.d.ts.map +1 -1
  172. package/package.json +4 -4
  173. package/.docs/docs/mastra-platform/connect/channels.md +0 -165
  174. package/.docs/docs/mastra-platform/connect/overview.md +0 -102
  175. package/.docs/docs/mastra-platform/connect/providers.md +0 -66
  176. package/.docs/docs/mastra-platform/connect/tools.md +0 -151
  177. package/dist/src-BDrEqwuY.js.map +0 -1
@@ -443,6 +443,69 @@ The in-memory fallback is identified by `isFromInMemory: true`. It returns run m
443
443
  }
444
444
  ```
445
445
 
446
+ ## Knowledge
447
+
448
+ These routes aren't registered by default. Add them with `KNOWLEDGE_ROUTES` from `@mastra/server/server-adapter` in `server.apiRoutes`, and register the instance on `Mastra` under `knowledge`. They need `@mastra/core` 1.81.0 or later, and the two link routes need 1.82.0 or later. With an RBAC provider, every route requires the `knowledge:read` permission. Without one, that check is skipped. See [Studio Knowledge](https://mastra.ai/docs/studio/knowledge) for setup.
449
+
450
+ | Method | Path | Description |
451
+ | ------ | -------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
452
+ | `GET` | `/api/knowledge` | List the registered Knowledge instances, filtered by FGA when configured |
453
+ | `GET` | `/api/knowledge/:knowledgeKey/tree` | List the root scopes, or the children of `parentId` |
454
+ | `GET` | `/api/knowledge/:knowledgeKey/pages/:pageId` | Get a page with its ancestors, notes, pin and referenced pages |
455
+ | `GET` | `/api/knowledge/:knowledgeKey/link-counts` | Count the links into and out of each page in `pageId` |
456
+ | `GET` | `/api/knowledge/:knowledgeKey/pages/:pageId/links` | List the links into and out of one page |
457
+ | `GET` | `/api/knowledge/:knowledgeKey/graph` | Get a bounded graph of pages with parent and mention edges and scope grants |
458
+ | `GET` | `/api/knowledge/:knowledgeKey/search` | Search page names, descriptions, bodies and notes |
459
+ | `GET` | `/api/knowledge/:knowledgeKey/activity` | List recent changes, optionally for one scope or page |
460
+ | `GET` | `/api/knowledge/:knowledgeKey/events` | Stream the caller's readable writes as Server-Sent Events. See [Knowledge events](#knowledge-events) |
461
+
462
+ `:knowledgeKey` is the key the instance is registered under in `knowledge: { ... }`.
463
+
464
+ ### Knowledge query parameters
465
+
466
+ | Route | Parameters |
467
+ | --------------------- | ------------------------------------------------------------------------------------- |
468
+ | `tree` | `parentId` (omit for root scopes), `cursor`, `limit` (1 to 100) |
469
+ | `pages/:pageId` | `noteCursor`, `noteLimit` (1 to 100) |
470
+ | `link-counts` | `pageId`, repeated once per page, 1 to 200 |
471
+ | `pages/:pageId/links` | `direction`: `in`, `out` or `both` (default) |
472
+ | `graph` | `rootId` (omit to walk every root scope), `maxPages` (1 to 500) |
473
+ | `search` | `q` (1 to 200 characters), `scopeId` (repeat for up to 20 scopes), `limit` (1 to 100) |
474
+ | `activity` | `scopeId`, `pageId`, `cursor`, `limit` (1 to 100) |
475
+
476
+ ### Knowledge access and errors
477
+
478
+ Without `server.auth` or `studio.auth`, the routes read as the instance owner and return everything. With auth, they read only what the scopes in the request context key `MASTRA_KNOWLEDGE_PRINCIPALS_KEY` can read. Set it to an array of scopes, or `'all'`.
479
+
480
+ | Status | When |
481
+ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
482
+ | `403` | Auth is configured and `MASTRA_KNOWLEDGE_PRINCIPALS_KEY` isn't set. `GET /api/knowledge` doesn't read the key, so it doesn't return `403` |
483
+ | `404` | The instance doesn't exist or the FGA provider denies `knowledge:read` on it, or the page doesn't exist or the caller can't read it. For an unreadable page, the link routes report zero counts and no links instead |
484
+ | `500` | `MASTRA_KNOWLEDGE_PRINCIPALS_KEY` isn't an array or `'all'`, or holds a scope that matches no declared scope type |
485
+ | `501` | `@mastra/core` is older than the route needs, or the store has no link index (link routes) |
486
+
487
+ With an FGA provider, each instance is checked as resource type `knowledge`, by its registered key, with `knowledge:read`. `GET /api/knowledge` lists only the instances the caller can read. With `requireForProtectedRoutes`, `GET /api/knowledge` is refused, because like other list routes it has no FGA metadata. Without an RBAC provider, the `knowledge:read` check is skipped.
488
+
489
+ The NestJS adapter doesn't serve these routes yet.
490
+
491
+ ### Knowledge events
492
+
493
+ `GET /api/knowledge/:knowledgeKey/events` sends one event per committed write that the caller can read:
494
+
495
+ ```typescript
496
+ {
497
+ kind: 'scope' | 'page' | 'note' | 'pin';
498
+ op: string; // such as 'create', 'update', 'delete' or 'merge'
499
+ pageId?: string; // left out when the caller can't read the page, including a deleted one
500
+ scopeId?: string; // left out when the caller can't read the scope
501
+ at: string; // ISO timestamp
502
+ }
503
+ ```
504
+
505
+ Writes that touch nothing the caller can read aren't sent. Events carry IDs, not content, so fetch what changed with the other routes. When `pageId` is missing, refresh the scope in `scopeId`.
506
+
507
+ The server sends a keepalive comment every 25 seconds and closes the stream after five minutes. Reconnect when it closes. The new stream reads the caller's scopes again, so revoked access stops updates. Writes made while disconnected aren't replayed, so refresh what you show after reconnecting.
508
+
446
509
  ## Vectors
447
510
 
448
511
  | Method | Path | Description |
@@ -8,7 +8,7 @@ The `ChunkType` type defines the mastra format of stream chunks that can be emit
8
8
 
9
9
  ## Base properties
10
10
 
11
- All chunks include these base properties:
11
+ All chunks except custom `data-*` chunks include these base properties:
12
12
 
13
13
  **type** (`string`): The specific chunk type identifier
14
14
 
@@ -26,6 +26,8 @@ All chunks include these base properties:
26
26
 
27
27
  **from.WORKFLOW** (`'WORKFLOW'`): Chunk from workflow execution
28
28
 
29
+ **from.NETWORK** (`'NETWORK'`): Chunk from agent network execution
30
+
29
31
  ## Text chunks
30
32
 
31
33
  ### text-start
@@ -39,9 +39,9 @@ These properties resolve to final values after the stream completes:
39
39
 
40
40
  **object.InferSchemaOutput** (`OUTPUT`): Fully typed object matching the exact schema definition
41
41
 
42
- **reasoning** (`Promise<string>`): Complete reasoning text for models that support reasoning (like OpenAI's o1 series). Returns empty string for models without reasoning capability.
42
+ **reasoning** (`Promise<ReasoningChunk[]>`): Reasoning parts for models that support reasoning (like OpenAI's o1 series). Resolves to an empty array for models without reasoning capability. Use 'reasoningText' for the reasoning as a single string.
43
43
 
44
- **reasoningText** (`Promise<string | undefined>`): Alternative access to reasoning content. May be undefined for models that don't support reasoning, while 'reasoning' returns empty string.
44
+ **reasoningText** (`Promise<string | undefined>`): Complete reasoning text, joined from all reasoning parts. Resolves to undefined for models that don't produce reasoning.
45
45
 
46
46
  **toolCalls** (`Promise<ToolCallChunk[]>`): Array of all tool call chunks made during execution. Each chunk contains tool metadata and execution details.
47
47
 
@@ -117,7 +117,9 @@ These properties resolve to final values after the stream completes:
117
117
 
118
118
  **getFullOutput.usage** (`Record<string, number>`): Token usage statistics
119
119
 
120
- **getFullOutput.reasoning** (`string`): Reasoning text if available
120
+ **getFullOutput.reasoning** (`ReasoningChunk[]`): Reasoning parts. Empty array if the model produced no reasoning
121
+
122
+ **getFullOutput.reasoningText** (`string`): Combined reasoning text if available
121
123
 
122
124
  **getFullOutput.finishReason** (`string`): Why generation finished
123
125
 
@@ -192,7 +194,7 @@ const output = await stream.getFullOutput()
192
194
  console.log({
193
195
  text: output.text,
194
196
  usage: output.usage,
195
- reasoning: output.reasoning,
197
+ reasoningText: output.reasoningText,
196
198
  finishReason: output.finishReason,
197
199
  })
198
200
  ```
@@ -122,7 +122,7 @@ const stream = await agent.stream('message for agent')
122
122
 
123
123
  **options.output** (`Zod schema | JsonSchema7`): \*\*Deprecated.\*\* Use structuredOutput without a model to achieve the same thing. Defines the expected structure of the output. Can be a JSON Schema object or a Zod schema.
124
124
 
125
- **options.scopes** (`string[]`): Scopes the run acts as, written as \<type>:\<value> (for example org:acme, resource:user-123, thread:conversation-123). Memory reads its resource and thread from resource: and thread: scopes. Other scopes are passed to tools and processors. Combined with the agent's scopes and the mastra__scopes request context key. Throws if a resource: or thread: scope conflicts with another resource or thread value.
125
+ **options.scopes** (`string[]`): Scopes the run acts as, written as \<type>:\<value> (for example org:acme, resource:user-123, thread:conversation-123). Memory reads its resource and thread from resource: and thread: scopes. Other scopes are passed to tools and processors. Combined with defaultOptions.scopes and the mastra__scopes request context key, then passed through the agent's scopes option: a list adds to them, a function replaces them. Throws if a resource: or thread: scope conflicts with another resource or thread value.
126
126
 
127
127
  **options.memory** (`object`): Configuration for memory. This is the preferred way to manage memory.
128
128
 
@@ -62,7 +62,7 @@ if (result!.status === 'suspended') {
62
62
 
63
63
  **stream.result** (`Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>`): A promise that resolves to the final workflow result
64
64
 
65
- **stream.usage** (`Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cacheInputTokens?: number }>`): A promise that resolves to token usage statistics
65
+ **stream.usage** (`Promise<{ inputTokens: number; outputTokens: number; totalTokens: number, reasoningTokens?: number, cachedInputTokens?: number }>`): A promise that resolves to token usage statistics
66
66
 
67
67
  ## Stream events
68
68
 
@@ -414,6 +414,8 @@ Tool results returned by MCP servers flow into your agent's context as model inp
414
414
 
415
415
  Retrieves all tools from all configured servers, with tool names namespaced by their server name (in the format `serverName_toolName`) to prevent conflicts. Intended to be passed onto an Agent definition.
416
416
 
417
+ App-only tools, whose `_meta.ui.visibility` omits `"model"`, are left out. `listToolsets()` and `listToolDefinitions()` leave them out too.
418
+
417
419
  ```ts
418
420
  new Agent({ id: 'agent', tools: await mcp.listTools() })
419
421
  ```
@@ -503,6 +505,8 @@ const retry = await mcp.listToolsetsWithErrors({ serverNames: timedOut })
503
505
 
504
506
  Returns every server's tools as plain, serializable definitions, grouped by server name and keyed by the server's own tool name (without the `serverName_toolName` namespacing that `listTools()` applies).
505
507
 
508
+ Like `listTools()`, it leaves out app-only tools, whose `_meta.ui.visibility` omits `"model"`. An MCP App calls those through its host, so they never reach an agent.
509
+
506
510
  Unlike `listTools()`, the result contains no functions or references to a live client, so it can be passed through `JSON.stringify` and cached in Redis or a database, as well as a build artifact. Each definition holds the data from the MCP `tools/list` response (name, title, description, input schema, output schema, annotations, and `_meta`), plus the server name, version, and instructions captured at discovery time.
507
511
 
508
512
  ```typescript
@@ -625,6 +625,8 @@ export type MCPServerResourceContent = { text?: string } | { blob?: string }
625
625
 
626
626
  Every callback receives `extra`, the same protocol context tools see as `context.mcp.extra` (cancellation `signal`, `requestId`, `authInfo`, `_meta`), and `requestContext`, the trusted application context that carries `authInfo` and the user mapped by `mapAuthInfoToUser`. Use them to scope what a caller can list and read.
627
627
 
628
+ A `resources/read` request resolves its URI against `listResources` first. When no listed resource matches, the URI is matched against the caller's `resourceTemplates`, and `getResourceContent` receives the expanded URI. Optional expressions such as `{?format}` or `{/section}` may be left out of the URI. Variable values must be percent-encoded as RFC 6570 expansion produces them, so `file://data?format=a/b` doesn't match `file://data{?format}`. The response uses the `mimeType` and `_meta` of the matching resource or template. A URI that matches neither fails with `Resource not found`.
629
+
628
630
  `getResourceContent` also receives `suspend`, `resumeData` and `suspendPayload` (the `MCPServerRequest` members). Declare `resumeSchema` to make `suspend` usable. It works exactly as it does for tools.
629
631
 
630
632
  Example:
@@ -640,11 +642,13 @@ import type {
640
642
 
641
643
  // Resources/resource templates will generally be dynamically fetched.
642
644
  const myResources: Resource[] = [
643
- { uri: 'file://data/123.txt', name: 'Data File', mimeType: 'text/plain' },
645
+ { uri: 'file://data/readme', name: 'Readme', mimeType: 'text/plain' },
644
646
  ]
645
647
 
646
648
  const myResourceContents: Record<string, MCPServerResourceContent> = {
647
- 'file://data.txt/123': { text: 'This is the content of the data file.' },
649
+ 'file://data/readme': { text: 'Read this first.' },
650
+ // Not listed; readable as an expansion of the `file://data/{id}` template
651
+ 'file://data/123': { text: 'This is the content of data file 123.' },
648
652
  }
649
653
 
650
654
  const myResourceTemplates: ResourceTemplate[] = [
@@ -88,14 +88,14 @@ The tool returns an object with:
88
88
  ```typescript
89
89
  {
90
90
  id: string; // Unique chunk/document identifier
91
- metadata: any; // All metadata fields (document ID, etc.)
92
- vector: number[]; // Embedding vector (if available)
91
+ metadata?: any; // All metadata fields (document ID, etc.)
92
+ vector: number[]; // Embedding vector, or [] when unavailable
93
93
  score: number; // Similarity score for this retrieval
94
94
  document: string; // Full chunk/document text (if available)
95
95
  }
96
96
  ```
97
97
 
98
- `document` is only populated by vector stores whose `query()` returns document content, such as Chroma, Elasticsearch, LanceDB, and MongoDB. For other stores, such as PgVector, it's an empty string. Read the chunk text from `sources[i].metadata.text` (or whichever metadata key you stored it under).
98
+ `document` is only populated by vector stores whose `query()` returns document content, such as Chroma, Elasticsearch, LanceDB, and MongoDB. For other stores, such as PgVector, it's an empty string. Read the chunk text from `sources[i].metadata?.text` (or whichever metadata key you stored it under). `metadata` is `undefined` when the store returns no metadata for a result.
99
99
 
100
100
  ## Default tool description
101
101
 
@@ -40,7 +40,7 @@ const result = await run.start({
40
40
 
41
41
  **tracingOptions.traceId** (`string`): Trace ID to use for this execution (1-32 hexadecimal characters). If provided, this trace will be part of the specified trace.
42
42
 
43
- **tracingOptions.parentSpanId** (`string`): Parent span ID to use for this execution (1-16 hexadecimal characters). If provided, the root span will be created as a child of this span.
43
+ **tracingOptions.parentSpanId** (`string`): Parent span ID to use for this execution (1-16 hexadecimal characters). Used to correlate with an external tracing system. Mastra does not treat it as a parent within Mastra storage unless nestUnderParent is true and a valid traceId is also set.
44
44
 
45
45
  **tracingOptions.nestUnderParent** (`boolean`): Set to true together with parentSpanId to attach this run as a child of that span inside the existing trace, for example an LLM judge under the run it scores. Exporters then keep the trace's own name, input, output, and tags. Leave unset when parentSpanId comes from your own tracing system. Ignored without a valid traceId and parentSpanId.
46
46
 
@@ -63,7 +63,7 @@ const result = await run.timeTravel({
63
63
 
64
64
  ## Returns
65
65
 
66
- **result** (`Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>`): A promise that resolves to the workflow execution result containing step outputs and status
66
+ **result** (`TOutput`): The workflow output. Present when status is 'success'.
67
67
 
68
68
  **traceId** (`string`): The trace ID associated with this execution when Tracing is enabled. Use this to correlate logs and debug execution flow.
69
69
 
@@ -131,6 +131,8 @@ export const testWorkflow = createWorkflow({
131
131
 
132
132
  **options.pruneSnapshot** (`(params: { snapshot: WorkflowRunState; workflowStatus: WorkflowRunStatus }) => WorkflowRunState`): Optional hook to transform the workflow snapshot immediately before it is persisted. Must return JSON-serializable data and preserve everything the workflow needs to resume (suspended step suspendPayloads, suspendedPaths, executionPath, etc.). Used internally by agent runs to keep snapshots minimal; user workflows persist full snapshots by default.
133
133
 
134
+ **options.storageVersion** (`1 | 2`): Experimental. How runs of this workflow are stored. 1 rewrites the whole run on every save. 2 saves only what changed at each step, which cuts storage writes for long workflows and loops. Version 2 requires the default execution engine and a storage adapter that supports it: in-memory, @mastra/pg, or @mastra/libsql. Creating a run on another adapter throws. It can't be combined with pruneSnapshot. Inside a version 2 run, read earlier steps with await getStepResultAsync(step) instead of getStepResult(step), and a shouldPersistSnapshot predicate sees earlier successful steps without their output. Workflow state is stored as JSON, so values such as Date are read back as strings. A run keeps the version it was stored with, so a run resumed after changing this option continues in that version. A nested workflow's runs use their parent run's version, so this option applies only when the workflow runs on its own.
135
+
134
136
  **options.onStart** (`(info: WorkflowStartCallbackInfo) => void | Promise<void>`): Callback awaited before a run starts executing, and before any step runs. Fires only on initial start, not on resume, restart, or time travel. Unlike onFinish and onError, errors thrown here are propagated: they reject the start() or stream() call and the run never executes, so this can be used as a pre-flight gate such as a quota check. The run record created by createRun() stays at status pending.
135
137
 
136
138
  **options.onStart.runId** (`string`): The workflow run ID
@@ -186,7 +186,7 @@ The runtime environment applies to commands executed through the sandbox rather
186
186
 
187
187
  ### `getEnv()`
188
188
 
189
- Returns a copy of the sandbox's current runtime environment; because mutations to the returned object don't change the sandbox, use `setEnv()` for updates.
189
+ Available on `MastraSandbox`, not declared on the `WorkspaceSandbox` interface. Returns a copy of the sandbox's current runtime environment; because mutations to the returned object don't change the sandbox, use `setEnv()` for updates.
190
190
 
191
191
  ```typescript
192
192
  const token = sandbox.getEnv().GH_TOKEN
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as createDocsServer, n as runServer } from "./src-BDrEqwuY.js";
1
+ export { t as createDocsServer, n as runServer } from "./src-CwUXyWAK.js";
@@ -1081,8 +1081,8 @@ async function readSourceMap(packageName, projectPath) {
1081
1081
  sourceMapCache.set(cacheKey, null);
1082
1082
  return null;
1083
1083
  }
1084
- const sourceMapPath = path.join(packageInfo.rootPath, "dist", "docs", "SOURCE_MAP.json");
1085
- const content = await fs.readFile(sourceMapPath, "utf-8");
1084
+ const docsDir = path.join(packageInfo.rootPath, "dist", "docs");
1085
+ const content = await fs.readFile(path.join(docsDir, "assets", "SOURCE_MAP.json"), "utf-8").catch(() => fs.readFile(path.join(docsDir, "SOURCE_MAP.json"), "utf-8"));
1086
1086
  const sourceMap = JSON.parse(content);
1087
1087
  sourceMapCache.set(cacheKey, sourceMap);
1088
1088
  return sourceMap;
@@ -1847,4 +1847,4 @@ async function runServer() {
1847
1847
  }
1848
1848
  export { writeErrorLog as i, runServer as n, setLogLevel as r, createDocsServer as t };
1849
1849
 
1850
- //# sourceMappingURL=src-BDrEqwuY.js.map
1850
+ //# sourceMappingURL=src-CwUXyWAK.js.map