@mastra/mcp-docs-server 1.3.14 → 1.3.15-alpha.1
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/knowledge/overview.md +1 -1
- package/.docs/docs/knowledge/patterns.md +2 -2
- package/.docs/docs/knowledge/scopes-and-access.md +11 -1
- package/.docs/docs/knowledge/search.md +1 -1
- package/.docs/docs/memory/observational-memory.md +1 -1
- package/.docs/models/gateways/mastra.md +1 -1
- package/.docs/models/index.md +26 -0
- package/.docs/reference/agent-controller/session.md +11 -0
- package/.docs/reference/client-js/agent-controller.md +4 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Knowledge gives agents a shared, organized place for information that lives outside any one conversation: policies, product docs, conventions, runbooks and what other agents have learned. Agents search, read and write it with tools. Pages you pin reach the agent's context through [signals](https://mastra.ai/docs/signals/overview) and stay current while it runs.
|
|
10
10
|
|
|
11
|
-
> **Alpha:** Knowledge is in alpha. Its API may change between releases.
|
|
11
|
+
> **Alpha:** Knowledge is in alpha. Its API may change between releases. Each scope's data is kept separate, but an agent with access to more than one scope can leak content between them. Give each agent only the scopes it needs, as [Keep scopes apart](https://mastra.ai/docs/knowledge/scopes-and-access) explains. Knowledge has no built-in importers yet, but you can [write content through its API](https://mastra.ai/docs/knowledge/load-your-content), and Mastra Platform offers importers. Knowledge can't expire old pages yet.
|
|
12
12
|
|
|
13
13
|
## What Knowledge is
|
|
14
14
|
|
|
@@ -8,7 +8,7 @@ These patterns show what you can build with Knowledge. Each one says who the age
|
|
|
8
8
|
|
|
9
9
|
> **Alpha:** Knowledge is in alpha. Its API may change between releases.
|
|
10
10
|
|
|
11
|
-
> **Warning:**
|
|
11
|
+
> **Warning:** Give each agent only the scopes its pattern needs. Knowledge has no guardrails yet against an agent leaking content between scopes it can access, so give one agent more than one scope only when that's acceptable. See [Keep scopes apart](https://mastra.ai/docs/knowledge/scopes-and-access).
|
|
12
12
|
|
|
13
13
|
## Answer from your own docs
|
|
14
14
|
|
|
@@ -51,7 +51,7 @@ await agent.generate(message, {
|
|
|
51
51
|
})
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
A Globex user's search for "renewal" doesn't return `tenant:acme#renewals`, because the run doesn't hold `tenant:acme`. The prompt has nothing to do with it. With Memory on the agent, the `resource:` and `thread:` scopes also tell Memory which user and thread the run is. Test the rules with [`explainAccess()`](https://mastra.ai/docs/knowledge/scopes-and-access).
|
|
54
|
+
A Globex user's search for "renewal" doesn't return `tenant:acme#renewals`, because the run doesn't hold `tenant:acme`. The prompt has nothing to do with it. With Memory on the agent, the `resource:` and `thread:` scopes also tell Memory which user and thread the run is. Test the rules with [`explainAccess()`](https://mastra.ai/docs/knowledge/scopes-and-access). An agent with both `tenant:acme` and `tenant:globex` could leak Acme's content into a Globex page, so use a separate agent for each tenant when they must stay apart.
|
|
55
55
|
|
|
56
56
|
## A policy every agent follows
|
|
57
57
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Scopes control what an agent can see and change in Knowledge. You decide what each kind of scope allows. Your server decides which scopes each run, or agent call, holds. The model works only with the pages and notes those scopes give it, and it can't change either decision.
|
|
8
8
|
|
|
9
|
-
> **Alpha:** Knowledge is in alpha. Its API may change between releases.
|
|
9
|
+
> **Alpha:** Knowledge is in alpha. Its API may change between releases. To keep one customer's data away from another's, read [Keep scopes apart](#keep-scopes-apart).
|
|
10
10
|
|
|
11
11
|
## Declare scopes
|
|
12
12
|
|
|
@@ -197,6 +197,16 @@ describe('team access', () => {
|
|
|
197
197
|
|
|
198
198
|
> **Warning:** Use `explainAccess()` only in server code. It shows whether a page is missing or hidden, and a run must never learn that. Don't expose it through an agent tool, or through a server route without admin-level auth.
|
|
199
199
|
|
|
200
|
+
## Keep scopes apart
|
|
201
|
+
|
|
202
|
+
Give each agent only the scopes its task needs, and understand what it means to give one agent more than one.
|
|
203
|
+
|
|
204
|
+
Knowledge keeps each scope's data separate. Every time an agent calls a Knowledge tool, Knowledge checks which scopes the agent has access to. An agent never sees pages or notes in scopes it can't reach. Agents working for different customers can't see each other's data, as long as two things hold. First, your server gives each run only its own customer's scopes and Memory IDs. Knowledge trusts the scopes and `memory` IDs your code passes, so authenticate the customer before you [set them](#set-a-runs-scopes). Second, every [access rule](#access-rules-and-roles) gives a customer's principal roles only on that customer's own scopes. Check each rule's principal and the scopes it applies to, and test the rules for each customer.
|
|
205
|
+
|
|
206
|
+
Knowledge has no guardrails yet against an agent leaking content between scopes it can access. Suppose an agent has access to `team:acme:support` and `resource:dana`. It can read a page in Dana's private scope and quote it in a team page. Each step is allowed on its own, and Knowledge can't tell that together they leak Dana's page.
|
|
207
|
+
|
|
208
|
+
Give one agent more than one scope only when it's acceptable for content to move between them. When scopes must stay apart, such as two tenants or two customers, use a separate agent for each.
|
|
209
|
+
|
|
200
210
|
## Next steps
|
|
201
211
|
|
|
202
212
|
Next, [give an agent the Knowledge tools](https://mastra.ai/docs/knowledge/agents-and-tools) so it can search, read and write in the scopes its runs hold.
|
|
@@ -39,7 +39,7 @@ export const knowledge = new Knowledge({
|
|
|
39
39
|
|
|
40
40
|
Pass both or neither. [`embedderOptions`](https://mastra.ai/reference/knowledge/knowledge-class) works the same way it does in Memory.
|
|
41
41
|
|
|
42
|
-
`knowledge_search` then merges keyword and meaning results by rank, so a close meaning match can come before a name match. Every semantic hit is read again with the run's access before it can take a place in the results, so hits the run can't read are dropped and don't take a slot.
|
|
42
|
+
`knowledge_search` then merges keyword and meaning results by rank, so a close meaning match can come before a name match. Every semantic hit is read again with the run's access before it can take a place in the results, so hits the run can't read are dropped and don't take a slot. Search checks at most 1,000 semantic candidates, though, so when most close matches are unreadable, readable ones further down can be missed.
|
|
43
43
|
|
|
44
44
|
Pages and notes are embedded when they're written. Scope pages aren't embedded, but notes on them are. Long pages are embedded in parts, and search still returns each page once. See [Limits](https://mastra.ai/reference/knowledge/limits) for the sizes.
|
|
45
45
|
|
|
@@ -38,7 +38,7 @@ yarn add @mastra/memory@latest @mastra/libsql@latest
|
|
|
38
38
|
bun add @mastra/memory@latest @mastra/libsql@latest
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
OM needs storage that supports it (`@mastra/libsql`, `@mastra/pg`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex` or `@mastra/
|
|
41
|
+
OM needs storage that supports it (`@mastra/libsql`, `@mastra/pg`, `@mastra/mysql`, `@mastra/mongodb`, `@mastra/convex`, `@mastra/oracledb` or `@mastra/mssql`), a thread for every call, and `observationalMemory: true`. This script stores memory in a local LibSQL file and calls the agent twice on one thread:
|
|
42
42
|
|
|
43
43
|
```typescript
|
|
44
44
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -10,7 +10,7 @@ Learn more in the [Gateway documentation](https://gateway.mastra.ai/docs).
|
|
|
10
10
|
|
|
11
11
|
## Get an API key
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Sign in to the [Mastra platform dashboard](https://projects.mastra.ai) and create a Gateway API key for your organization. Credits, spend limits, and billing for the Gateway are managed in the same dashboard.
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
package/.docs/models/index.md
CHANGED
|
@@ -398,6 +398,32 @@ Other keys behave differently unless they match the key from the `id`:
|
|
|
398
398
|
|
|
399
399
|
Options under a key that doesn't apply are dropped without a warning. If an option has no effect on the request, check the key first.
|
|
400
400
|
|
|
401
|
+
### Set `maxOutputTokens` for other models on an Anthropic-compatible endpoint
|
|
402
|
+
|
|
403
|
+
When a model that isn't Claude runs behind an Anthropic-compatible endpoint, the bundled Anthropic provider doesn't recognize its ID and caps each response at 4,096 output tokens. A reasoning model can spend that whole budget thinking and stop before it writes any text. The agent then fails with "The model stopped because it reached its maximum output length before finishing."
|
|
404
|
+
|
|
405
|
+
Set `maxOutputTokens` to the limit your model supports:
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
409
|
+
import { Agent } from "@mastra/core/agent";
|
|
410
|
+
|
|
411
|
+
const provider = createAnthropic({
|
|
412
|
+
baseURL: "https://your-anthropic-compatible-endpoint.com/v1",
|
|
413
|
+
apiKey: process.env.MY_PROVIDER_API_KEY,
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
const agent = new Agent({
|
|
417
|
+
id: "my-agent",
|
|
418
|
+
name: "My Agent",
|
|
419
|
+
instructions: "You are a helpful assistant",
|
|
420
|
+
model: provider("my-reasoning-model"),
|
|
421
|
+
defaultOptions: {
|
|
422
|
+
modelSettings: { maxOutputTokens: 32000 },
|
|
423
|
+
},
|
|
424
|
+
})
|
|
425
|
+
```
|
|
426
|
+
|
|
401
427
|
## Use AI SDK with Mastra
|
|
402
428
|
|
|
403
429
|
Mastra supports AI SDK provider modules, should you need to use them directly.
|
|
@@ -90,6 +90,17 @@ unsubscribe()
|
|
|
90
90
|
|
|
91
91
|
Returns: `() => void`
|
|
92
92
|
|
|
93
|
+
#### `initialStateEvents()`
|
|
94
|
+
|
|
95
|
+
Return what a subscriber joining mid-run is missing, as ordinary events the session never emits itself. The list holds a `message_start` for the reply in flight, the latest `om_status` for the active thread, and a `usage_update` whose `total` is the thread's token total. Deliver them to the joining subscriber right before calling `subscribe()`, in the same synchronous block, so no live event lands between the two.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
for (const event of session.initialStateEvents()) send(event)
|
|
99
|
+
const unsubscribe = session.subscribe(send)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Returns: `AgentControllerEvent[]`
|
|
103
|
+
|
|
93
104
|
### Messages and run control
|
|
94
105
|
|
|
95
106
|
#### `sendMessage({ content, files?, requestContext?, author? })`
|
|
@@ -126,6 +126,8 @@ Subscribes to the session's event stream over SSE. The promise resolves once the
|
|
|
126
126
|
|
|
127
127
|
**idleTimeoutMs** (`number`): Treats the stream as dropped after this many milliseconds without receiving any data. Server heartbeats, sent every 25 seconds, reset the timer, so only a silent connection, such as one left half-open by laptop sleep or a proxy timeout, trips it. A timeout is handled like any other drop: it triggers reconnect and onReconnect when reconnect is enabled, otherwise onError. Also bounds opening the stream: subscribe() rejects, and a reconnect attempt counts as failed, when no response arrives in time. Set to 0 to disable. (Default: `60000`)
|
|
128
128
|
|
|
129
|
+
**displayState** (`boolean`): Set to false to receive no display_state_changed snapshots, including the one that opens the stream. The stream then opens with the session state as ordinary events instead: a message_start for the reply in flight, the latest om_status, and a usage_update carrying the token total. Use this when the client keeps its own state from events, since each snapshot carries the whole display state. (Default: `true`)
|
|
130
|
+
|
|
129
131
|
Returns: `Promise<AgentControllerSubscription>`, an object with an `unsubscribe()` method that stops reading and releases the stream.
|
|
130
132
|
|
|
131
133
|
### `sendMessage(message, options?)`
|
|
@@ -261,6 +263,8 @@ Returns: `Promise<SendNotificationResult>`
|
|
|
261
263
|
| Workspace | `workspace_ready`, `workspace_error`, `workspace_status_changed` |
|
|
262
264
|
| Diagnostics | `info`, `error` |
|
|
263
265
|
|
|
266
|
+
`usage_update` carries the step's `usage` and, from servers that send it, `total`: the thread's running token total after that step.
|
|
267
|
+
|
|
264
268
|
Notifications are delivered as agent signals carried on messages rather than as `notification` or `notification_summary` controller events.
|
|
265
269
|
|
|
266
270
|
A message lifecycle uses three event shapes:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.15-alpha.1",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@mastra/mcp-legacy": "npm:@mastra/mcp@^1.18.0",
|
|
27
27
|
"local-pkg": "^1.2.1",
|
|
28
28
|
"zod": "^4.6.7",
|
|
29
|
-
"@mastra/core": "1.
|
|
29
|
+
"@mastra/core": "1.85.0-alpha.1",
|
|
30
30
|
"@mastra/mcp": "^2.10.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|