@mastra/mcp-docs-server 1.3.13-alpha.9 → 1.3.13

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 (55) hide show
  1. package/.docs/docs/agents/code-mode.md +4 -0
  2. package/.docs/docs/agents/tools.md +10 -2
  3. package/.docs/docs/auth/custom-auth-provider.md +66 -0
  4. package/.docs/docs/auth/jwt.md +1 -1
  5. package/.docs/docs/connections/mcp.md +4 -65
  6. package/.docs/docs/evals/overview.md +4 -0
  7. package/.docs/docs/harness/schedules.md +1 -1
  8. package/.docs/docs/memory/multi-user-threads.md +57 -127
  9. package/.docs/docs/memory/observational-memory.md +196 -756
  10. package/.docs/docs/memory/overview.md +4 -0
  11. package/.docs/docs/observability/feedback.md +5 -7
  12. package/.docs/docs/sandbox/overview.md +2 -0
  13. package/.docs/docs/sandbox/search.md +25 -0
  14. package/.docs/docs/server/mcp.md +315 -0
  15. package/.docs/docs/server/request-context.md +35 -0
  16. package/.docs/docs/studio/deployment.md +0 -1
  17. package/.docs/docs/studio/overview.md +4 -4
  18. package/.docs/docs/workflows/scheduled-workflows.md +26 -5
  19. package/.docs/integrations/sandboxes/docker.md +39 -0
  20. package/.docs/integrations/sandboxes/e2b.md +1 -1
  21. package/.docs/integrations/voice/openai.md +2 -2
  22. package/.docs/models/gateways/custom-gateways.md +74 -44
  23. package/.docs/reference/agents/generate.md +1 -1
  24. package/.docs/reference/agents/generateLegacy.md +7 -23
  25. package/.docs/reference/auth/jwt.md +26 -2
  26. package/.docs/reference/cli/mastra.md +74 -6
  27. package/.docs/reference/client-js/observability.md +13 -5
  28. package/.docs/reference/configuration.md +64 -0
  29. package/.docs/reference/connect/tools.md +59 -0
  30. package/.docs/reference/editor/mastra-editor.md +1 -1
  31. package/.docs/reference/index.md +1 -0
  32. package/.docs/reference/memory/observational-memory.md +350 -151
  33. package/.docs/reference/observability/feedback.md +57 -14
  34. package/.docs/reference/observability/tracing/advanced-queries.md +3 -1
  35. package/.docs/reference/observability/tracing/exporters/langfuse.md +24 -1
  36. package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +19 -16
  37. package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
  38. package/.docs/reference/observability/tracing/interfaces.md +2 -2
  39. package/.docs/reference/observability/tracing/spans.md +7 -1
  40. package/.docs/reference/processors/processor-interface.md +23 -0
  41. package/.docs/reference/rag/chunk.md +1 -1
  42. package/.docs/reference/rag/graph-rag-guide.md +3 -1
  43. package/.docs/reference/schedules/overview.md +25 -5
  44. package/.docs/reference/server/dispatch-route.md +124 -0
  45. package/.docs/reference/server/elysia-adapter.md +1 -1
  46. package/.docs/reference/server/express-adapter.md +17 -11
  47. package/.docs/reference/server/fastify-adapter.md +1 -1
  48. package/.docs/reference/server/hono-adapter.md +1 -1
  49. package/.docs/reference/server/invoke-route.md +10 -0
  50. package/.docs/reference/server/koa-adapter.md +1 -1
  51. package/.docs/reference/server/nestjs-adapter.md +1 -1
  52. package/.docs/reference/streaming/agents/stream.md +1 -1
  53. package/.docs/reference/workspace/factory-sandbox.md +20 -1
  54. package/.docs/reference/workspace/platform-sandbox.md +1 -1
  55. package/package.json +5 -5
@@ -109,6 +109,7 @@ The resolver also exposes methods for manual control:
109
109
  - `refresh()` fetches from the platform immediately, then updates the cache and returns the tool record. Rejects if the platform fetch fails.
110
110
  - `disconnect()` clears the cached snapshots and closes the MCP transports of the state behind this resolver. Resolvers created with identical options share that state, so this disconnects them too. A later resolution rebuilds the state, and already-returned MCP tools reconnect on their next call.
