@mastra/mcp-docs-server 1.3.13-alpha.0 → 1.3.13-alpha.11
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/resumable-streams.md +140 -0
- package/.docs/docs/agents/tools.md +3 -2
- package/.docs/docs/auth/overview.md +1 -0
- package/.docs/docs/channels.md +34 -1
- package/.docs/docs/connections/mcp.md +34 -67
- package/.docs/docs/deployment/mastra-server.md +10 -2
- package/.docs/docs/deployment/workers.md +3 -1
- package/.docs/docs/harness/background-tasks.md +2 -1
- package/.docs/docs/harness/durable-agents.md +106 -8
- package/.docs/docs/harness/schedules.md +2 -0
- package/.docs/docs/mastra-platform/connect.md +231 -0
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/semantic-recall.md +26 -1
- package/.docs/docs/observability/feedback.md +5 -7
- package/.docs/docs/observability/integrations/exporters/mastra-storage.md +41 -0
- package/.docs/docs/observability/tracing/overview.md +0 -2
- package/.docs/docs/sandbox/skills.md +32 -3
- package/.docs/docs/server/custom-adapters.md +40 -11
- package/.docs/docs/server/middleware.md +1 -1
- package/.docs/docs/signals/sending-signals.md +3 -1
- package/.docs/docs/workflows/overview.md +12 -0
- package/.docs/docs/workflows/suspend-and-resume.md +1 -1
- package/.docs/integrations/agentic-ui/ai-sdk-ui.md +46 -0
- package/.docs/integrations/auth/clerk.md +46 -7
- package/.docs/integrations/auth/neon.md +217 -0
- package/.docs/integrations/auth/supabase.md +46 -7
- package/.docs/integrations/auth/workos.md +54 -15
- package/.docs/integrations/channels/discord.md +84 -6
- package/.docs/integrations/channels/github.md +63 -24
- package/.docs/integrations/channels/slack.md +89 -8
- package/.docs/integrations/channels/teams.md +79 -5
- package/.docs/integrations/channels/telegram.md +47 -6
- package/.docs/integrations/crm/attio.md +42 -0
- package/.docs/integrations/crm/clay.md +42 -0
- package/.docs/integrations/crm/hubspot.md +41 -0
- package/.docs/integrations/databases/neon.md +37 -1
- package/.docs/integrations/databases/postgresql.md +46 -0
- package/.docs/integrations/deploy/render.md +59 -18
- package/.docs/integrations/deploy/temporal.md +74 -0
- package/.docs/integrations/documents/google-docs.md +41 -0
- package/.docs/integrations/documents/google-sheet.md +41 -0
- package/.docs/integrations/documents/microsoft-excel.md +43 -0
- package/.docs/integrations/documents/microsoft-powerpoint.md +41 -0
- package/.docs/integrations/documents/microsoft-word.md +41 -0
- package/.docs/integrations/documents/notion.md +41 -0
- package/.docs/integrations/documents/one-drive.md +41 -0
- package/.docs/integrations/documents/sharepoint-online.md +41 -0
- package/.docs/integrations/email-calendar/google-calendar.md +41 -0
- package/.docs/integrations/email-calendar/google-mail.md +41 -0
- package/.docs/integrations/email-calendar/outlook.md +41 -0
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/google-drive.md +54 -15
- package/.docs/integrations/observability/arize.md +1 -1
- package/.docs/integrations/observability/posthog.md +50 -11
- package/.docs/integrations/other/canva.md +42 -0
- package/.docs/integrations/other/fireflies.md +41 -0
- package/.docs/integrations/other/incident-io.md +41 -0
- package/.docs/integrations/other/resend.md +43 -0
- package/.docs/integrations/other/robinhood.md +44 -0
- package/.docs/integrations/other/sanity.md +42 -0
- package/.docs/integrations/other/snowflake.md +41 -0
- package/.docs/integrations/project-management/jira.md +41 -0
- package/.docs/integrations/project-management/linear.md +41 -0
- package/.docs/integrations/sandboxes/docker.md +39 -0
- package/.docs/integrations/sandboxes/e2b.md +1 -1
- package/.docs/integrations/voice/openai.md +40 -0
- package/.docs/integrations.md +40 -1
- package/.docs/models/environment-variables.md +1 -1
- package/.docs/models/gateways/azure-openai.md +61 -2
- package/.docs/models/gateways/custom-gateways.md +2 -0
- package/.docs/models/gateways/merge-gateway.md +3 -1
- package/.docs/models/gateways/netlify.md +11 -7
- package/.docs/models/gateways/openrouter.md +13 -12
- package/.docs/models/gateways/requesty.md +221 -0
- package/.docs/models/gateways/vercel.md +423 -420
- package/.docs/models/gateways.md +7 -1
- package/.docs/models/index.md +46 -3
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/aihubmix.md +2 -0
- package/.docs/models/providers/amazon-bedrock.md +4 -0
- package/.docs/models/providers/anthropic.md +2 -1
- package/.docs/models/providers/azure.md +4 -0
- package/.docs/models/providers/chutes.md +6 -4
- package/.docs/models/providers/cloudflare-ai-gateway.md +2 -0
- package/.docs/models/providers/cloudflare-workers-ai.md +0 -13
- package/.docs/models/providers/cohere.md +2 -0
- package/.docs/models/providers/crossmodel.md +5 -1
- package/.docs/models/providers/deepinfra.md +2 -1
- package/.docs/models/providers/edenai.md +12 -13
- package/.docs/models/providers/empiriolabs.md +3 -3
- package/.docs/models/providers/fireworks-ai.md +30 -28
- package/.docs/models/providers/google-vertex.md +2 -0
- package/.docs/models/providers/google.md +4 -3
- package/.docs/models/providers/hyper.md +8 -14
- package/.docs/models/providers/inceptron.md +2 -2
- package/.docs/models/providers/kilo.md +34 -33
- package/.docs/models/providers/llmgateway-providers.md +448 -427
- package/.docs/models/providers/llmgateway.md +9 -5
- package/.docs/models/providers/meta.md +5 -4
- package/.docs/models/providers/morph.md +2 -1
- package/.docs/models/providers/nano-gpt.md +51 -57
- package/.docs/models/providers/novita-ai.md +4 -2
- package/.docs/models/providers/ollama-cloud.md +2 -1
- package/.docs/models/providers/ollama.md +2 -0
- package/.docs/models/providers/opencode-go.md +3 -1
- package/.docs/models/providers/opencode.md +11 -6
- package/.docs/models/providers/prime.md +4 -4
- package/.docs/models/providers/qvac.md +2 -0
- package/.docs/models/providers/tencent-token-plan.md +2 -1
- package/.docs/models/providers/tencent-tokenhub.md +2 -1
- package/.docs/models/providers/tinfoil.md +2 -1
- package/.docs/models/providers/wandb.md +4 -4
- package/.docs/models/providers.md +0 -1
- package/.docs/reference/agent-controller/agent-controller-class.md +4 -2
- package/.docs/reference/agent-controller/session.md +1 -1
- package/.docs/reference/agents/agent.md +2 -0
- package/.docs/reference/agents/channels.md +117 -1
- package/.docs/reference/agents/durable-agent.md +42 -29
- package/.docs/reference/ai-sdk/chat-route.md +33 -2
- package/.docs/reference/auth/neon.md +24 -15
- package/.docs/reference/build-with-ai.md +12 -2
- package/.docs/reference/cli/mastra.md +10 -1
- package/.docs/reference/client-js/agents.md +4 -4
- package/.docs/reference/client-js/observability.md +36 -6
- package/.docs/reference/code-sdk/mount-agent-controller.md +5 -1
- package/.docs/reference/connect/channels.md +55 -1
- package/.docs/reference/connect/credential.md +2 -1
- package/.docs/reference/connect/providers.md +5 -3
- package/.docs/reference/connect/tools.md +29 -2
- package/.docs/reference/core/getGatewayById.md +14 -1
- package/.docs/reference/core/mastra-class.md +1 -1
- package/.docs/reference/evals/create-scorer.md +3 -1
- package/.docs/reference/file-based-agents/tools.md +3 -3
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/memory-class.md +1 -1
- package/.docs/reference/observability/feedback.md +43 -14
- package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
- package/.docs/reference/observability/tracing/configuration.md +3 -0
- package/.docs/reference/observability/tracing/exporters/mastra-platform-exporter.md +51 -15
- package/.docs/reference/observability/tracing/exporters/mastra-storage-exporter.md +30 -0
- package/.docs/reference/observability/tracing/interfaces.md +2 -0
- package/.docs/reference/processors/processor-interface.md +24 -1
- package/.docs/reference/processors/semantic-recall-processor.md +7 -3
- package/.docs/reference/processors/skill-search-processor.md +3 -0
- package/.docs/reference/processors/skills-processor.md +84 -0
- package/.docs/reference/pubsub/lease-provider.md +4 -2
- package/.docs/reference/pubsub/redis-streams.md +3 -1
- package/.docs/reference/rag/graph-rag.md +2 -2
- package/.docs/reference/rag/rerank.md +1 -1
- package/.docs/reference/rag/rerankWithScorer.md +1 -1
- package/.docs/reference/streaming/agents/MastraModelOutput.md +13 -12
- package/.docs/reference/tools/mcp-client.md +26 -7
- package/.docs/reference/tools/mcp-server.md +6 -2
- package/.docs/reference/workers/overview.md +2 -2
- package/.docs/reference/workflows/run-methods/resume.md +1 -1
- package/.docs/reference/workflows/run.md +1 -1
- package/.docs/reference/workflows/workflow.md +1 -1
- package/.docs/reference/workspace/factory-sandbox.md +24 -8
- package/.docs/reference/workspace/platform-sandbox.md +22 -7
- package/.docs/reference/workspace/workspace-class.md +5 -5
- package/package.json +4 -5
- package/.docs/docs/mastra-platform/connect/channels.md +0 -165
- package/.docs/docs/mastra-platform/connect/overview.md +0 -102
- package/.docs/docs/mastra-platform/connect/providers.md +0 -66
- package/.docs/docs/mastra-platform/connect/tools.md +0 -151
- package/.docs/models/providers/requesty.md +0 -261
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# `MastraAuthNeon` and `MastraRBACNeon`
|
|
6
6
|
|
|
7
|
-
[`MastraAuthNeon`](https://github.com/mastra-ai/mastra/tree/main/auth/neon) connects Mastra authentication to [Neon Auth](https://neon.com/docs/guides/neon-auth). It
|
|
7
|
+
[`MastraAuthNeon`](https://github.com/mastra-ai/mastra/tree/main/auth/neon) connects Mastra authentication to [Neon Auth](https://neon.com/docs/guides/neon-auth). It verifies Neon Auth JWTs sent as bearer tokens with Neon Auth's JWKS endpoint and validates Neon Auth session cookies through its session API. The provider also supports email-and-password sign-in, sign-up, and session management.
|
|
8
8
|
|
|
9
9
|
`MastraRBACNeon` maps Neon Auth organization roles to Mastra permissions. Register it separately when your application uses Neon Auth organization memberships for role-based access control.
|
|
10
10
|
|
|
@@ -34,7 +34,9 @@ export const mastra = new Mastra({
|
|
|
34
34
|
})
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Set `NEON_AUTH_BASE_URL` to
|
|
37
|
+
Set `NEON_AUTH_BASE_URL` to the Neon Auth URL shown in the Neon Console, for example `https://ep-example-123456.neonauth.us-east-2.aws.neon.tech/neondb/auth`. You can also pass `baseUrl` directly to both constructors.
|
|
38
|
+
|
|
39
|
+
Visit the [Neon integration guide](https://mastra.ai/integrations/auth/neon) for setup steps.
|
|
38
40
|
|
|
39
41
|
## `MastraAuthNeon`
|
|
40
42
|
|
|
@@ -42,13 +44,13 @@ Set `NEON_AUTH_BASE_URL` to your Neon Auth service URL. You can also pass `baseU
|
|
|
42
44
|
|
|
43
45
|
The `MastraAuthNeon` constructor accepts an optional `MastraAuthNeonOptions` object.
|
|
44
46
|
|
|
45
|
-
**baseUrl** (`string`): Neon Auth
|
|
47
|
+
**baseUrl** (`string`): Neon Auth URL, including the database path (for example /neondb/auth). Falls back to the NEON_AUTH_BASE_URL environment variable. Trailing slashes are removed. The JWT issuer and audience must equal the origin of this URL.
|
|
46
48
|
|
|
47
|
-
**jwksUrl** (`string`): JWKS endpoint used to verify bearer tokens. Falls back to NEON_AUTH_JWKS_URL, then \<baseUrl
|
|
49
|
+
**jwksUrl** (`string`): JWKS endpoint used to verify bearer tokens. Falls back to NEON_AUTH_JWKS_URL, then \<baseUrl>/.well-known/jwks.json.
|
|
48
50
|
|
|
49
|
-
**sessionCookieName** (`string`): Name of the Neon Auth session cookie. Defaults to
|
|
51
|
+
**sessionCookieName** (`string`): Name of the Neon Auth session cookie. Defaults to \_\_Secure-neon-auth.session_token.
|
|
50
52
|
|
|
51
|
-
**signUpEnabled** (`boolean`): Whether credentials-based sign-up is enabled. Defaults to true.
|
|
53
|
+
**signUpEnabled** (`boolean`): Whether credentials-based sign-up is enabled. When false, signUp() throws and no Neon Auth account is created. Defaults to true.
|
|
52
54
|
|
|
53
55
|
**name** (`string`): Provider name. Defaults to neon.
|
|
54
56
|
|
|
@@ -74,7 +76,9 @@ The `MastraAuthNeon` constructor accepts an optional `MastraAuthNeonOptions` obj
|
|
|
74
76
|
await auth.authenticateToken(token, request)
|
|
75
77
|
```
|
|
76
78
|
|
|
77
|
-
Verifies
|
|
79
|
+
Verifies a JWT-shaped token against the configured JWKS endpoint, checking its signature, issuer, audience, and expiry. Otherwise, validates the Neon Auth session cookie from the request through the session API. If JWT verification fails, the session cookie is still accepted, so an expired bearer token doesn't sign out a client that also sends cookies. When the request has no session cookie, a non-JWT token is treated as the session cookie value. Returns the authenticated `NeonAuthUser`, or `null` when validation fails.
|
|
80
|
+
|
|
81
|
+
`NeonAuthUser` contains the top-level `id`, `email`, and `name`, the Neon Auth `user` object, and either the `session` (cookie authentication) or the verified `jwt` claims (bearer authentication).
|
|
78
82
|
|
|
79
83
|
#### `authorizeUser()`
|
|
80
84
|
|
|
@@ -92,7 +96,7 @@ Runs the configured custom authorization function when one is provided. Otherwis
|
|
|
92
96
|
const result = await auth.signIn(email, password, request)
|
|
93
97
|
```
|
|
94
98
|
|
|
95
|
-
Authenticates email-and-password credentials through Neon Auth. Returns the authenticated user,
|
|
99
|
+
Authenticates email-and-password credentials through Neon Auth. Returns the authenticated user, a Neon Auth JWT as `token`, and the Neon Auth session cookies. Neon Auth must trust the origin of the incoming request.
|
|
96
100
|
|
|
97
101
|
#### `signUp()`
|
|
98
102
|
|
|
@@ -100,7 +104,7 @@ Authenticates email-and-password credentials through Neon Auth. Returns the auth
|
|
|
100
104
|
const result = await auth.signUp(email, password, name, request)
|
|
101
105
|
```
|
|
102
106
|
|
|
103
|
-
Creates a Neon Auth account using email-and-password credentials. `name` is optional
|
|
107
|
+
Creates a Neon Auth account using email-and-password credentials. `name` is optional. When omitted, the provider derives a display name from the email address. Returns the same result as `signIn()`.
|
|
104
108
|
|
|
105
109
|
#### `isSignUpEnabled()`
|
|
106
110
|
|
|
@@ -139,10 +143,13 @@ Validates the session through Neon Auth. Neon Auth refreshes sessions automatica
|
|
|
139
143
|
#### `destroySession()`
|
|
140
144
|
|
|
141
145
|
```typescript
|
|
142
|
-
|
|
146
|
+
const sessionId = auth.getSessionIdFromRequest(request)
|
|
147
|
+
if (sessionId) await auth.destroySession(sessionId)
|
|
143
148
|
```
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
Pass the signed session cookie value from `getSessionIdFromRequest()`, not the `id` returned by `validateSession()`. `destroySession()` attempts to revoke that session through the Neon Auth sign-out endpoint. A network error or non-2xx response can leave the session active, and the method doesn't throw for these failures. When Mastra sends the header from `getClearSessionHeaders()`, it clears the matching cookie on the Mastra host, not a cookie on a separate Neon Auth host. A separate Neon Auth session can remain active after Studio sign-out.
|
|
151
|
+
|
|
152
|
+
Revoking a session doesn't invalidate an already-issued JWT. Bearer tokens that pass JWT verification can still authenticate because verification doesn't check the Neon Auth session. JWT verification doesn't require an expiration claim, so a token without one may remain usable after sign-out.
|
|
146
153
|
|
|
147
154
|
## `MastraRBACNeon`
|
|
148
155
|
|
|
@@ -152,11 +159,11 @@ The `MastraRBACNeon` constructor accepts a `MastraRBACNeonOptions` object.
|
|
|
152
159
|
|
|
153
160
|
**roleMapping** (`RoleMapping`): Maps Neon Auth role names to Mastra permission patterns. Use \_default to define permissions for unmapped roles.
|
|
154
161
|
|
|
155
|
-
**baseUrl** (`string`): Neon Auth
|
|
162
|
+
**baseUrl** (`string`): Neon Auth URL. Falls back to the NEON_AUTH_BASE_URL environment variable. Trailing slashes are removed.
|
|
156
163
|
|
|
157
|
-
**organizationId** (`string`):
|
|
164
|
+
**organizationId** (`string`): Organization whose membership role is used. Defaults to the active organization of the session.
|
|
158
165
|
|
|
159
|
-
**getUserRoles** (`(user: NeonAuthUser) => Promise<string[]> | string[]`): Custom function
|
|
166
|
+
**getUserRoles** (`(user: NeonAuthUser) => Promise<string[]> | string[]`): Custom function that returns role names for a user. Use it to assign roles to bearer JWT requests, which carry no organization roles.
|
|
160
167
|
|
|
161
168
|
**cache** (`{ ttlMs?: number; maxSize?: number }`): Role lookup cache configuration. The defaults are 60,000 ms and 1,000 entries.
|
|
162
169
|
|
|
@@ -168,7 +175,9 @@ The `MastraRBACNeon` constructor accepts a `MastraRBACNeonOptions` object.
|
|
|
168
175
|
const roles = await rbac.getRoles(user)
|
|
169
176
|
```
|
|
170
177
|
|
|
171
|
-
Returns roles from the configured `getUserRoles` function, the user's
|
|
178
|
+
Returns roles from the configured `getUserRoles` function when provided. Otherwise, when `organizationId` is set or the session has an active organization, returns the user's role in that organization, read from Neon Auth with the user's session cookie. Non-members get no roles. Without an organization, returns the user's Neon Auth role, such as `user` or `admin`.
|
|
179
|
+
|
|
180
|
+
Bearer JWT requests have no session, so they get no roles unless `getUserRoles` is provided. The JWT `role` claim (`authenticated`) is never used as a Mastra role.
|
|
172
181
|
|
|
173
182
|
#### `hasRole()`
|
|
174
183
|
|
|
@@ -18,9 +18,19 @@ Each `dist/docs` includes:
|
|
|
18
18
|
|
|
19
19
|
## Context files
|
|
20
20
|
|
|
21
|
-
Mastra provides a root [`llms.txt`](https://mastra.ai/llms.txt) file that contains an overview of all available documentation pages.
|
|
21
|
+
Mastra provides a root [`llms.txt`](https://mastra.ai/llms.txt) file that contains an overview of all available documentation pages.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
To load many pages in one request, use the `llms-full.txt` bundles. They contain the full Markdown of every page in sidebar order:
|
|
24
|
+
|
|
25
|
+
- [`/llms-full.txt`](https://mastra.ai/llms-full.txt): All documentation
|
|
26
|
+
- [`/docs/llms-full.txt`](https://mastra.ai/docs/llms-full.txt): Docs
|
|
27
|
+
- [`/models/llms-full.txt`](https://mastra.ai/models/llms-full.txt): Models
|
|
28
|
+
- [`/integrations/llms-full.txt`](https://mastra.ai/integrations/llms-full.txt): Integrations
|
|
29
|
+
- [`/reference/llms-full.txt`](https://mastra.ai/reference/llms-full.txt): Reference
|
|
30
|
+
|
|
31
|
+
The full bundle is large, so prefer a section bundle or individual pages when you only need part of the documentation.
|
|
32
|
+
|
|
33
|
+
Each documentation page also has its own `llms.txt` file. These files are streamlined markdown files. At the end of each docs page you'll find a link to the corresponding `llms.txt` file.
|
|
24
34
|
|
|
25
35
|
Add `/llms.txt` to any Mastra docs URL to access it. You can also request it by adding a `.md` extension to the end of the URL.
|
|
26
36
|
|
|
@@ -877,6 +877,8 @@ Manages authentication for Mastra platform. Credentials are stored in `~/.mastra
|
|
|
877
877
|
|
|
878
878
|
Opens a browser for login and stores the credentials locally.
|
|
879
879
|
|
|
880
|
+
When browser sign-in is needed and there's no interactive terminal (in CI, when input or output is piped, or in an agent's shell), the command first prints how to authenticate headless shells, then still waits for browser sign-in. On the same machine, you can run `mastra auth login` once in your own terminal so later commands reuse the saved session. In CI or on another machine, set `MASTRA_API_TOKEN` and `MASTRA_ORG_ID` instead. Create the token from a signed-in terminal with [`mastra auth tokens create`](#mastra-auth-tokens-create) or in the dashboard. If the browser sign-in wait times out, the command exits with status 1. If `MASTRA_API_TOKEN` is already set in a non-interactive shell, the command skips browser sign-in: it verifies the token and checks that an organization is selected (from `MASTRA_ORG_ID` or saved credentials), then exits with status 0. If either check fails, it exits with status 1 and names what's missing.
|
|
881
|
+
|
|
880
882
|
### `mastra auth logout`
|
|
881
883
|
|
|
882
884
|
Removes stored credentials. If `MASTRA_API_TOKEN` is still set in the environment, the CLI warns that it will continue to be used.
|
|
@@ -943,7 +945,7 @@ Connects a provider to the project. When the organization already has connection
|
|
|
943
945
|
|
|
944
946
|
OAuth providers open the provider's consent screen in your browser and print its URL if you need to open it manually. API key and Basic auth providers prompt for credentials in the terminal and verify them before completing the connection. Providers with other auth types open a hosted connect page. The command waits until the connection becomes active before exiting.
|
|
945
947
|
|
|
946
|
-
Credential prompts require an interactive terminal, even with `--yes`. Run the command outside CI or connect through the platform UI.
|
|
948
|
+
Credential prompts require an interactive terminal, even with `--yes`. Run the command outside CI or connect through the platform UI. Each provider's [integration page](https://mastra.ai/docs/mastra-platform/connect) lists its API key and permission requirements.
|
|
947
949
|
|
|
948
950
|
Once a new connection is active, the command offers to set a display name so you can tell connections to the same provider apart. It lists the provider's existing connections, suggests a name that doesn't collide with them, and asks for confirmation if the chosen name duplicates another connection's name. Leave the field blank to skip naming. Setting a display name requires the organization admin role; if naming fails, the connection remains active.
|
|
949
951
|
|
|
@@ -1266,6 +1268,13 @@ Errors are written to `stderr` as JSON and return a non-zero exit code:
|
|
|
1266
1268
|
}
|
|
1267
1269
|
```
|
|
1268
1270
|
|
|
1271
|
+
The exit code reflects whether the request succeeded, not the contents of the response:
|
|
1272
|
+
|
|
1273
|
+
- `0`: The server returned a successful response. This includes empty results and payloads that report existing state, such as a tool result saying a record already exists. A tool that returns an object with an `error` field still exits `0`, so check the `data` payload when the tool reports its own failures.
|
|
1274
|
+
- `1`: The request failed. This includes an unreachable server, invalid JSON input, a missing resource, or a tool that throws an error.
|
|
1275
|
+
|
|
1276
|
+
If the command reading the output exits early, as with `| head`, the exit code still reflects whether the request succeeded.
|
|
1277
|
+
|
|
1269
1278
|
### Target resolution
|
|
1270
1279
|
|
|
1271
1280
|
For runtime commands, the command resolves the target server in this order:
|
|
@@ -914,9 +914,9 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
914
914
|
})
|
|
915
915
|
```
|
|
916
916
|
|
|
917
|
-
####
|
|
917
|
+
#### Resumable streams for stored agents
|
|
918
918
|
|
|
919
|
-
Set `durable` to
|
|
919
|
+
Set `durable` to configure [resumable streams](https://mastra.ai/docs/agents/resumable-streams) on the hydrated plain agent. Pass `true` to enable streams, `false` to disable them, or an object to tune stream cleanup:
|
|
920
920
|
|
|
921
921
|
```typescript
|
|
922
922
|
const agent = await mastraClient.createStoredAgent({
|
|
@@ -927,11 +927,11 @@ const agent = await mastraClient.createStoredAgent({
|
|
|
927
927
|
provider: 'openai',
|
|
928
928
|
name: 'gpt-5.4',
|
|
929
929
|
},
|
|
930
|
-
durable: {
|
|
930
|
+
durable: { cleanupTimeoutMs: 0 },
|
|
931
931
|
})
|
|
932
932
|
```
|
|
933
933
|
|
|
934
|
-
Only serializable options are accepted
|
|
934
|
+
Only serializable options are accepted, with cache and pubsub inherited from the server's `Mastra` instance. Existing stored agents with `durable: true` also use this field for resumable streams only. To retain durable execution and checkpoint recovery, register a code agent wrapped with `createDurableAgent({ agent })`.
|
|
935
935
|
|
|
936
936
|
### `getStoredAgent()`
|
|
937
937
|
|
|
@@ -115,7 +115,7 @@ if (capabilities.spanAggregate) {
|
|
|
115
115
|
|
|
116
116
|
The request and response structure follows `aggregateTraces()`, with direct span predicates and span dimensions such as `spanType`, `name`, and `parentEntityName`. Token and cost measures belong to the span that recorded the usage and aren't added to parent spans. Check `capabilities.spanAggregate` before calling, and `capabilities.spanAggregateModelDimensions` before grouping or counting distinct values by `model` or `provider`. With an older adapter, those requests return `501`.
|
|
117
117
|
|
|
118
|
-
Both `aggregateTraces()` and `aggregateSpans()` accept `timeToFirstToken.*` and `timeToFirstChunk
|
|
118
|
+
Both `aggregateTraces()` and `aggregateSpans()` accept time to first token (TTFT) and time to first chunk (TTFC) measures, `timeToFirstToken.*` and `timeToFirstChunk.*`, when `capabilities.aggregateTimeToFirstMeasures` is `true`. Spans and traces without a recorded value are skipped, never counted as 0. See [Time to first chunk (TTFC)](https://mastra.ai/reference/observability/tracing/advanced-queries) and [Time to first token (TTFT)](https://mastra.ai/reference/observability/tracing/advanced-queries).
|
|
119
119
|
|
|
120
120
|
See [Aggregate spans](https://mastra.ai/reference/observability/tracing/advanced-queries) for selection, dimensions, per-span usage, and how to list the spans behind a group.
|
|
121
121
|
|
|
@@ -371,11 +371,17 @@ const result = await mastraClient.deleteTraces({
|
|
|
371
371
|
traceIds: ['trace-1', 'trace-2'],
|
|
372
372
|
})
|
|
373
373
|
|
|
374
|
-
|
|
374
|
+
if ('accepted' in result) {
|
|
375
|
+
console.log('Deletion requested')
|
|
376
|
+
} else {
|
|
377
|
+
console.log(result.success)
|
|
378
|
+
}
|
|
375
379
|
```
|
|
376
380
|
|
|
377
381
|
Each request accepts up to 1,000 trace IDs and no tenant scope fields. Signals that aren't linked to a trace are preserved. Traces created by experiments are deleted like any other trace.
|
|
378
382
|
|
|
383
|
+
The client supports two response shapes: OSS returns `{ success: true }` after its delete operation, while a Platform backend that supports queued batch deletion returns `202 { accepted: true }` after accepting cleanup. Acceptance doesn't mean records have disappeared from reads, so check the response before reporting deletion as complete. Using these client methods with Platform requires a deployment that supports the batch deletion endpoints.
|
|
384
|
+
|
|
379
385
|
## Scoring traces
|
|
380
386
|
|
|
381
387
|
Score specific traces using registered scorers for evaluation:
|
|
@@ -403,6 +409,16 @@ const scores = await mastraClient.listScoresBySpan({
|
|
|
403
409
|
})
|
|
404
410
|
```
|
|
405
411
|
|
|
412
|
+
## Get a score by ID
|
|
413
|
+
|
|
414
|
+
Use `getScore()` to retrieve one observability score:
|
|
415
|
+
|
|
416
|
+
```typescript
|
|
417
|
+
const { score } = await mastraClient.getScore('score-id-123')
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
The response is `{ score: record | null }`. A missing score returns HTTP 200 with `{ score: null }`. The return type is `GetScoreResponse`, exported from `@mastra/client-js`.
|
|
421
|
+
|
|
406
422
|
## Creating scores
|
|
407
423
|
|
|
408
424
|
Create a score for a trace, optionally identifying a span within it:
|
|
@@ -422,7 +438,19 @@ const response = await mastraClient.createScore({
|
|
|
422
438
|
|
|
423
439
|
## Feedback
|
|
424
440
|
|
|
425
|
-
Feedback methods create, list, and query human-in-the-loop signals such as ratings, thumbs, comments, and corrections through the configured API server. Create methods support OSS and Platform. Full replacement
|
|
441
|
+
Feedback methods create, list, and query human-in-the-loop signals such as ratings, thumbs, comments, and corrections through the configured API server. Create methods support OSS and Platform. Full replacement is supported by Platform and OSS servers with feedback replacement support. See the [feedback guide](https://mastra.ai/docs/observability/feedback) for examples and the [feedback reference](https://mastra.ai/reference/observability/feedback) for full schemas.
|
|
442
|
+
|
|
443
|
+
### Get feedback by ID
|
|
444
|
+
|
|
445
|
+
Use `getFeedback()` to retrieve one feedback record:
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
const { feedback } = await mastraClient.getFeedback('feedback-id-123')
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
The response is `{ feedback: record | null }`. A missing record returns HTTP 200 with `{ feedback: null }`. The return type is `GetFeedbackResponse`, exported from `@mastra/client-js`.
|
|
452
|
+
|
|
453
|
+
Both getters accept an unencoded ID and encode it as a URL path segment. They use the client's configured API prefix, credentials, and headers. Record timestamps are ISO strings in the JSON response.
|
|
426
454
|
|
|
427
455
|
### Creating feedback
|
|
428
456
|
|
|
@@ -470,9 +498,9 @@ Create responses contain `success` and optional `data` with the generated or sup
|
|
|
470
498
|
|
|
471
499
|
Explicit modes require server support. Older servers may ignore `contextMode`. Deploy Platform's supplied-context support before sending `"provided"` there.
|
|
472
500
|
|
|
473
|
-
### Replacing feedback
|
|
501
|
+
### Replacing feedback
|
|
474
502
|
|
|
475
|
-
`replaceFeedback()` sends a full replacement to `PUT /api/observability/feedback/:feedbackId`. Include the original `feedbackId`, `traceId`, and normalized `timestamp`, along with all feedback fields to retain.
|
|
503
|
+
`replaceFeedback()` sends a full replacement to `PUT /api/observability/feedback/:feedbackId`. Include the original `feedbackId`, `traceId`, and normalized `timestamp`, along with all feedback fields to retain. Platform and OSS servers with feedback replacement support accept this method. OSS returns `501` when its storage adapter doesn't support replacement. For OSS, check `capabilities.feedbackReplacement` before offering edits. A missing capability means unavailable.
|
|
476
504
|
|
|
477
505
|
```typescript
|
|
478
506
|
await mastraClient.replaceFeedback({
|
|
@@ -487,7 +515,7 @@ await mastraClient.replaceFeedback({
|
|
|
487
515
|
})
|
|
488
516
|
```
|
|
489
517
|
|
|
490
|
-
Use the normalized timestamp from the create response's `data` when available.
|
|
518
|
+
Use the normalized timestamp from the create response's `data` when available. OSS rejects changes to the original trace or timestamp with `409`. Platform uses the timestamp as part of record identity, so preserve it there too. The client preserves the replacement body across retries, but each accepted PUT retry is a new replacement and can supersede another edit. Pass `{ retries: 0, anchorRetryTimeoutMs: 0 }` as the second argument to disable automatic retries.
|
|
491
519
|
|
|
492
520
|
### Deleting feedback and scores
|
|
493
521
|
|
|
@@ -507,6 +535,8 @@ await mastraClient.deleteScores({
|
|
|
507
535
|
})
|
|
508
536
|
```
|
|
509
537
|
|
|
538
|
+
Both methods return `{ success: boolean }` from OSS or `{ accepted: true }` from a Platform backend that supports queued batch deletion. See [Deleting traces](#deleting-traces) for response handling. Accepted records can remain readable until cleanup runs. Platform uses authenticated organization/project scope, which request-body scope fields can't override.
|
|
539
|
+
|
|
510
540
|
### Listing feedback
|
|
511
541
|
|
|
512
542
|
Retrieve paginated feedback records with optional filters:
|
|
@@ -74,7 +74,11 @@ const { controller } = await mountAgentControllerOnMastra({ mastra })
|
|
|
74
74
|
|
|
75
75
|
**disableBuiltinTools** (`BuiltinToolId[]`): Agent controller built-in tools (for example, 'submit_plan') removed from every session. Tool guidance skips disabled tools, and plan mode writes the plan file instead of calling 'submit_plan' when it's disabled.
|
|
76
76
|
|
|
77
|
-
**storage** (`StorageConfig`): Custom storage config instead of the auto-detected default.
|
|
77
|
+
**storage** (`StorageConfig | MastraCompositeStore`): Custom storage config instead of the auto-detected default, or a pre-built store instance. An injected instance has no connection test or LibSQL fallback. In both cases the SDK wraps the store: scorer results are discarded unless disableScoreStorage is false, and local observability goes to a separate DuckDB store only when local tracing is enabled and that store opens; otherwise local observability is disabled. Cloud export runs independently when cloud credentials are configured.
|
|
78
|
+
|
|
79
|
+
**storageBackend** (`'libsql' | 'pg'`): Backend of an injected storage instance. Inferred for LibSQLStore and PostgresStore; required for any other injected store, otherwise mounting throws.
|
|
80
|
+
|
|
81
|
+
**vector** (`MastraVector`): Pre-built vector store for recall search. Skips creating the default vector store. When storage is a pre-built instance, no default vector store is created, so pass vector to keep semantic recall search; without it, recall still browses history but can't search semantically.
|
|
78
82
|
|
|
79
83
|
**workspace** (`AgentControllerConfig["workspace"]`): Override the workspace. (Default: `local filesystem + local sandbox based on the detected project`)
|
|
80
84
|
|
|
@@ -18,7 +18,7 @@ export const mastra = new Mastra({
|
|
|
18
18
|
|
|
19
19
|
Returns: `Promise<ChannelsResolver>`. See [The resolver](#the-resolver).
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
Each provider's integration page covers its channel setup: [Slack](https://mastra.ai/integrations/channels/slack), [Telegram](https://mastra.ai/integrations/channels/telegram), [Discord](https://mastra.ai/integrations/channels/discord), and [Microsoft Teams](https://mastra.ai/integrations/channels/teams). Their implementations come from `@mastra/slack`, `@mastra/telegram`, `@mastra/discord`, and `@mastra/teams`, loaded on demand. Use those packages directly to configure a channel outside the platform connection flow.
|
|
22
22
|
|
|
23
23
|
The Teams provider encrypts stored bot secrets with `MASTRA_ENCRYPTION_KEY` when set. When it isn't, the key is derived from the platform access token and a warning is logged while a Teams connection is active. Rotating the platform access token makes stored bot credentials unreadable (disconnect and reconnect to re-provision). Projects without a Teams connection are unaffected.
|
|
24
24
|
|
|
@@ -62,6 +62,60 @@ Providers without an active connection don't appear in the resolved map. Their r
|
|
|
62
62
|
|
|
63
63
|
Failure handling matches [`tools()`](https://mastra.ai/reference/connect/tools): configuration errors (missing project ID, bad `ttlMs`, an unknown or malformed provider ID, both spellings of the Slack key) reject at call time, while per-provider problems (provider construction failure, `needs_reauth`, credential sync failure) are downgraded to warn-and-skip. Several active connections for one provider aren't a skip: the resolver warns and uses the first, and `providers.<id>.connectionId` pins the choice. The initial resolution rejects if its platform fetch fails. A failed background refresh warns and preserves the cached snapshot, while an explicit `refresh()` rejects on fetch failure.
|
|
64
64
|
|
|
65
|
+
## Combine with self-managed channels
|
|
66
|
+
|
|
67
|
+
`channels()` replaces the whole `channels` option, and there is no built-in helper to merge it with providers you construct yourself. To use Connect for some channels and manage another yourself, wrap both in one resolver. The wrapper must stay callable and expose a `getRoutes()` that returns every provider's routes, because Mastra mounts channel routes once at construction:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Mastra } from '@mastra/core'
|
|
71
|
+
import { channels } from '@mastra/connect'
|
|
72
|
+
import { TelegramProvider } from '@mastra/telegram'
|
|
73
|
+
import { assistant } from './agents/assistant'
|
|
74
|
+
|
|
75
|
+
const connectChannels = await channels({ providers: ['slack', 'discord'] })
|
|
76
|
+
const telegram = new TelegramProvider()
|
|
77
|
+
|
|
78
|
+
export const mastra = new Mastra({
|
|
79
|
+
agents: { assistant },
|
|
80
|
+
channels: Object.assign(async () => ({ ...(await connectChannels()), telegram }), {
|
|
81
|
+
getRoutes: () => [...connectChannels.getRoutes(), ...telegram.getRoutes()],
|
|
82
|
+
}),
|
|
83
|
+
})
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Exclude the self-managed channel from the Connect selection, as the array form does here. Mastra doesn't detect two providers that register the same route, so a channel enabled in both places mounts conflicting webhooks. Create the self-managed provider once, outside the wrapper: Mastra attaches each distinct provider instance only once. Configure its credentials as described in the [Telegram provider reference](https://mastra.ai/reference/channels/telegram-provider).
|
|
87
|
+
|
|
88
|
+
## Vary tools by channel
|
|
89
|
+
|
|
90
|
+
Channel messages put a [`ChannelContext`](https://mastra.ai/integrations/channels/slack) on the [request context](https://mastra.ai/docs/server/request-context) under the `channel` key. It includes the platform, whether the conversation is a direct message (`isDM`), channel and thread IDs, and the sender's user ID and name. An agent's `tools` function can read it to filter the record that [`tools()`](https://mastra.ai/reference/connect/tools) resolves:
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Agent } from '@mastra/core/agent'
|
|
94
|
+
import type { ChannelContext } from '@mastra/core/channels'
|
|
95
|
+
import { tools } from '@mastra/connect'
|
|
96
|
+
|
|
97
|
+
const connectTools = tools({ providers: ['linear'] })
|
|
98
|
+
const readTools = new Set(['linear_list_issues'])
|
|
99
|
+
|
|
100
|
+
export const assistant = new Agent({
|
|
101
|
+
id: 'assistant',
|
|
102
|
+
name: 'assistant',
|
|
103
|
+
instructions: 'You help the team track work in Linear from Slack and Discord.',
|
|
104
|
+
model: 'openai/gpt-6-luna',
|
|
105
|
+
tools: async ctx => {
|
|
106
|
+
const channel = ctx.requestContext?.get('channel') as ChannelContext | undefined
|
|
107
|
+
const all = await connectTools(ctx)
|
|
108
|
+
|
|
109
|
+
if (channel?.isDM && ctx.requestContext?.get('role') === 'operator') {
|
|
110
|
+
return all
|
|
111
|
+
}
|
|
112
|
+
return Object.fromEntries(Object.entries(all).filter(([key]) => readTools.has(key)))
|
|
113
|
+
},
|
|
114
|
+
})
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Here, only direct messages from users your application identifies as operators get the full Linear toolset. Other requests get only `linear_list_issues`. Set `role` in trusted server-side code after you verify the sender's identity and permissions. Don't grant write access based on conversation type alone. To filter by options instead of post-processing, see [per-request options](https://mastra.ai/reference/connect/tools).
|
|
118
|
+
|
|
65
119
|
## Discord permissions
|
|
66
120
|
|
|
67
121
|
The Discord bot-invite URL requests the `bot` and `applications.commands` scopes with these permissions:
|
|
@@ -42,7 +42,7 @@ Most applications should prefer [`tools()`](https://mastra.ai/reference/connect/
|
|
|
42
42
|
|
|
43
43
|
**connectionId** (`string`): ID of the connection to fetch credentials for.
|
|
44
44
|
|
|
45
|
-
**options** (`{ client?: ConnectClientOptions }`): Optional platform client overrides (accessToken, orgId, baseUrl, fetch
|
|
45
|
+
**options** (`{ client?: ConnectClientOptions; resourceId?: string }`): Optional platform client overrides (accessToken, orgId, baseUrl, fetch; see ConnectClientOptions in tools()) and the end-user resourceId. Pass resourceId when the connection is scoped to an end user. The value is trimmed and must be 1-256 characters, otherwise invalid_options is thrown before any request is sent. The value is sent as the x-mastra-resource-id header, takes precedence over client.resourceId, and the platform returns not found for a resource-scoped connection when it's missing or doesn't match.
|
|
46
46
|
|
|
47
47
|
## Credential handling
|
|
48
48
|
|
|
@@ -56,6 +56,7 @@ Throws `MastraConnectError` with a `code` property:
|
|
|
56
56
|
|
|
57
57
|
| Code | When |
|
|
58
58
|
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `invalid_options` | An option is invalid, for example an empty `resourceId` or one longer than 256 characters after trimming |
|
|
59
60
|
| `missing_access_token` | No platform token configured |
|
|
60
61
|
| `connection_not_found` | The connection doesn't exist or isn't accessible |
|
|
61
62
|
| `unsupported_credential_type` | The connection's credential type can't be returned |
|
|
@@ -8,7 +8,7 @@ This page documents generated toolsets for 28 providers (1076 tools in this vers
|
|
|
8
8
|
|
|
9
9
|
Tool keys are stable identifiers of the form `<provider>_<action>` and are the values accepted by `allowTools` and `disallowTools`. Toolsets are versioned with the package: the exact list depends on the installed `@mastra/connect` version, and this page reflects the version it was generated from.
|
|
10
10
|
|
|
11
|
-
MCP providers (Attio, Canva, Clay, Neon, Render, Robinhood, and Sanity) serve their tools from their hosted MCP servers at runtime and aren't listed here. See [MCP providers](https://mastra.ai/
|
|
11
|
+
MCP providers ([Attio](https://mastra.ai/integrations/crm/attio), [Canva](https://mastra.ai/integrations/other/canva), [Clay](https://mastra.ai/integrations/crm/clay), [Neon](https://mastra.ai/integrations/databases/neon), [Render](https://mastra.ai/integrations/deploy/render), [Robinhood](https://mastra.ai/integrations/other/robinhood), and [Sanity](https://mastra.ai/integrations/other/sanity)) serve their tools from their hosted MCP servers at runtime and aren't listed here. See [MCP providers](https://mastra.ai/reference/connect/tools) for how `tools()` discovers them.
|
|
12
12
|
|
|
13
13
|
| Provider | Provider ID | Tools |
|
|
14
14
|
| ----------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----- |
|
|
@@ -30,9 +30,9 @@ MCP providers (Attio, Canva, Clay, Neon, Render, Robinhood, and Sanity) serve th
|
|
|
30
30
|
|  [Microsoft Teams](#microsoft-teams) | `microsoft-teams` | 25 |
|
|
31
31
|
|  [Microsoft Word](#microsoft-word) | `microsoft-word` | 18 |
|
|
32
32
|
|  [Notion](#notion) | `notion` | 44 |
|
|
33
|
-
| [OneDrive](#onedrive)
|
|
33
|
+
|  [OneDrive](#onedrive) | `one-drive` | 20 |
|
|
34
34
|
|  [OpenAI](#openai) | `openai` | 26 |
|
|
35
|
-
|  [Microsoft Outlook](#microsoft-outlook) | `outlook` | 30 |
|
|
36
36
|
|  [PostHog](#posthog) | `posthog` | 67 |
|
|
37
37
|
|  [Resend](#resend) | `resend` | 80 |
|
|
38
38
|
|  [SharePoint Online](#sharepoint-online) | `sharepoint-online` | 53 |
|
|
@@ -1010,6 +1010,8 @@ Provider ID: `posthog` · 67 tools
|
|
|
1010
1010
|
|
|
1011
1011
|
Provider ID: `resend` · 80 tools
|
|
1012
1012
|
|
|
1013
|
+
> **Note:** Connect Resend with an API key that has **Full access** permission. A **Sending access** key fails to connect because Mastra checks a new key by listing your domains, which sending access keys can't do.
|
|
1014
|
+
|
|
1013
1015
|
| Tool | Description |
|
|
1014
1016
|
| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1015
1017
|
| `resend_add_contact_to_segment` | Add a contact to a segment in Resend. |
|
|
@@ -21,7 +21,7 @@ export const opsAgent = new Agent({
|
|
|
21
21
|
|
|
22
22
|
Returns: `ToolsResolver`, a resolver producing a flat tool record keyed by tool key (for example `linear_create_issue`). See [The resolver](#the-resolver).
|
|
23
23
|
|
|
24
|
-
See [Connect](https://mastra.ai/docs/mastra-platform/connect
|
|
24
|
+
See [Connect](https://mastra.ai/docs/mastra-platform/connect) to get started.
|
|
25
25
|
|
|
26
26
|
## Parameters
|
|
27
27
|
|
|
@@ -108,7 +108,34 @@ The resolver also exposes methods for manual control:
|
|
|
108
108
|
|
|
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
|
-
- `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 [
|
|
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
|
+
|
|
113
|
+
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
|
+
```typescript
|
|
116
|
+
import { Agent } from '@mastra/core/agent'
|
|
117
|
+
import { tools } from '@mastra/connect'
|
|
118
|
+
|
|
119
|
+
const connectTools = tools({ providers: ['linear'] })
|
|
120
|
+
const viewerTools = new Set(['linear_list_issues'])
|
|
121
|
+
|
|
122
|
+
export const opsAgent = new Agent({
|
|
123
|
+
id: 'ops',
|
|
124
|
+
name: 'ops',
|
|
125
|
+
instructions: 'You help the team track work in Linear.',
|
|
126
|
+
model: 'openai/gpt-6-luna',
|
|
127
|
+
tools: async ctx => {
|
|
128
|
+
const all = await connectTools(ctx)
|
|
129
|
+
|
|
130
|
+
if (ctx.requestContext?.get('role') === 'admin') {
|
|
131
|
+
return all
|
|
132
|
+
}
|
|
133
|
+
return Object.fromEntries(Object.entries(all).filter(([key]) => viewerTools.has(key)))
|
|
134
|
+
},
|
|
135
|
+
})
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Only the `admin` role gets every tool. Any other or missing role gets the viewer subset. Set `role` in trusted server-side code based on the authenticated user. [Vary tools by channel](https://mastra.ai/reference/connect/channels) applies the same pattern to channel messages.
|
|
112
139
|
|
|
113
140
|
Error handling depends on the cause:
|
|
114
141
|
|
|
@@ -34,7 +34,20 @@ console.log(gateway.name) // 'My Custom Gateway'
|
|
|
34
34
|
|
|
35
35
|
## Returns
|
|
36
36
|
|
|
37
|
-
**gateway** (`
|
|
37
|
+
**gateway** (`MastraModelGatewayInterface`): The gateway instance
|
|
38
|
+
|
|
39
|
+
## Throws
|
|
40
|
+
|
|
41
|
+
Throws a `MastraError` with ID `MASTRA_GET_GATEWAY_BY_ID_NOT_FOUND` if no registered gateway has the specified ID. Wrap the call in `try`/`catch` when the gateway might not be registered:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
let gateway
|
|
45
|
+
try {
|
|
46
|
+
gateway = mastra.getGatewayById('my-custom-gateway')
|
|
47
|
+
} catch {
|
|
48
|
+
// Gateway is not registered
|
|
49
|
+
}
|
|
50
|
+
```
|
|
38
51
|
|
|
39
52
|
## Related
|
|
40
53
|
|
|
@@ -137,7 +137,7 @@ Visit the [Configuration reference](https://mastra.ai/reference/configuration) f
|
|
|
137
137
|
|
|
138
138
|
**recovery** (`MastraRecoveryConfig`): Boot-time recovery behavior for orphaned agent and workflow runs. See Crash recovery. (Default: `{ durableAgents: 'off', workflows: 'auto', workflowConcurrency: 5 }`)
|
|
139
139
|
|
|
140
|
-
**recovery.durableAgents** (`'auto' | 'off'`): Set to 'auto' to automatically re-drive orphaned RUNNING durable agent runs on server boot. This also controls the default snapshot-persistence policy for durable agents: running checkpoints are only written when set to 'auto' (or when an agent sets a custom shouldPersistSnapshot that includes running). Recovery
|
|
140
|
+
**recovery.durableAgents** (`'auto' | 'off'`): Set to 'auto' to automatically re-drive orphaned RUNNING durable agent runs on server boot. This also controls the default snapshot-persistence policy for durable agents: running checkpoints are only written when set to 'auto' (or when an agent sets a custom shouldPersistSnapshot that includes running). Recovery can run an interrupted tool call again and request a new model response in place of one that wasn't saved, so tools must be idempotent. See make tools safe to repeat.
|
|
141
141
|
|
|
142
142
|
**recovery.workflows** (`'auto' | 'off'`): Set to 'off' to skip restarting active workflow runs on server boot. Individual workflows can also opt out with autoRestartActiveRuns: false.
|
|
143
143
|
|
|
@@ -45,7 +45,9 @@ const scorer = createScorer({
|
|
|
45
45
|
|
|
46
46
|
**judge.model** (`LanguageModel`): The LLM model instance to use for evaluation.
|
|
47
47
|
|
|
48
|
-
**judge.instructions** (`
|
|
48
|
+
**judge.instructions** (`SystemMessage | ({ requestContext: RequestContext }) => SystemMessage | Promise<SystemMessage>`): System instructions for the LLM. Can be a string, array of strings, system message object, array of system messages, or a function that returns any of these types.
|
|
49
|
+
|
|
50
|
+
**judge.requestContext** (`RequestContext`): Values available to the judge's dynamic instructions, tools, and processors. Values from the run's requestContext override these values. scorer.run doesn't pass reserved Mastra keys or MastraMemory from the run to the judge, because they could put the judge on the caller's memory thread or give it credentials such as the auth token. To give the judge a reserved key, set it on this option. Only the scorer-level judge accepts this option.
|
|
49
51
|
|
|
50
52
|
**judge.jsonPromptInjection** (`boolean | 'system' | 'inline' | 'auto'`): Controls how the judge's structured output schema reaches the model. Defaults to 'auto', which uses native structured output when supported and inline prompt injection otherwise. Explicit values override automatic routing.
|
|
51
53
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Tools
|
|
6
6
|
|
|
7
|
-
A file-based agent discovers tools from `.ts` and `.js` files directly under its `tools/` directory. Each discovered file is imported at build time
|
|
7
|
+
A file-based agent discovers tools from `.ts` and `.js` files directly under its `tools/` directory. Each discovered file is imported at build time and must default-export a tool. Any tool an agent's `tools` option accepts works, such as a [`createTool()`](https://mastra.ai/reference/tools/create-tool) result or a Vercel AI SDK `tool()`. The filename without its extension becomes the tool key the model can call.
|
|
8
8
|
|
|
9
9
|
Use this page for the file-based convention. For tool schemas, execution options, output shaping, and approval options, see the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool).
|
|
10
10
|
|
|
@@ -46,14 +46,14 @@ Because nested directories aren't discovered as tools, group related tools with
|
|
|
46
46
|
|
|
47
47
|
## Tool options
|
|
48
48
|
|
|
49
|
-
The file-based convention only controls where the tool lives and how it's registered.
|
|
49
|
+
The file-based convention only controls where the tool lives and how it's registered. Options come from the tool itself. For tools built with `createTool()`:
|
|
50
50
|
|
|
51
51
|
- Use `description` to tell the model when to call the tool.
|
|
52
52
|
- Use `inputSchema` and `outputSchema` for structured inputs and outputs.
|
|
53
53
|
- Use `toModelOutput` when the model should see a different shape than the raw value returned from `execute`.
|
|
54
54
|
- Use `requireApproval` when a tool needs human confirmation before execution.
|
|
55
55
|
|
|
56
|
-
See the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool) for all options and [tool approval](https://mastra.ai/docs/harness/agent-controller) for the approval flow.
|
|
56
|
+
See the [`createTool()` reference](https://mastra.ai/reference/tools/create-tool) for all options and [tool approval](https://mastra.ai/docs/harness/agent-controller) for the approval flow. Vercel AI SDK tools use the [AI SDK `tool()` API](https://ai-sdk.dev/docs/reference/ai-sdk-core/tool) instead.
|
|
57
57
|
|
|
58
58
|
## Runtime boundary
|
|
59
59
|
|
package/.docs/reference/index.md
CHANGED
|
@@ -296,6 +296,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
296
296
|
- [ResponseCache](https://mastra.ai/reference/processors/response-cache)
|
|
297
297
|
- [SemanticRecall](https://mastra.ai/reference/processors/semantic-recall-processor)
|
|
298
298
|
- [SkillSearchProcessor](https://mastra.ai/reference/processors/skill-search-processor)
|
|
299
|
+
- [SkillsProcessor](https://mastra.ai/reference/processors/skills-processor)
|
|
299
300
|
- [StreamErrorRetryProcessor](https://mastra.ai/reference/processors/stream-error-retry-processor)
|
|
300
301
|
- [SystemPromptScrubber](https://mastra.ai/reference/processors/system-prompt-scrubber)
|
|
301
302
|
- [TokenCostControl](https://mastra.ai/reference/processors/token-cost-control)
|
|
@@ -49,7 +49,7 @@ export const agent = new Agent({
|
|
|
49
49
|
|
|
50
50
|
**options.retainFullInput** (`boolean`): When true, the request input is processed exactly as supplied instead of being filtered against stored history. Use this when you assemble the input yourself and need the message sequence preserved. Stored history is still loaded underneath, and every input message that isn't already stored is saved to the thread, including few-shot examples. Can be set per call on memory.options or agent-wide in the memory constructor options.
|
|
51
51
|
|
|
52
|
-
**options.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires a vector store, and an embedder unless the vector store embeds text itself (isSelfEmbedding). Default topK is 4, default messageRange is {before: 1, after: 1}.
|
|
52
|
+
**options.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource'; maxChunkChars?: number }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires a vector store, and an embedder unless the vector store embeds text itself (isSelfEmbedding). Default topK is 4, default messageRange is {before: 1, after: 1}. maxChunkChars caps the characters of message text per embedded chunk; see Long messages.
|
|
53
53
|
|
|
54
54
|
**options.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be { enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' } or { enabled: boolean } to disable.
|
|
55
55
|
|