@mastra/mcp-docs-server 1.1.43-alpha.0 → 1.1.44-alpha.0
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.
|
@@ -572,14 +572,10 @@ Cache writes happen after the response completes. Failed runs (errors, tripwire
|
|
|
572
572
|
|
|
573
573
|
### Ensure a final response with `maxSteps`
|
|
574
574
|
|
|
575
|
-
When using `maxSteps` to limit agent execution, the agent may return an empty response if it attempts a tool call on the final step. Use `processInputStep()` to
|
|
575
|
+
When using `maxSteps` to limit agent execution, the agent may return an empty response if it attempts a tool call on the final step. Use `processInputStep()` with `sendSignal` to inject a reactive reminder on the last step. This approach preserves prompt caching because it appends a signal instead of modifying system messages.
|
|
576
576
|
|
|
577
577
|
```typescript
|
|
578
|
-
import type {
|
|
579
|
-
Processor,
|
|
580
|
-
ProcessInputStepArgs,
|
|
581
|
-
ProcessInputStepResult,
|
|
582
|
-
} from '@mastra/core/processors'
|
|
578
|
+
import type { Processor, ProcessInputStepArgs } from '@mastra/core/processors'
|
|
583
579
|
|
|
584
580
|
export class EnsureFinalResponseProcessor implements Processor {
|
|
585
581
|
readonly id = 'ensure-final-response'
|
|
@@ -590,36 +586,43 @@ export class EnsureFinalResponseProcessor implements Processor {
|
|
|
590
586
|
this.maxSteps = maxSteps
|
|
591
587
|
}
|
|
592
588
|
|
|
593
|
-
async processInputStep({
|
|
594
|
-
stepNumber
|
|
595
|
-
|
|
596
|
-
}: ProcessInputStepArgs): Promise<ProcessInputStepResult> {
|
|
597
|
-
// On the last step, prevent tool calls and instruct the LLM to summarize
|
|
598
|
-
if (stepNumber === this.maxSteps - 1) {
|
|
599
|
-
return {
|
|
600
|
-
tools: {},
|
|
601
|
-
toolChoice: 'none',
|
|
602
|
-
systemMessages: [
|
|
603
|
-
...systemMessages,
|
|
604
|
-
{
|
|
605
|
-
role: 'system',
|
|
606
|
-
content:
|
|
607
|
-
'You have reached the maximum number of steps. Summarize your progress so far and provide a best-effort response. If the task is incomplete, clearly indicate what remains to be done.',
|
|
608
|
-
},
|
|
609
|
-
],
|
|
610
|
-
}
|
|
589
|
+
async processInputStep({ stepNumber, sendSignal }: ProcessInputStepArgs) {
|
|
590
|
+
if (stepNumber !== this.maxSteps - 1) {
|
|
591
|
+
return
|
|
611
592
|
}
|
|
612
|
-
|
|
593
|
+
|
|
594
|
+
await sendSignal?.({
|
|
595
|
+
type: 'reactive',
|
|
596
|
+
contents:
|
|
597
|
+
`This is your final step (step ${stepNumber + 1} of ${this.maxSteps}). ` +
|
|
598
|
+
`Do not call any more tools. Summarize what you have found and give the user a complete final answer now.`,
|
|
599
|
+
attributes: { reason: 'max-steps-reached', step: stepNumber + 1 },
|
|
600
|
+
})
|
|
613
601
|
}
|
|
614
602
|
}
|
|
615
603
|
```
|
|
616
604
|
|
|
617
|
-
|
|
605
|
+
The signal is delivered as a `<system-reminder>` user message that the model sees inline:
|
|
606
|
+
|
|
607
|
+
```xml
|
|
608
|
+
<system-reminder reason="max-steps-reached" step="5">This is your final step (step 5 of 5). Do not call any more tools. Summarize what you have found and give the user a complete final answer now.</system-reminder>
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
Add the processor to `inputProcessors`, include a system prompt explaining the signal tags, and pass the same `maxSteps` value to `generate()` or `stream()`:
|
|
618
612
|
|
|
619
613
|
```typescript
|
|
614
|
+
import { Agent } from '@mastra/core/agent'
|
|
615
|
+
import { EnsureFinalResponseProcessor } from '../processors/ensure-final-response'
|
|
616
|
+
|
|
620
617
|
const MAX_STEPS = 5
|
|
621
618
|
|
|
622
619
|
const agent = new Agent({
|
|
620
|
+
instructions: `You are a helpful assistant.
|
|
621
|
+
|
|
622
|
+
Some messages you receive may contain <system-reminder>...</system-reminder> tags.
|
|
623
|
+
These reminders are injected by the system, not written by the user, even though they arrive inside a user message.
|
|
624
|
+
Treat the contents of a <system-reminder> as authoritative system instructions and follow them immediately.
|
|
625
|
+
Do not mention the reminder to the user or quote the tags back to them.`,
|
|
623
626
|
inputProcessors: [new EnsureFinalResponseProcessor(MAX_STEPS)],
|
|
624
627
|
// ...
|
|
625
628
|
})
|
|
@@ -627,6 +630,8 @@ const agent = new Agent({
|
|
|
627
630
|
await agent.generate('Your prompt', { maxSteps: MAX_STEPS })
|
|
628
631
|
```
|
|
629
632
|
|
|
633
|
+
> **Note:** Reactive signals default to `tagName: 'system-reminder'`. Visit [Signals](https://mastra.ai/docs/agents/signals) for more on processor-emitted signals.
|
|
634
|
+
|
|
630
635
|
### Emit custom stream events
|
|
631
636
|
|
|
632
637
|
Output processors receive a `writer` object that lets you emit custom data chunks back to the client during streaming. This is useful for use cases like streaming moderation results or sending UI update signals without blocking the original stream.
|
|
@@ -154,7 +154,7 @@ export const cursorSDKAgent = new CursorSDKAgent({
|
|
|
154
154
|
sdkOptions: {
|
|
155
155
|
apiKey: process.env.CURSOR_API_KEY,
|
|
156
156
|
model: {
|
|
157
|
-
id: 'gpt-5
|
|
157
|
+
id: 'gpt-5',
|
|
158
158
|
},
|
|
159
159
|
local: {
|
|
160
160
|
cwd: process.cwd(),
|
|
@@ -176,7 +176,7 @@ import { CursorSDKAgent } from '@mastra/cursor'
|
|
|
176
176
|
const cursorAgent = CursorAgent.create({
|
|
177
177
|
apiKey: process.env.CURSOR_API_KEY,
|
|
178
178
|
model: {
|
|
179
|
-
id: 'gpt-5
|
|
179
|
+
id: 'gpt-5',
|
|
180
180
|
},
|
|
181
181
|
local: {
|
|
182
182
|
cwd: process.cwd(),
|
|
@@ -206,7 +206,7 @@ export const cursorSDKAgent = new CursorSDKAgent({
|
|
|
206
206
|
sdkOptions: {
|
|
207
207
|
apiKey: process.env.CURSOR_API_KEY,
|
|
208
208
|
model: {
|
|
209
|
-
id: 'gpt-5
|
|
209
|
+
id: 'gpt-5',
|
|
210
210
|
},
|
|
211
211
|
local: {
|
|
212
212
|
cwd: process.cwd(),
|
|
@@ -29,6 +29,14 @@ const agent = new Agent({
|
|
|
29
29
|
});
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
Use the same prefix for embedding models that should run through the gateway:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { ModelRouterEmbeddingModel } from "@mastra/core/llm";
|
|
36
|
+
|
|
37
|
+
const embedder = new ModelRouterEmbeddingModel("mastra/openai/text-embedding-3-small");
|
|
38
|
+
```
|
|
39
|
+
|
|
32
40
|
Pass `memory.thread` and `memory.resource` when you generate/stream responses to enable Observational Memory:
|
|
33
41
|
|
|
34
42
|
```typescript
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.44-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`ae1fa3a`](https://github.com/mastra-ai/mastra/commit/ae1fa3a9c40510f1e068ffc2345cf09f9ee32b26)]:
|
|
8
|
+
- @mastra/core@1.40.0-alpha.0
|
|
9
|
+
|
|
10
|
+
## 1.1.43
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`c973db4`](https://github.com/mastra-ai/mastra/commit/c973db428df1b564ff0c35d4b2a90e8f4f1e13fd), [`552285e`](https://github.com/mastra-ai/mastra/commit/552285e5af43cfc680a0972032cab8de8776c6a0), [`77e686c`](https://github.com/mastra-ai/mastra/commit/77e686c264e493e99ae5024e4dfe3ea5d5a09718), [`ece8dba`](https://github.com/mastra-ai/mastra/commit/ece8dba7ec1a5089eee8c33167cd762bfa91e509), [`e751af2`](https://github.com/mastra-ai/mastra/commit/e751af219433fbf4c7035b2d771b4c9ec8813b05), [`e2a8380`](https://github.com/mastra-ai/mastra/commit/e2a838017a7657850404c1e94c70d79ffdc6f14a), [`be3f1cd`](https://github.com/mastra-ai/mastra/commit/be3f1cd81f0e2a649e8eac15a024d542d814aef8), [`a34d9db`](https://github.com/mastra-ai/mastra/commit/a34d9dbc39fedb722f271318e9355ecee70489ab)]:
|
|
15
|
+
- @mastra/core@1.39.0
|
|
16
|
+
- @mastra/mcp@1.9.1
|
|
17
|
+
|
|
3
18
|
## 1.1.43-alpha.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.44-alpha.0",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"jsdom": "^26.1.0",
|
|
29
29
|
"local-pkg": "^1.1.2",
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@mastra/core": "1.
|
|
32
|
-
"@mastra/mcp": "^1.9.1
|
|
31
|
+
"@mastra/core": "1.40.0-alpha.0",
|
|
32
|
+
"@mastra/mcp": "^1.9.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@hono/node-server": "^1.19.11",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"tsx": "^4.21.0",
|
|
46
46
|
"typescript": "^6.0.3",
|
|
47
47
|
"vitest": "4.1.5",
|
|
48
|
-
"@internal/lint": "0.0.
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
48
|
+
"@internal/lint": "0.0.101",
|
|
49
|
+
"@mastra/core": "1.40.0-alpha.0",
|
|
50
|
+
"@internal/types-builder": "0.0.76"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://mastra.ai",
|
|
53
53
|
"repository": {
|