111
111
  - `with(extra)` returns a new resolver that merges extra tools into every resolution, giving extras priority on key collision. It accepts a static tool record or a function (sync or async) and calls chain. For the same merge using a spread of the resolver's result in a `tools` callback, see [Add tools to an agent](https://mastra.ai/docs/mastra-platform/connect).
112
+ - `codeMode(options)` exposes the tools through [Code Mode](#code-mode).
112
113
 
113
114
  To filter on something other than tool keys, or on data that options can't express, post-process the resolved record in the agent's `tools` function. Create the resolver once, outside the function, so its cache is shared:
114
115
 
@@ -144,6 +145,64 @@ Error handling depends on the cause:
144
145
  - If a background refresh fails while a snapshot is cached, the resolver keeps serving the cached toolsets and warns. It rejects only when nothing was ever cached.
145
146
  - A problem with one provider, such as a connection that needs reauthorization, logs a warning and skips that provider. The other providers' tools still load.
146
147
 
148
+ ## Code Mode
149
+
150
+ `codeMode()` gives the agent the connected tools through [Code Mode](https://mastra.ai/docs/agents/code-mode): the agent writes one TypeScript program that calls the tools as `external_*` functions, instead of calling each tool in its own step. Use it when tasks fan out across many calls or providers, such as listing items in one provider and looking each one up in another.
151
+
152
+ ```typescript
153
+ import { Agent } from '@mastra/core/agent'
154
+ import { LocalSandbox } from '@mastra/core/workspace'
155
+ import { tools } from '@mastra/connect'
156
+
157
+ const code = tools({ providers: ['linear', 'slack'] }).codeMode({ sandbox: new LocalSandbox() })
158
+
159
+ export const opsAgent = new Agent({
160
+ id: 'ops',
161
+ name: 'ops',
162
+ instructions: async ctx => ['You help the team track work.', await code.instructions(ctx)],
163
+ model: 'openai/gpt-6-luna',
164
+ tools: code.tools,
165
+ })
166
+ ```
167
+
168
+ > **Warning:** `LocalSandbox` runs the model-written program as a host `node` process with host privileges. Connected tools return third-party data, such as issue text, that can influence the code the model writes. Use `LocalSandbox` only for trusted or local development. See [how Code Mode works](https://mastra.ai/docs/agents/code-mode) for isolated alternatives.
169
+
170
+ `codeMode()` returns two functions, `tools` and `instructions`. Pass both to the agent. Like the resolver, they resolve the current connections on every request. The functions the program can call change as providers are connected or disconnected. Within one request both use the same resolution, and the instructions never declare a function the program can't call.
171
+
172
+ The method accepts every [`createCodeMode()` option](https://mastra.ai/reference/tools/create-code-mode) except `tools` (`sandbox`, `timeout`, `id`), plus `transport` for a [remote sandbox](https://mastra.ai/docs/agents/code-mode) or [in-process isolation](https://mastra.ai/docs/agents/code-mode), and `toolSearch` for [tool search](#tool-search). Every resolver provides it, including the callback form and resolvers returned by `with()`. Extra tools from `with()` join the program's functions.
173
+
174
+ Some tools stay direct agent tools instead of program functions, because they pause the agent run and a call from inside a program can't:
175
+
176
+ - Tools that need approval through `requireApproval`. The agent still waits for the user to approve each call.
177
+ - The `request_connection` tool, so the connect prompt can still pause the run until the user connects.
178
+
179
+ For [MCP providers](#mcp-providers), a `requireApproval` list keeps **all** of that provider's tools direct, including the ones the list doesn't name. Mastra discovers MCP tools at request time and checks the list on each call, so Code Mode has no way to know in advance which calls need approval and keeps every tool from that provider out of the program. Generated HTTP tools work differently, because only the tools that match the list stay direct.
180
+
181
+ ```typescript
182
+ // Every neon-mcp tool stays direct, not just neon-mcp_run_sql
183
+ const ops = tools({
184
+ providers: { 'neon-mcp': { requireApproval: ['neon-mcp_run_sql'] } },
185
+ }).codeMode({ sandbox })
186
+ ```
187
+
188
+ To let a program call that provider's other tools, remove the gated tools with `disallowTools` instead of gating them. To keep them gated, accept that the agent calls the provider's tools one at a time.
189
+
190
+ When there is nothing to orchestrate, for example when the project has no connections yet, `tools` returns only the direct tools and `instructions` returns an empty string.
191
+
192
+ ### Tool search
193
+
194
+ Declaring every function in the instructions uses context on every request: about 4,000 tokens for Linear alone and over 20,000 for Linear, GitHub, and Stripe together. With tool search, the instructions list only the function names, and the agent gets a `search_functions` tool that returns the TypeScript declarations for the functions it needs. The agent searches by what it wants to do or by exact names from the list, then writes the program. The program can still call every function. Only the declarations move behind the search.
195
+
196
+ Tool search turns on by itself when declaring every function would take more than about 10,000 tokens. Set `toolSearch` to choose:
197
+
198
+ ```typescript
199
+ // Always list names only and search for declarations
200
+ const searching = tools().codeMode({ sandbox: new LocalSandbox(), toolSearch: true })
201
+
202
+ // Always declare every function up front
203
+ const declared = tools().codeMode({ sandbox: new LocalSandbox(), toolSearch: false })
204
+ ```
205
+
147
206
  ## Choosing providers
148
207
 
149
208
  The `providers` array form is an allowlist: only listed providers are returned. Without the option, every connected provider with a supported toolset is included. A listed provider with no connection in the project yet is skipped and included automatically once a connection is attached. In the record form, `false` excludes a provider and never errors, even for IDs that match nothing.
@@ -38,7 +38,7 @@ export const mastra = new Mastra({
38
38
 
39
39
  **builder** (`AgentBuilderOptions`): Agent Builder configuration. See the AgentBuilderOptions reference. Omit or set enabled: false to disable the Builder.
40
40
 
41
- **source** (`'code' | 'db'`): Where agent overrides are stored. With 'db', overrides live in the configured storage backend and Studio shows the save and publish flow. With 'code', overrides live as per-agent JSON files on disk (routed through a local FilesystemStore) and Studio shows filesystem actions. See Editor storage options for the difference. (Default: `'db'`)
41
+ **source** (`'code' | 'db'`): Where agent overrides are stored. With 'db', overrides live in the configured storage backend and Studio shows the save and publish flow. With 'code', overrides live as per-agent JSON files at codePath (routed through a local FilesystemStore) and Studio shows filesystem actions. When source is 'code' and a source-control provider is configured, agent overrides are persisted through source-control operations instead of the local filesystem, and the provider controls the repository path. A provider passed as sourceControlProvider uses its own pathPrefix; the provider created from environment variables uses MASTRA_SOURCE_STORAGE_PATH_PREFIX when it is set, and codePath otherwise. The environment provider is created only when MASTRA_SOURCE_PROVIDER is github, an endpoint is set (MASTRA_SOURCE_PROVIDER_ENDPOINT, MASTRA_SHARED_API_URL, or MASTRA_CLOUD_API_ENDPOINT), and a token is set (MASTRA_PLATFORM_ACCESS_TOKEN or MASTRA_CLOUD_ACCESS_TOKEN). Each list is checked in order and the first defined variable wins, so an empty higher-priority variable disables the provider instead of falling back. The endpoint is a Mastra platform API that brokers the GitHub operations, so the provider never calls the GitHub API directly. Without a provider, overrides stay in the local files at codePath. See Editor storage options for the difference. (Default: `'db'`)
42
42
 
43
43
  **codePath** (`string`): Directory used by the 'code' source for per-agent JSON files. Ignored when source is not 'code'. (Default: `'./mastra/editor'`)
44
44
 
@@ -330,6 +330,7 @@ The Reference section provides documentation of Mastra's API, including paramete
330
330
  - [.chunk()](https://mastra.ai/reference/rag/chunk)
331
331
  - [Overview](https://mastra.ai/reference/schedules/overview)
332
332
  - [createRoute()](https://mastra.ai/reference/server/create-route)
333
+ - [dispatchRoute()](https://mastra.ai/reference/server/dispatch-route)
333
334
  - [Elysia Adapter](https://mastra.ai/reference/server/elysia-adapter)
334
335
  - [Express Adapter](https://mastra.ai/reference/server/express-adapter)
335
336
  - [Fastify Adapter](https://mastra.ai/reference/server/fastify-adapter)