@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.
- package/.docs/docs/agents/resumable-streams.md +140 -0
- package/.docs/docs/agents/tools.md +2 -2
- package/.docs/docs/auth/overview.md +1 -0
- package/.docs/docs/auth/simple-auth.md +8 -8
- package/.docs/docs/channels.md +34 -1
- package/.docs/docs/connections/mcp.md +66 -1
- package/.docs/docs/guides/authentication-identity.md +4 -0
- package/.docs/docs/harness/background-tasks.md +2 -1
- package/.docs/docs/harness/durable-agents.md +6 -6
- package/.docs/docs/harness/goals.md +1 -1
- package/.docs/docs/harness/schedules.md +2 -0
- package/.docs/docs/knowledge/agents-and-tools.md +122 -0
- package/.docs/docs/knowledge/load-your-content.md +86 -0
- package/.docs/docs/knowledge/overview.md +106 -0
- package/.docs/docs/knowledge/patterns.md +167 -0
- package/.docs/docs/knowledge/pinned-context.md +177 -0
- package/.docs/docs/knowledge/scopes-and-access.md +202 -0
- package/.docs/docs/knowledge/search.md +63 -0
- package/.docs/docs/mastra-platform/connect.md +231 -0
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/memory/observational-memory.md +23 -23
- package/.docs/docs/memory/overview.md +19 -7
- package/.docs/docs/observability/tracing/overview.md +0 -2
- package/.docs/docs/server/custom-adapters.md +4 -0
- package/.docs/docs/server/request-context.md +6 -6
- package/.docs/docs/server/server-adapters.md +12 -12
- package/.docs/docs/signals/sending-signals.md +3 -1
- package/.docs/docs/studio/knowledge.md +45 -24
- package/.docs/docs/studio/overview.md +3 -1
- 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/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/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/voice/openai.md +40 -0
- package/.docs/integrations.md +40 -1
- package/.docs/models/gateways/custom-gateways.md +2 -0
- package/.docs/models/gateways/netlify.md +8 -3
- package/.docs/models/gateways/openrouter.md +7 -8
- package/.docs/models/gateways/vercel.md +418 -418
- package/.docs/models/index.md +46 -2
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/baseten.md +2 -1
- package/.docs/models/providers/chutes.md +2 -1
- package/.docs/models/providers/edenai.md +5 -9
- package/.docs/models/providers/empiriolabs.md +3 -3
- package/.docs/models/providers/hyper.md +7 -13
- package/.docs/models/providers/inceptron.md +3 -3
- package/.docs/models/providers/kilo.md +20 -25
- package/.docs/models/providers/llmgateway-providers.md +22 -10
- package/.docs/models/providers/llmgateway.md +5 -5
- package/.docs/models/providers/modular.md +6 -6
- package/.docs/models/providers/nano-gpt.md +18 -21
- package/.docs/models/providers/opencode-go.md +3 -1
- package/.docs/models/providers/opencode.md +3 -2
- package/.docs/models/providers/ovhcloud.md +1 -2
- package/.docs/models/providers/prime.md +1 -1
- 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 -2
- package/.docs/models/providers/togetherai.md +2 -1
- package/.docs/models/providers/wandb.md +5 -4
- package/.docs/reference/agents/agent.md +3 -1
- package/.docs/reference/agents/channels.md +38 -1
- package/.docs/reference/agents/durable-agent.md +37 -26
- package/.docs/reference/agents/generate.md +1 -1
- package/.docs/reference/agents/getLLM.md +1 -1
- package/.docs/reference/agents/getMetadata.md +1 -1
- package/.docs/reference/agents/getModel.md +4 -2
- package/.docs/reference/agents/getSkill.md +1 -1
- package/.docs/reference/agents/listScorers.md +1 -1
- package/.docs/reference/agents/listTools.md +1 -1
- package/.docs/reference/auth/better-auth.md +2 -2
- package/.docs/reference/auth/neon.md +24 -15
- package/.docs/reference/channels/slack-provider.md +1 -1
- package/.docs/reference/cli/mastra.md +10 -1
- package/.docs/reference/client-js/agents.md +4 -4
- package/.docs/reference/client-js/observability.md +90 -3
- package/.docs/reference/connect/channels.md +55 -1
- package/.docs/reference/connect/providers.md +5 -3
- package/.docs/reference/connect/tools.md +34 -3
- package/.docs/reference/core/addDynamicWorkflow.md +1 -1
- package/.docs/reference/core/addGateway.md +1 -1
- package/.docs/reference/core/getAgent.md +4 -2
- package/.docs/reference/core/getEditor.md +1 -1
- package/.docs/reference/core/getGateway.md +1 -1
- package/.docs/reference/core/getGatewayById.md +14 -1
- package/.docs/reference/core/getMemory.md +2 -2
- package/.docs/reference/core/getStorage.md +1 -1
- package/.docs/reference/core/listMemory.md +3 -3
- package/.docs/reference/core/listScorers.md +2 -2
- package/.docs/reference/core/listVectors.md +1 -1
- package/.docs/reference/evals/completeness.md +0 -1
- package/.docs/reference/evals/content-similarity.md +1 -3
- package/.docs/reference/evals/create-scorer.md +5 -3
- package/.docs/reference/evals/faithfulness.md +1 -1
- package/.docs/reference/evals/hallucination.md +2 -2
- package/.docs/reference/evals/noise-sensitivity.md +8 -1
- package/.docs/reference/evals/scorer-utils.md +1 -1
- package/.docs/reference/index.md +7 -0
- package/.docs/reference/knowledge/knowledge-class.md +296 -0
- package/.docs/reference/knowledge/knowledge-memory-scopes.md +78 -0
- package/.docs/reference/knowledge/knowledge-tools.md +299 -0
- package/.docs/reference/knowledge/limits.md +44 -0
- package/.docs/reference/knowledge/scope-declarations.md +275 -0
- package/.docs/reference/knowledge/tool-instructions.md +56 -0
- package/.docs/reference/logging/pino-logger.md +1 -1
- package/.docs/reference/memory/observational-memory.md +9 -7
- package/.docs/reference/observability/feedback.md +3 -1
- package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
- package/.docs/reference/processors/batch-parts-processor.md +0 -2
- package/.docs/reference/processors/message-history-processor.md +1 -1
- package/.docs/reference/processors/moderation-processor.md +1 -1
- package/.docs/reference/processors/semantic-recall-processor.md +1 -1
- package/.docs/reference/processors/stream-error-retry-processor.md +1 -1
- package/.docs/reference/processors/token-limiter-processor.md +1 -1
- package/.docs/reference/processors/tool-search-processor.md +1 -1
- package/.docs/reference/pubsub/redis-streams.md +2 -0
- package/.docs/reference/schedules/overview.md +3 -3
- package/.docs/reference/server/invoke-route.md +86 -0
- package/.docs/reference/server/koa-adapter.md +1 -1
- package/.docs/reference/server/routes.md +63 -0
- package/.docs/reference/streaming/ChunkType.md +3 -1
- package/.docs/reference/streaming/agents/MastraModelOutput.md +6 -4
- package/.docs/reference/streaming/agents/stream.md +1 -1
- package/.docs/reference/streaming/workflows/resumeStream.md +1 -1
- package/.docs/reference/tools/mcp-client.md +4 -0
- package/.docs/reference/tools/mcp-server.md +6 -2
- package/.docs/reference/tools/vector-query-tool.md +3 -3
- package/.docs/reference/workflows/run-methods/start.md +1 -1
- package/.docs/reference/workflows/run-methods/timeTravel.md +1 -1
- package/.docs/reference/workflows/workflow.md +2 -0
- package/.docs/reference/workspace/sandbox.md +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-BDrEqwuY.js → src-CwUXyWAK.js} +3 -3
- package/dist/src-CwUXyWAK.js.map +1 -0
- package/dist/stdio.js +1 -1
- package/dist/tools/embedded-docs.d.ts.map +1 -1
- package/package.json +4 -4
- 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/dist/src-BDrEqwuY.js.map +0 -1
|
@@ -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:
|
|
@@ -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
|
|
|
@@ -74,12 +74,16 @@ Each value in the `providers` record form is `true`, `false`, or a `ToolsProvide
|
|
|
74
74
|
|
|
75
75
|
### ConnectClientOptions
|
|
76
76
|
|
|
77
|
-
Every field falls back to an environment variable, so a fully env-configured app can pass nothing.
|
|
77
|
+
Every field except `fetch` and `resourceId` falls back to an environment variable. `fetch` defaults to `globalThis.fetch`, and `resourceId` has no fallback, so a fully env-configured app that doesn't scope calls to a resource can pass nothing.
|
|
78
78
|
|
|
79
79
|
**accessToken** (`string`): Platform access token. Falls back to MASTRA_PLATFORM_ACCESS_TOKEN, then MASTRA_PLATFORM_SECRET_KEY.
|
|
80
80
|
|
|
81
81
|
**orgId** (`string`): Organization ID. Falls back to MASTRA_ORG_ID; sent as the x-organization-id header when present.
|
|
82
82
|
|
|
83
|
+
**projectId** (`string`): Project ID, sent as the x-mastra-project-id header so the platform can attribute proxy activity to the project. Falls back to MASTRA_PROJECT_ID; the header is omitted when absent.
|
|
84
|
+
|
|
85
|
+
**resourceId** (`string`): End-user resource key the client acts for, sent as the x-mastra-resource-id header. Connection listings are scoped to global connections plus that resource's connections. Has no environment variable fallback.
|
|
86
|
+
|
|
83
87
|
**baseUrl** (`string`): Connect API base URL. Falls back to MASTRA_INTEGRATIONS_API_URL, then the regional default from MASTRA_PLATFORM_REGION (us or eu), then https\://integrations.mastra.ai.
|
|
84
88
|
|
|
85
89
|
**fetch** (`typeof globalThis.fetch`): Fetch implementation, for testing or custom transports. Defaults to globalThis.fetch.
|
|
@@ -104,7 +108,34 @@ The resolver also exposes methods for manual control:
|
|
|
104
108
|
|
|
105
109
|
- `refresh()` fetches from the platform immediately, then updates the cache and returns the tool record. Rejects if the platform fetch fails.
|
|
106
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.
|
|
107
|
-
- `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.
|
|
108
139
|
|
|
109
140
|
Error handling depends on the cause:
|
|
110
141
|
|
|
@@ -47,7 +47,7 @@ const result = await run.start({ inputData: { name: 'Ada' } })
|
|
|
47
47
|
|
|
48
48
|
## Returns
|
|
49
49
|
|
|
50
|
-
A promise that resolves once the definition is validated
|
|
50
|
+
A promise that resolves once the definition is validated and registered, and persisted when storage provides a `workflowDefinitions` store.
|
|
51
51
|
|
|
52
52
|
## Behavior
|
|
53
53
|
|
|
@@ -23,7 +23,7 @@ mastra.addGateway(new MyCustomGateway())
|
|
|
23
23
|
|
|
24
24
|
## Parameters
|
|
25
25
|
|
|
26
|
-
**gateway** (`
|
|
26
|
+
**gateway** (`MastraModelGatewayInterface`): The gateway instance to add
|
|
27
27
|
|
|
28
28
|
**key** (`string`): Optional registration key. If not provided, uses gateway.getId()
|
|
29
29
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Mastra.getAgent()
|
|
6
6
|
|
|
7
|
-
The `.getAgent()` method is used to retrieve an agent. The method accepts
|
|
7
|
+
The `.getAgent()` method is used to retrieve an agent. The method accepts the agent's name and an optional version selector. Passing a version selector returns a promise.
|
|
8
8
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
@@ -16,9 +16,11 @@ mastra.getAgent('testAgent')
|
|
|
16
16
|
|
|
17
17
|
**name** (`TAgentName extends keyof TAgents`): The name of the agent to retrieve. Must be a valid agent name that exists in the Mastra configuration.
|
|
18
18
|
|
|
19
|
+
**version** (`{ versionId: string } | { status?: 'draft' | 'published' }`): Selects a stored version of the agent. When provided, the method returns a promise.
|
|
20
|
+
|
|
19
21
|
## Returns
|
|
20
22
|
|
|
21
|
-
**agent** (`TAgents[TAgentName]
|
|
23
|
+
**agent** (`TAgents[TAgentName] | Promise<TAgents[TAgentName]>`): The agent instance with the specified name, or a promise that resolves to it when version is provided. Throws an error if the agent is not found.
|
|
22
24
|
|
|
23
25
|
## Related
|
|
24
26
|
|
|
@@ -31,7 +31,7 @@ This method doesn't accept any parameters.
|
|
|
31
31
|
|
|
32
32
|
## Returns
|
|
33
33
|
|
|
34
|
-
**editor** (`
|
|
34
|
+
**editor** (`IMastraEditor | undefined`): The configured editor instance, or undefined if no editor has been configured.
|
|
35
35
|
|
|
36
36
|
## Related
|
|
37
37
|
|
|
@@ -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
|
|
|
@@ -20,11 +20,11 @@ const thread = await memory.createThread({
|
|
|
20
20
|
|
|
21
21
|
## Parameters
|
|
22
22
|
|
|
23
|
-
**
|
|
23
|
+
**name** (`TMemoryName extends keyof TMemory`): The registry key of the memory instance to retrieve. Must match a key used when registering memory in the Mastra constructor.
|
|
24
24
|
|
|
25
25
|
## Returns
|
|
26
26
|
|
|
27
|
-
**memory** (`TMemory[
|
|
27
|
+
**memory** (`TMemory[TMemoryName]`): The memory instance with the specified key. Throws an error if the memory is not found.
|
|
28
28
|
|
|
29
29
|
## Example: Registering and retrieving memory
|
|
30
30
|
|
|
@@ -18,7 +18,7 @@ This method doesn't accept any parameters.
|
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
**storage** (`MastraCompositeStore | undefined`): The configured storage instance,
|
|
21
|
+
**storage** (`MastraCompositeStore | undefined`): The configured storage instance. When no storage is configured, Mastra uses a default InMemoryStore, which this method returns.
|
|
22
22
|
|
|
23
23
|
## Related
|
|
24
24
|
|
|
@@ -9,7 +9,7 @@ The `.listMemory()` method returns all memory instances registered with the Mast
|
|
|
9
9
|
## Usage example
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
const memoryInstances = mastra.listMemory()
|
|
12
|
+
const memoryInstances = mastra.listMemory() ?? {}
|
|
13
13
|
|
|
14
14
|
for (const [key, memory] of Object.entries(memoryInstances)) {
|
|
15
15
|
console.log(`Memory "${key}": ${memory.id}`)
|
|
@@ -22,7 +22,7 @@ This method takes no parameters.
|
|
|
22
22
|
|
|
23
23
|
## Returns
|
|
24
24
|
|
|
25
|
-
**memory** (`Record<string, MastraMemory
|
|
25
|
+
**memory** (`Record<string, MastraMemory> | undefined`): An object containing all registered memory instances, keyed by their registry keys.
|
|
26
26
|
|
|
27
27
|
## Example: Checking registered memory
|
|
28
28
|
|
|
@@ -49,7 +49,7 @@ const mastra = new Mastra({
|
|
|
49
49
|
})
|
|
50
50
|
|
|
51
51
|
// List all registered memory instances
|
|
52
|
-
const allMemory = mastra.listMemory()
|
|
52
|
+
const allMemory = mastra.listMemory() ?? {}
|
|
53
53
|
console.log(Object.keys(allMemory)) // ["conversationMemory", "analyticsMemory"]
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -15,7 +15,7 @@ import { mastra } from './mastra'
|
|
|
15
15
|
const allScorers = mastra.listScorers()
|
|
16
16
|
|
|
17
17
|
// Access a specific scorer
|
|
18
|
-
const myScorer = allScorers
|
|
18
|
+
const myScorer = allScorers?.relevancyScorer
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Parameters
|
|
@@ -24,7 +24,7 @@ This method takes no parameters.
|
|
|
24
24
|
|
|
25
25
|
## Returns
|
|
26
26
|
|
|
27
|
-
**scorers** (`Record<string, MastraScorer> | undefined`): An object containing all registered scorers, where keys are scorer names and values are MastraScorer instances. Returns
|
|
27
|
+
**scorers** (`Record<string, MastraScorer> | undefined`): An object containing all registered scorers, where keys are scorer names and values are MastraScorer instances. Returns an empty object if no scorers are registered.
|
|
28
28
|
|
|
29
29
|
## Related
|
|
30
30
|
|
|
@@ -18,7 +18,7 @@ This method doesn't accept any parameters.
|
|
|
18
18
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
|
-
**vectors** (`TVectors`): A record of all configured vector stores, where keys are vector store names and values are vector store instances.
|
|
21
|
+
**vectors** (`TVectors | undefined`): A record of all configured vector stores, where keys are vector store names and values are vector store instances.
|
|
22
22
|
|
|
23
23
|
## Related
|
|
24
24
|
|
|
@@ -47,7 +47,6 @@ The scorer extracts and analyzes several types of elements:
|
|
|
47
47
|
The extraction process includes:
|
|
48
48
|
|
|
49
49
|
- Normalization of text (removing diacritics, converting to lowercase)
|
|
50
|
-
- Splitting camelCase words
|
|
51
50
|
- Handling of word boundaries
|
|
52
51
|
- Special handling of short words (3 characters or less)
|
|
53
52
|
- Deduplication of elements
|
|
@@ -18,12 +18,10 @@ This function returns an instance of the MastraScorer class. See the [MastraScor
|
|
|
18
18
|
|
|
19
19
|
## `.run()` returns
|
|
20
20
|
|
|
21
|
-
**runId** (`string`): The id of the run
|
|
21
|
+
**runId** (`string`): The id of the run.
|
|
22
22
|
|
|
23
23
|
**preprocessStepResult** (`object`): Object with processed input and output: { processedInput: string, processedOutput: string }
|
|
24
24
|
|
|
25
|
-
**analyzeStepResult** (`object`): Object with similarity: { similarity: number }
|
|
26
|
-
|
|
27
25
|
**score** (`number`): Similarity score (0-1) where 1 indicates perfect similarity.
|
|
28
26
|
|
|
29
27
|
## Scoring details
|
|
@@ -268,7 +268,9 @@ The method can return any value. The returned value will be available to subsequ
|
|
|
268
268
|
|
|
269
269
|
**Required** step that computes the final numerical score.
|
|
270
270
|
|
|
271
|
-
**Function Mode:** Function: `({ run, results }) => number
|
|
271
|
+
**Function Mode:** Function: `({ run, results }) => number | NotScorable | Promise<number | NotScorable>`
|
|
272
|
+
|
|
273
|
+
Return [`notScorable()`](https://mastra.ai/reference/evals/not-scorable) instead of a number to finish the run without a score.
|
|
272
274
|
|
|
273
275
|
**run.input** (`any`): Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. \[{ role: 'user', content: 'hello world' }]. If the scorer is used in a workflow, this will be the input of the workflow.
|
|
274
276
|
|
|
@@ -282,8 +284,8 @@ The method can return any value. The returned value will be available to subsequ
|
|
|
282
284
|
|
|
283
285
|
**results.analyzeStepResult** (`any`): Result from analyze step, if defined (optional).
|
|
284
286
|
|
|
285
|
-
Returns: `number`\
|
|
286
|
-
|
|
287
|
+
Returns: `number | NotScorable`\
|
|
288
|
+
Return a numerical score, or `notScorable()` to finish the run without a score.
|
|
287
289
|
|
|
288
290
|
**Prompt Object Mode:**
|
|
289
291
|
|
|
@@ -10,7 +10,7 @@ The `createFaithfulnessScorer()` function evaluates how factually accurate an LL
|
|
|
10
10
|
|
|
11
11
|
The `createFaithfulnessScorer()` function accepts a single options object with the following properties:
|
|
12
12
|
|
|
13
|
-
**model** (`
|
|
13
|
+
**model** (`MastraModelConfig`): Configuration for the model used to evaluate faithfulness.
|
|
14
14
|
|
|
15
15
|
**options** (`{ context?: string[]; scale?: number }`): Configuration options for the scorer.
|
|
16
16
|
|
|
@@ -14,7 +14,7 @@ The `createHallucinationScorer()` function accepts a single options object with
|
|
|
14
14
|
|
|
15
15
|
**options** (`Options`): Configuration options.
|
|
16
16
|
|
|
17
|
-
**options.scale** (`number`): Maximum score value.
|
|
17
|
+
**options.scale** (`number`): Maximum score value. A value of 0 falls back to 1.
|
|
18
18
|
|
|
19
19
|
**options.context** (`string[]`): Static context strings to use as ground truth for hallucination detection.
|
|
20
20
|
|
|
@@ -65,7 +65,7 @@ The scorer evaluates hallucination through contradiction detection and unsupport
|
|
|
65
65
|
- Divides by total statements
|
|
66
66
|
- Scales to configured range
|
|
67
67
|
|
|
68
|
-
Final score: `min(1, hallucinated_statements / total_statements) * scale
|
|
68
|
+
Final score: `min(1, hallucinated_statements / total_statements) * (scale || 1)`, rounded to two decimal places, when `total_statements > 0`, otherwise `0`.
|
|
69
69
|
|
|
70
70
|
### Important Considerations
|
|
71
71
|
|
|
@@ -119,13 +119,20 @@ Checks if noise causes the agent to generate false or fabricated information tha
|
|
|
119
119
|
### Formula
|
|
120
120
|
|
|
121
121
|
```text
|
|
122
|
-
|
|
122
|
+
selected_score = |llm_score - calculated_score| > discrepancy_threshold
|
|
123
|
+
? min(llm_score, calculated_score)
|
|
124
|
+
: llm_score
|
|
125
|
+
|
|
126
|
+
Final Score = max(0, selected_score - issues_penalty)
|
|
123
127
|
```
|
|
124
128
|
|
|
129
|
+
The final score is rounded to two decimal places.
|
|
130
|
+
|
|
125
131
|
Where:
|
|
126
132
|
|
|
127
133
|
- `llm_score` = Direct robustness score from LLM analysis
|
|
128
134
|
- `calculated_score` = Average of impact weights across dimensions
|
|
135
|
+
- `discrepancy_threshold` = `scoring.discrepancyThreshold` (default `0.2`)
|
|
129
136
|
- `issues_penalty` = min(major_issues × penalty_rate, max_penalty)
|
|
130
137
|
|
|
131
138
|
### Impact Level Weights
|
|
@@ -189,7 +189,7 @@ Combines all system messages into a single prompt string, joined with double new
|
|
|
189
189
|
|
|
190
190
|
### `extractToolCalls`
|
|
191
191
|
|
|
192
|
-
Extracts information about
|
|
192
|
+
Extracts information about tool calls from the run output, excluding partial calls (`partial-call` state), including tool names, call IDs, and their positions in the message array.
|
|
193
193
|
|
|
194
194
|
```typescript
|
|
195
195
|
const toolUsageScorer = createScorer({
|
package/.docs/reference/index.md
CHANGED
|
@@ -223,6 +223,12 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
223
223
|
- [Tools](https://mastra.ai/reference/file-based-agents/tools)
|
|
224
224
|
- [Workflows](https://mastra.ai/reference/file-based-agents/workflows)
|
|
225
225
|
- [Workspace](https://mastra.ai/reference/file-based-agents/workspace)
|
|
226
|
+
- [Knowledge Class](https://mastra.ai/reference/knowledge/knowledge-class)
|
|
227
|
+
- [Knowledge Tools](https://mastra.ai/reference/knowledge/knowledge-tools)
|
|
228
|
+
- [knowledgeMemoryScopes()](https://mastra.ai/reference/knowledge/knowledge-memory-scopes)
|
|
229
|
+
- [Limits](https://mastra.ai/reference/knowledge/limits)
|
|
230
|
+
- [Scope declarations](https://mastra.ai/reference/knowledge/scope-declarations)
|
|
231
|
+
- [Tool instructions](https://mastra.ai/reference/knowledge/tool-instructions)
|
|
226
232
|
- [Cloned Thread Utilities](https://mastra.ai/reference/memory/clone-utilities)
|
|
227
233
|
- [Memory Class](https://mastra.ai/reference/memory/memory-class)
|
|
228
234
|
- [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
|
|
@@ -327,6 +333,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
327
333
|
- [Express Adapter](https://mastra.ai/reference/server/express-adapter)
|
|
328
334
|
- [Fastify Adapter](https://mastra.ai/reference/server/fastify-adapter)
|
|
329
335
|
- [Hono Adapter](https://mastra.ai/reference/server/hono-adapter)
|
|
336
|
+
- [invokeRoute()](https://mastra.ai/reference/server/invoke-route)
|
|
330
337
|
- [Koa Adapter](https://mastra.ai/reference/server/koa-adapter)
|
|
331
338
|
- [MastraServer](https://mastra.ai/reference/server/mastra-server)
|
|
332
339
|
- [NestJS Adapter](https://mastra.ai/reference/server/nestjs-adapter)
|