@mastra/mcp-docs-server 1.3.13-alpha.8 → 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.
- package/.docs/docs/agents/code-mode.md +4 -0
- package/.docs/docs/agents/tools.md +10 -2
- package/.docs/docs/auth/custom-auth-provider.md +66 -0
- package/.docs/docs/auth/jwt.md +1 -1
- package/.docs/docs/connections/mcp.md +11 -71
- package/.docs/docs/evals/overview.md +4 -0
- package/.docs/docs/harness/durable-agents.md +36 -0
- package/.docs/docs/harness/schedules.md +1 -1
- package/.docs/docs/memory/multi-user-threads.md +57 -127
- package/.docs/docs/memory/observational-memory.md +196 -756
- package/.docs/docs/memory/overview.md +4 -0
- package/.docs/docs/memory/semantic-recall.md +2 -0
- package/.docs/docs/observability/feedback.md +5 -7
- package/.docs/docs/sandbox/overview.md +2 -0
- package/.docs/docs/sandbox/search.md +25 -0
- package/.docs/docs/server/mcp.md +315 -0
- package/.docs/docs/server/request-context.md +35 -0
- package/.docs/docs/studio/deployment.md +0 -1
- package/.docs/docs/studio/overview.md +4 -4
- package/.docs/docs/workflows/scheduled-workflows.md +26 -5
- package/.docs/integrations/deploy/temporal.md +74 -0
- package/.docs/integrations/sandboxes/docker.md +39 -0
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/voice/openai.md +2 -2
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/azure-openai.md +61 -2
- package/.docs/models/gateways/custom-gateways.md +74 -44
- package/.docs/models/gateways/requesty.md +221 -0
- package/.docs/models/gateways.md +7 -1
- package/.docs/models/index.md +0 -1
- package/.docs/models/providers/aihubmix.md +2 -0
- package/.docs/models/providers/amazon-bedrock.md +4 -0
- package/.docs/models/providers/azure.md +4 -0
- package/.docs/models/providers/cloudflare-ai-gateway.md +2 -0
- package/.docs/models/providers/cohere.md +2 -0
- package/.docs/models/providers/google-vertex.md +2 -0
- package/.docs/models/providers/ollama.md +2 -0
- package/.docs/models/providers/qvac.md +2 -0
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/generateLegacy.md +7 -23
- package/.docs/reference/auth/jwt.md +26 -2
- package/.docs/reference/cli/mastra.md +74 -6
- package/.docs/reference/client-js/observability.md +13 -5
- package/.docs/reference/configuration.md +64 -0
- package/.docs/reference/connect/tools.md +59 -0
- package/.docs/reference/editor/mastra-editor.md +1 -1
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/observational-memory.md +350 -151
- package/.docs/reference/observability/feedback.md +57 -14
- package/.docs/reference/observability/tracing/advanced-queries.md +3 -1
- package/.docs/reference/observability/tracing/exporters/langfuse.md +24 -1
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +19 -16
- package/.docs/reference/observability/tracing/exporters/otel.md +1 -1
- package/.docs/reference/observability/tracing/interfaces.md +2 -2
- package/.docs/reference/observability/tracing/spans.md +7 -1
- package/.docs/reference/processors/processor-interface.md +23 -0
- package/.docs/reference/processors/semantic-recall-processor.md +2 -0
- package/.docs/reference/rag/chunk.md +1 -1
- package/.docs/reference/rag/graph-rag-guide.md +3 -1
- package/.docs/reference/rag/graph-rag.md +1 -1
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/rag/rerankWithScorer.md +1 -1
- package/.docs/reference/schedules/overview.md +25 -5
- package/.docs/reference/server/dispatch-route.md +124 -0
- package/.docs/reference/server/elysia-adapter.md +1 -1
- package/.docs/reference/server/express-adapter.md +17 -11
- package/.docs/reference/server/fastify-adapter.md +1 -1
- package/.docs/reference/server/hono-adapter.md +1 -1
- package/.docs/reference/server/invoke-route.md +10 -0
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/nestjs-adapter.md +1 -1
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/tools/mcp-client.md +11 -1
- package/.docs/reference/workspace/factory-sandbox.md +20 -1
- package/.docs/reference/workspace/platform-sandbox.md +1 -1
- package/package.json +5 -5
- package/.docs/models/providers/requesty.md +0 -261
|
@@ -720,6 +720,70 @@ export const mastra = new Mastra({
|
|
|
720
720
|
})
|
|
721
721
|
```
|
|
722
722
|
|
|
723
|
+
### server.mcp
|
|
724
|
+
|
|
725
|
+
**Type:** `object`\
|
|
726
|
+
**Default:** `undefined`
|
|
727
|
+
|
|
728
|
+
Configures the [built-in MCP server](https://mastra.ai/docs/server/mcp) that exposes your agents, workflows, and tools at `/api/mcp`.
|
|
729
|
+
|
|
730
|
+
| Property | Type | Default | Description |
|
|
731
|
+
| ------------ | ----------------------------------------------------------------------------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
732
|
+
| `enabled` | `boolean \| 'dev'` | `'dev'` | `'dev'` serves the endpoint under `mastra dev`, and in production only when `server.auth` is configured. `true` always serves it and logs a warning when no auth is configured. `false` never serves it. |
|
|
733
|
+
| `path` | `string` | `'/mcp'` | Path of the endpoint, mounted under the API prefix. Each segment can use letters, digits, `-`, `.`, `_`, and `~`. Invalid paths and paths that collide with the `MCPServer` routes or any other server route fall back to `/mcp` and log an error. |
|
|
734
|
+
| `toolsets` | `('agents' \| 'workflows' \| 'tools' \| 'memory' \| 'observability' \| 'observability_analytics' \| 'stored_agents')[]` | All toolsets | Toolsets to serve. Clients can narrow this per request with `?toolsets=` or the `X-MCP-Toolsets` header. |
|
|
735
|
+
| `enumLimit` | `number` | `25` | Up to this many visible agents or workflows are listed as an enum on the id argument, and up to this many tools get an individual `tool_<id>` tool. |
|
|
736
|
+
| `featured` | `{ agents?: string[]; workflows?: string[] }` | `undefined` | Agents and workflows that also get a dedicated `agent_<id>` or `workflow_<id>` tool. |
|
|
737
|
+
| `readOnly` | `boolean` | `false` | Only serve tools whose backing route is a read operation. Clients can also request this with `?readonly=1` or the `X-MCP-Readonly` header. |
|
|
738
|
+
| `include` | `{ agents?: string[]; workflows?: string[]; tools?: string[] }` | `undefined` | When set for a primitive type, only these are exposed. Each entry matches a primitive's `id` or its registration key. |
|
|
739
|
+
| `exclude` | `{ agents?: string[]; workflows?: string[]; tools?: string[] }` | `undefined` | Never exposed. Each entry matches a primitive's `id` or its registration key. Takes precedence over `include`. |
|
|
740
|
+
| `serverInfo` | `{ name?: string; version?: string; title?: string; instructions?: string }` | `undefined` | Server identity reported to MCP clients. |
|
|
741
|
+
| `oauth` | `{ resource?: string; requireAudience?: boolean; authorizationServers?: string[]; scopesSupported?: string[] }` | `undefined` | OAuth discovery and token audience settings. See [`server.mcp.oauth`](#servermcpoauth). |
|
|
742
|
+
|
|
743
|
+
```typescript
|
|
744
|
+
import { Mastra } from '@mastra/core'
|
|
745
|
+
|
|
746
|
+
export const mastra = new Mastra({
|
|
747
|
+
server: {
|
|
748
|
+
mcp: {
|
|
749
|
+
featured: { agents: ['support-agent'] },
|
|
750
|
+
exclude: { tools: ['delete-account'] },
|
|
751
|
+
},
|
|
752
|
+
},
|
|
753
|
+
})
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
### server.mcp.oauth
|
|
757
|
+
|
|
758
|
+
**Type:** `object`\
|
|
759
|
+
**Default:** `undefined`
|
|
760
|
+
|
|
761
|
+
OAuth protected-resource metadata for the [built-in MCP server](https://mastra.ai/docs/server/mcp). Used when `server.auth` is configured.
|
|
762
|
+
|
|
763
|
+
| Property | Type | Default | Description |
|
|
764
|
+
| ---------------------- | ---------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
765
|
+
| `resource` | `string` | Endpoint URL derived from the request | Canonical public URL of the MCP endpoint, for example `https://my-app.example.com/api/mcp`. Setting it also requires the token's `aud` claim to include this URL on `/api/mcp`, for auth providers that support audience checks. |
|
|
766
|
+
| `requireAudience` | `boolean` | `false` | Requires `resource`. Rejects MCP requests with a `401` when the auth provider that accepted the token can't check the audience, including such providers inside `CompositeAuth`. When `false`, those requests are accepted and Mastra logs a warning at startup. |
|
|
767
|
+
| `authorizationServers` | `string[]` | From the auth provider | Issuer URLs of the authorization servers that MCP clients get tokens from. |
|
|
768
|
+
| `scopesSupported` | `string[]` | From the auth provider | OAuth scopes advertised to MCP clients. Left out of the metadata when unset. |
|
|
769
|
+
|
|
770
|
+
```typescript
|
|
771
|
+
import { Mastra } from '@mastra/core'
|
|
772
|
+
import { MastraJwtAuth } from '@mastra/auth'
|
|
773
|
+
|
|
774
|
+
export const mastra = new Mastra({
|
|
775
|
+
server: {
|
|
776
|
+
auth: new MastraJwtAuth({
|
|
777
|
+
jwksUri: 'https://auth.example.com/.well-known/jwks.json',
|
|
778
|
+
issuer: 'https://auth.example.com/',
|
|
779
|
+
}),
|
|
780
|
+
mcp: {
|
|
781
|
+
oauth: { resource: 'https://my-app.example.com/api/mcp' },
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
})
|
|
785
|
+
```
|
|
786
|
+
|
|
723
787
|
### server.mcpOptions
|
|
724
788
|
|
|
725
789
|
**Type:** `object`\
|
|
@@ -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
|
|
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
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -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)
|