@mastra/mcp-docs-server 1.3.13-alpha.14 → 1.3.13-alpha.16
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/studio/overview.md +2 -0
- package/.docs/integrations/voice/openai.md +2 -2
- package/.docs/models/gateways/custom-gateways.md +74 -44
- package/.docs/reference/observability/tracing/advanced-queries.md +2 -1
- package/.docs/reference/observability/tracing/spans.md +7 -1
- package/.docs/reference/workspace/factory-sandbox.md +4 -1
- package/package.json +2 -2
|
@@ -55,6 +55,8 @@ Chat with your agent directly, switch [models](https://mastra.ai/models), and tw
|
|
|
55
55
|
|
|
56
56
|
Model pickers show newer releases first within each provider when the catalog includes release dates. Models with the same release date, or without a release date, use alphabetical order. Models without dates appear after dated models.
|
|
57
57
|
|
|
58
|
+
To limit the model picker to models from your own [custom gateways](https://mastra.ai/models/gateways/custom-gateways), set `AUTO_BLOCK_EXTERNAL_PROVIDERS=true`. See [Showing only custom gateways in Studio](https://mastra.ai/models/gateways/custom-gateways).
|
|
59
|
+
|
|
58
60
|
When you interact with your agent, you can follow its reasoning and view tool call outputs. You can also [observe](#observability) traces and logs to see how responses are generated.
|
|
59
61
|
|
|
60
62
|
For a markdown table in a response, select **Copy table as markdown** above the table to copy it without the surrounding message. The copied table preserves markdown formatting and includes any link and footnote definitions it uses. To download the table as CSV, open the arrow beside the copy button and select **Download CSV**. Both actions become available once the text segment containing the table finishes streaming and displaying. The agent may still be running tools or writing later segments.
|
|
@@ -155,7 +155,7 @@ const voice = new OpenAIRealtimeVoice()
|
|
|
155
155
|
// Or initialize with specific configuration
|
|
156
156
|
const voiceWithConfig = new OpenAIRealtimeVoice({
|
|
157
157
|
apiKey: 'your-openai-api-key',
|
|
158
|
-
model: 'gpt-
|
|
158
|
+
model: 'gpt-realtime-2.1-mini',
|
|
159
159
|
speaker: 'alloy', // Default voice
|
|
160
160
|
})
|
|
161
161
|
|
|
@@ -198,7 +198,7 @@ voice.connect()
|
|
|
198
198
|
|
|
199
199
|
#### Constructor options
|
|
200
200
|
|
|
201
|
-
**model** (`string`): The model ID to use for real-time voice interactions. (Default: `'gpt-
|
|
201
|
+
**model** (`string`): The model ID to use for real-time voice interactions. (Default: `'gpt-realtime-2.1-mini'`)
|
|
202
202
|
|
|
203
203
|
**apiKey** (`string`): OpenAI API key. Falls back to OPENAI_API_KEY environment variable.
|
|
204
204
|
|
|
@@ -15,16 +15,35 @@ Gateways handle provider-specific logic for accessing language models:
|
|
|
15
15
|
- URL construction for API endpoints
|
|
16
16
|
- Language model instance creation
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
## When to use custom gateways
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
20
|
+
Use a custom gateway to connect Mastra to open-weight models that you run yourself, such as gpt-oss, Llama, Gemma, Mistral, Qwen, or DeepSeek. Self-hosting fits when:
|
|
21
|
+
|
|
22
|
+
- Your industry's rules don't allow sending prompts or customer data to a third-party API (HIPAA, GDPR, finance, defense)
|
|
23
|
+
- You make enough model calls that per-token API pricing costs more than running your own GPUs
|
|
24
|
+
- You've fine-tuned an open-weight model on internal data and want your agents to use it
|
|
25
|
+
- You need a model that only changes when you upgrade it, so a provider update can't break your prompts
|
|
26
|
+
- Your agents run offline, on air-gapped networks, on edge hardware, or in the same data center as your app
|
|
27
|
+
|
|
28
|
+
The gateway lists the models behind your endpoint, so they get typed model IDs and appear in the Studio model picker. It can also resolve credentials on every call, and you can [limit the Studio model picker](#showing-only-custom-gateways-in-studio) to your own models.
|
|
29
|
+
|
|
30
|
+
To call a single endpoint with an OpenAI-compatible API, you don't need a gateway: set `url` in the model config instead. Mastra doesn't read an API key from environment variables for a `url` model, so also set `apiKey` when the endpoint requires authentication. See [Use local models with Mastra](https://mastra.ai/models).
|
|
24
31
|
|
|
25
32
|
## Creating a Custom Gateway
|
|
26
33
|
|
|
27
|
-
Implement `MastraModelGatewayInterface` for a plain object gateway, or extend `MastraModelGateway`
|
|
34
|
+
Implement `MastraModelGatewayInterface` for a plain object gateway, or extend the `MastraModelGateway` base class.
|
|
35
|
+
|
|
36
|
+
### Choose a plain object or a class
|
|
37
|
+
|
|
38
|
+
Both work the same way at runtime. The base class provides default `getId()`, `shouldEnable()`, `handlesModel()`, and `serializeForSpan()` methods, and Mastra applies the same defaults to a plain object that leaves them out.
|
|
39
|
+
|
|
40
|
+
Use a plain object when the gateway has fixed configuration and no state. Extend `MastraModelGateway` when the gateway:
|
|
41
|
+
|
|
42
|
+
- Takes options in its constructor, such as a base URL or API key
|
|
43
|
+
- Keeps private state, such as cached tokens
|
|
44
|
+
- Runs as several instances, such as one per region or version
|
|
45
|
+
|
|
46
|
+
The following example implements the interface with a plain object:
|
|
28
47
|
|
|
29
48
|
```typescript
|
|
30
49
|
import { type MastraModelGatewayInterface, type ProviderConfig } from '@mastra/core/llm';
|
|
@@ -50,35 +69,43 @@ const myPrivateGateway: MastraModelGatewayInterface = {
|
|
|
50
69
|
async getApiKey() {
|
|
51
70
|
return process.env.MY_API_KEY ?? '';
|
|
52
71
|
},
|
|
53
|
-
async resolveLanguageModel({ modelId, providerId, apiKey }) {
|
|
72
|
+
async resolveLanguageModel({ modelId, providerId, apiKey, headers }) {
|
|
54
73
|
return createOpenAICompatible({
|
|
55
74
|
name: providerId,
|
|
56
75
|
apiKey,
|
|
76
|
+
headers,
|
|
57
77
|
baseURL: 'https://api.myprovider.com/v1',
|
|
58
78
|
}).chatModel(modelId);
|
|
59
79
|
},
|
|
60
80
|
};
|
|
61
81
|
```
|
|
62
82
|
|
|
63
|
-
The following example extends
|
|
83
|
+
The following example extends `MastraModelGateway` and takes its ID, base URL, and API key as constructor options:
|
|
64
84
|
|
|
65
85
|
```typescript
|
|
66
|
-
import { MastraModelGateway, type ProviderConfig } from '@mastra/core/llm';
|
|
86
|
+
import { MastraModelGateway, type GatewayLanguageModel, type ProviderConfig } from '@mastra/core/llm';
|
|
67
87
|
import { createOpenAICompatible } from '@ai-sdk/openai-compatible-v5';
|
|
68
|
-
import type { LanguageModelV2 } from '@ai-sdk/provider-v5';
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
89
|
+
interface MyPrivateGatewayOptions {
|
|
90
|
+
id?: string;
|
|
91
|
+
baseURL?: string;
|
|
92
|
+
apiKey?: string;
|
|
93
|
+
}
|
|
74
94
|
|
|
75
|
-
|
|
95
|
+
class MyPrivateGateway extends MastraModelGateway {
|
|
96
|
+
readonly id: string;
|
|
76
97
|
readonly name = 'My Private Gateway';
|
|
77
98
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
99
|
+
private readonly baseURL: string;
|
|
100
|
+
private readonly apiKey?: string;
|
|
101
|
+
|
|
102
|
+
constructor(options: MyPrivateGatewayOptions = {}) {
|
|
103
|
+
super();
|
|
104
|
+
this.id = options.id ?? 'private';
|
|
105
|
+
this.baseURL = options.baseURL ?? 'https://api.myprovider.com/v1';
|
|
106
|
+
this.apiKey = options.apiKey;
|
|
107
|
+
}
|
|
108
|
+
|
|
82
109
|
async fetchProviders(): Promise<Record<string, ProviderConfig>> {
|
|
83
110
|
return {
|
|
84
111
|
'my-provider': {
|
|
@@ -86,57 +113,60 @@ class MyPrivateGateway extends MastraModelGateway {
|
|
|
86
113
|
models: ['openai/gpt-6.1-sol', 'anthropic/claude-sonnet-5-5'],
|
|
87
114
|
apiKeyEnvVar: 'MY_API_KEY',
|
|
88
115
|
gateway: this.id,
|
|
89
|
-
url:
|
|
116
|
+
url: this.baseURL,
|
|
90
117
|
},
|
|
91
118
|
};
|
|
92
119
|
}
|
|
93
120
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
* @param modelId - Full model ID (e.g., "private/my-provider/model-1")
|
|
97
|
-
* @param envVars - Environment variables (optional)
|
|
98
|
-
*/
|
|
99
|
-
buildUrl(modelId: string, envVars?: Record<string, string>): string {
|
|
100
|
-
return 'https://api.myprovider.com/v1';
|
|
121
|
+
buildUrl(): string {
|
|
122
|
+
return this.baseURL;
|
|
101
123
|
}
|
|
102
124
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* @param modelId - Full model ID
|
|
106
|
-
*/
|
|
107
|
-
async getApiKey(modelId: string): Promise<string> {
|
|
108
|
-
const apiKey = process.env.MY_API_KEY;
|
|
125
|
+
async getApiKey(): Promise<string> {
|
|
126
|
+
const apiKey = this.apiKey ?? process.env.MY_API_KEY;
|
|
109
127
|
if (!apiKey) {
|
|
110
|
-
throw new Error(
|
|
128
|
+
throw new Error('Missing MY_API_KEY environment variable');
|
|
111
129
|
}
|
|
112
130
|
return apiKey;
|
|
113
131
|
}
|
|
114
132
|
|
|
115
|
-
|
|
116
|
-
* Create a language model instance
|
|
117
|
-
* @param args - Model ID, provider ID, and API key
|
|
118
|
-
*/
|
|
119
|
-
async resolveLanguageModel({
|
|
133
|
+
resolveLanguageModel({
|
|
120
134
|
modelId,
|
|
121
135
|
providerId,
|
|
122
136
|
apiKey,
|
|
137
|
+
headers,
|
|
123
138
|
}: {
|
|
124
139
|
modelId: string;
|
|
125
140
|
providerId: string;
|
|
126
141
|
apiKey: string;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
headers?: Record<string, string>;
|
|
143
|
+
}): GatewayLanguageModel {
|
|
130
144
|
return createOpenAICompatible({
|
|
131
145
|
name: providerId,
|
|
132
146
|
apiKey,
|
|
133
|
-
|
|
147
|
+
headers,
|
|
148
|
+
baseURL: this.baseURL,
|
|
134
149
|
supportsStructuredOutputs: true,
|
|
135
150
|
}).chatModel(modelId);
|
|
136
151
|
}
|
|
137
152
|
}
|
|
138
153
|
```
|
|
139
154
|
|
|
155
|
+
To run one instance per endpoint, give each instance its own `id`. Mastra keeps only the first gateway registered with a given ID, and the ID is the model ID prefix:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { Mastra } from '@mastra/core';
|
|
159
|
+
|
|
160
|
+
const mastra = new Mastra({
|
|
161
|
+
gateways: {
|
|
162
|
+
privateEu: new MyPrivateGateway({ id: 'private-eu', baseURL: 'https://eu.api.myprovider.com/v1' }),
|
|
163
|
+
privateUs: new MyPrivateGateway({ id: 'private-us', baseURL: 'https://us.api.myprovider.com/v1' }),
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Models: 'private-eu/my-provider/openai/gpt-6.1-sol' and 'private-us/my-provider/openai/gpt-6.1-sol'
|
|
168
|
+
```
|
|
169
|
+
|
|
140
170
|
### Gateway-owned authentication
|
|
141
171
|
|
|
142
172
|
Add `resolveAuth` when the gateway owns credential lookup. Mastra uses this hook before falling back to `getApiKey()`.
|
|
@@ -625,7 +655,7 @@ By default, **Studio** lists every external model provider (such as OpenAI, Anth
|
|
|
625
655
|
AUTO_BLOCK_EXTERNAL_PROVIDERS=true
|
|
626
656
|
```
|
|
627
657
|
|
|
628
|
-
When this variable is set to `true` or `1`, Mastra returns only the providers from gateways you register yourself. The static provider registry and the built-in gateways (`models.dev`, `netlify`, and `mastra`) are hidden from the model picker. This is useful when you route all model traffic through a single private gateway and don't want the other providers to appear.
|
|
658
|
+
When this variable is set to `true` or `1`, Mastra returns only the providers from gateways you register yourself. The static provider registry and the built-in gateways (`models.dev`, `netlify`, and `mastra`) are hidden from the model picker. This is useful when you route all model traffic through a single private gateway and don't want the other providers to appear. The filter applies to the server's `GET /agents/providers` endpoint, which Studio uses for the model picker, so API clients don't see the external providers either. It only changes which providers are listed. It doesn't stop agents from calling other providers in code.
|
|
629
659
|
|
|
630
660
|
With this variable set and no custom gateway registered, the model picker is empty. Register at least one custom gateway to expose its models.
|
|
631
661
|
|
|
@@ -36,6 +36,7 @@ The configured observability store must support each API. Call `getObservability
|
|
|
36
36
|
| `traceQuery` | `trace-query` | `queryTraces()` |
|
|
37
37
|
| `spanQuery` | `span-query` | `querySpans()` |
|
|
38
38
|
| `spanQueryDurationSort` | `span-query-duration-sort` | `orderBy` on `durationMs` in `querySpans()` |
|
|
39
|
+
| `spanQueryModelProviderSort` | `span-query-model-provider-sort` | `orderBy` on `model` or `provider` in `querySpans()` |
|
|
39
40
|
| `spanQueryContextFields` | `span-query-context-fields` | Additional identity, context, and parent/root entity predicates in span queries and aggregates |
|
|
40
41
|
| `spanQueryModelFields` | `span-query-model-fields` | `model` and `provider` predicates in span queries and aggregates |
|
|
41
42
|
| `traceAggregate` | `trace-aggregate` | `aggregateTraces()` |
|
|
@@ -673,7 +674,7 @@ const result = await mastraClient.querySpans({
|
|
|
673
674
|
console.log(result.spans)
|
|
674
675
|
```
|
|
675
676
|
|
|
676
|
-
Pages default to 100 rows and allow at most 1,000. The response is `{ spans, page: { next } }`, without a total count. Ordering accepts exactly one of `startedAt`, `endedAt`, `durationMs`, `timeToFirstChunkMs`, or `
|
|
677
|
+
Pages default to 100 rows and allow at most 1,000. The response is `{ spans, page: { next } }`, without a total count. Ordering accepts exactly one of `startedAt`, `endedAt`, `durationMs`, `timeToFirstChunkMs`, `timeToFirstTokenMs`, `model`, or `provider`, ascending or descending, and defaults to descending start time. Missing sort values appear last in both directions. Model and provider sorting is case-sensitive.
|
|
677
678
|
|
|
678
679
|
| Fields | Operators |
|
|
679
680
|
| -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
@@ -164,7 +164,7 @@ interface ExportedSpan<TType extends SpanType> extends BaseSpan<TType> {
|
|
|
164
164
|
/** Milliseconds from the start of the model inference that streamed the first chunk to that chunk */
|
|
165
165
|
timeToFirstTokenMs?: number
|
|
166
166
|
|
|
167
|
-
/**
|
|
167
|
+
/** Failures originating directly on this span; unset when the count is unknown */
|
|
168
168
|
errorCount?: number
|
|
169
169
|
|
|
170
170
|
/** TRUE if the span is the root span of a trace */
|
|
@@ -172,6 +172,12 @@ interface ExportedSpan<TType extends SpanType> extends BaseSpan<TType> {
|
|
|
172
172
|
}
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
+
### Local error counts
|
|
176
|
+
|
|
177
|
+
`errorCount` counts failures originating on the span. It excludes child counts and repeated reports of the same failure on parent spans. A recovered failure still contributes to the count, so a successful span can have a positive count.
|
|
178
|
+
|
|
179
|
+
An unset `errorCount` means the count is unavailable, not necessarily zero.
|
|
180
|
+
|
|
175
181
|
## Span lifecycle events
|
|
176
182
|
|
|
177
183
|
Events emitted during the span lifecycle.
|
|
@@ -195,8 +195,11 @@ When the sandbox declares `builds`, factory builds the environment template ahea
|
|
|
195
195
|
- on `POST /web/factory/projects/:id/environment/build` (the Environment page's Build now, or `mastra api factory project environment build <project-id>`)
|
|
196
196
|
- on a cron schedule kept in core `Schedules`, enabled through `PATCH { buildTriggers: { schedule: { enabled: true, cron, timezone } } }`; needs a storage adapter with the schedules domain, otherwise the route reports `scheduleAvailable: false`
|
|
197
197
|
- after a push to a linked repository's default branch when `buildTriggers.push.enabled` is set, at most once per `debounceMinutes`
|
|
198
|
+
- after saving a change to a template input, once the project has a template; a change saved while a build runs is built when that build ends
|
|
198
199
|
|
|
199
|
-
|
|
200
|
+
A save that leaves every template input unchanged doesn't start a build. Scheduled and push builds skip when the last build is ready, no repository head moved and no template input changed (settings, repositories and their order, setup commands, the working directory or the factory's Build variables). Factory stores only the last build id and the active template. Status and history come from the provider through `GET …/environment/builds/:buildId` and `GET …/environment/builds` (404 `no_history` when the provider keeps none).
|
|
201
|
+
|
|
202
|
+
When a build start was never recorded and the provider can't list its builds, Factory can't tell whether that build is still running. Triggers skip with reason `unresolved` for 30 minutes after the start's lease lapsed, then Factory treats the start as failed and the next trigger builds.
|
|
200
203
|
|
|
201
204
|
## Environment variables
|
|
202
205
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.3.13-alpha.
|
|
3
|
+
"version": "1.3.13-alpha.16",
|
|
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.83.0-alpha.
|
|
29
|
+
"@mastra/core": "1.83.0-alpha.12",
|
|
30
30
|
"@mastra/mcp": "^2.9.0-alpha.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|