@mastra/mcp 1.15.0 → 1.15.1-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.
- package/CHANGELOG.md +9 -0
- package/dist/client/configuration.d.ts +13 -0
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/docs/SKILL.md +2 -2
- package/dist/docs/assets/SOURCE_MAP.json +2 -55
- package/dist/docs/references/docs-mcp-mcp-apps.md +1 -1
- package/dist/docs/references/docs-mcp-overview.md +9 -9
- package/dist/docs/references/docs-server-auth-fga.md +9 -6
- package/dist/docs/references/reference-tools-mcp-client.md +15 -15
- package/dist/docs/references/reference-tools-mcp-server.md +21 -21
- package/dist/index.cjs +25943 -36504
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25854 -36456
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.15.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Speed up MCP discovery when an `MCPClient` is configured with multiple servers. `listTools()`, `listToolsets()`, `resources.list()`, `resources.templates()`, and `prompts.list()` now query all configured servers concurrently instead of one at a time, so total discovery time is roughly the slowest single server rather than the sum of all of them, and one slow or unresponsive server no longer stalls discovery for the rest. Tool, resource, and prompt ordering and per-server error reporting are unchanged. ([#19919](https://github.com/mastra-ai/mastra/pull/19919))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4844167`](https://github.com/mastra-ai/mastra/commit/4844167cff2d5ec5004e94edd34970833040fa3f), [`5faf93f`](https://github.com/mastra-ai/mastra/commit/5faf93f03e19daea394b9e2a923f2e4f833407f2), [`80ad891`](https://github.com/mastra-ai/mastra/commit/80ad891f8cd10379aa5b5af7510c763783b2ab56), [`a1cb98d`](https://github.com/mastra-ai/mastra/commit/a1cb98d11990b560b98482292a1f34aa1a2d9092), [`598ad82`](https://github.com/mastra-ai/mastra/commit/598ad82d41c41389a686338a1d0e50b7400e1938), [`1fd6aad`](https://github.com/mastra-ai/mastra/commit/1fd6aad1ea4a9d32f65efa832307c35e981a4c0a)]:
|
|
10
|
+
- @mastra/core@1.56.0-alpha.4
|
|
11
|
+
|
|
3
12
|
## 1.15.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -731,6 +731,19 @@ export declare class MCPClient extends MastraBase {
|
|
|
731
731
|
toolsets: Record<string, Record<string, Tool<any, any, any, any>>>;
|
|
732
732
|
errors: Record<string, string>;
|
|
733
733
|
}>;
|
|
734
|
+
/**
|
|
735
|
+
* Runs a per-server discovery `operation` against every configured server
|
|
736
|
+
* concurrently, isolating and logging per-server failures. Results are
|
|
737
|
+
* returned in configuration order (`Object.keys(serverConfigs)`) so callers
|
|
738
|
+
* fold them back deterministically.
|
|
739
|
+
*
|
|
740
|
+
* Mirrors the parallel teardown in `disconnect()`: each server is bounded by
|
|
741
|
+
* its own request timeout, so total time is the slowest single server rather
|
|
742
|
+
* than the sum, and one slow or unresponsive server never stalls the others.
|
|
743
|
+
* Backs `listTools`/`listToolsets`, `resources.list`/`templates`, and
|
|
744
|
+
* `prompts.list`.
|
|
745
|
+
*/
|
|
746
|
+
private discoverAcrossServers;
|
|
734
747
|
/**
|
|
735
748
|
* Creates MCPServerBase-compatible proxy objects for each server connection
|
|
736
749
|
* in this MCPClient. The returned record can be spread directly into
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,KAAK,EAAE,I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;YAIlB,iBAAiB;CAuBhC"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-mcp
|
|
|
3
3
|
description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/mcp"
|
|
6
|
-
version: "1.15.0"
|
|
6
|
+
version: "1.15.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -17,7 +17,7 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
19
|
- [MCP Apps](references/docs-mcp-mcp-apps.md) - Serve interactive HTML UIs from MCP tools using the MCP Apps extension.
|
|
20
|
-
- [MCP overview](references/docs-mcp-overview.md) - Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient
|
|
20
|
+
- [MCP overview](references/docs-mcp-overview.md) - Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient and connect to registries, plus share your own tools using MCPServer.
|
|
21
21
|
- [Fine-Grained Authorization (FGA)](references/docs-server-auth-fga.md) - Add resource-level authorization to your Mastra application with FGA providers.
|
|
22
22
|
|
|
23
23
|
### Reference
|
|
@@ -1,59 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.15.0",
|
|
2
|
+
"version": "1.15.1-alpha.0",
|
|
3
3
|
"package": "@mastra/mcp",
|
|
4
|
-
"exports": {
|
|
5
|
-
"UnauthorizedError": {
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"implementation": "dist/auth.js"
|
|
8
|
-
},
|
|
9
|
-
"auth": {
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
|
-
"implementation": "dist/auth.js"
|
|
12
|
-
},
|
|
13
|
-
"buildDiscoveryUrls": {
|
|
14
|
-
"types": "dist/index.d.ts",
|
|
15
|
-
"implementation": "dist/auth.js"
|
|
16
|
-
},
|
|
17
|
-
"discoverAuthorizationServerMetadata": {
|
|
18
|
-
"types": "dist/index.d.ts",
|
|
19
|
-
"implementation": "dist/auth.js"
|
|
20
|
-
},
|
|
21
|
-
"discoverOAuthMetadata": {
|
|
22
|
-
"types": "dist/index.d.ts",
|
|
23
|
-
"implementation": "dist/auth.js"
|
|
24
|
-
},
|
|
25
|
-
"discoverOAuthProtectedResourceMetadata": {
|
|
26
|
-
"types": "dist/index.d.ts",
|
|
27
|
-
"implementation": "dist/auth.js"
|
|
28
|
-
},
|
|
29
|
-
"exchangeAuthorization": {
|
|
30
|
-
"types": "dist/index.d.ts",
|
|
31
|
-
"implementation": "dist/auth.js"
|
|
32
|
-
},
|
|
33
|
-
"extractResourceMetadataUrl": {
|
|
34
|
-
"types": "dist/index.d.ts",
|
|
35
|
-
"implementation": "dist/auth.js"
|
|
36
|
-
},
|
|
37
|
-
"parseErrorResponse": {
|
|
38
|
-
"types": "dist/index.d.ts",
|
|
39
|
-
"implementation": "dist/auth.js"
|
|
40
|
-
},
|
|
41
|
-
"refreshAuthorization": {
|
|
42
|
-
"types": "dist/index.d.ts",
|
|
43
|
-
"implementation": "dist/auth.js"
|
|
44
|
-
},
|
|
45
|
-
"registerClient": {
|
|
46
|
-
"types": "dist/index.d.ts",
|
|
47
|
-
"implementation": "dist/auth.js"
|
|
48
|
-
},
|
|
49
|
-
"selectResourceURL": {
|
|
50
|
-
"types": "dist/index.d.ts",
|
|
51
|
-
"implementation": "dist/auth.js"
|
|
52
|
-
},
|
|
53
|
-
"startAuthorization": {
|
|
54
|
-
"types": "dist/index.d.ts",
|
|
55
|
-
"implementation": "dist/auth.js"
|
|
56
|
-
}
|
|
57
|
-
},
|
|
4
|
+
"exports": {},
|
|
58
5
|
"modules": {}
|
|
59
6
|
}
|
|
@@ -85,7 +85,7 @@ Visit [MCPServer reference](https://mastra.ai/reference/tools/mcp-server) for th
|
|
|
85
85
|
|
|
86
86
|
## Connecting MCP Apps to agents
|
|
87
87
|
|
|
88
|
-
Agents consume tools
|
|
88
|
+
Agents consume tools, they don't need to know about MCP servers. Pass tools to the agent's `tools` config, and register the MCP server at the Mastra level so Studio can resolve app resources.
|
|
89
89
|
|
|
90
90
|
```typescript
|
|
91
91
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# MCP overview
|
|
4
4
|
|
|
5
|
-
Mastra supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), an open standard for connecting AI agents to external tools and resources. It
|
|
5
|
+
Mastra supports the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction), an open standard for connecting AI agents to external tools and resources. It's a universal plugin system, enabling agents to call tools regardless of language or hosting environment.
|
|
6
6
|
|
|
7
7
|
Mastra can also be used to author MCP servers, exposing agents, tools, and other structured resources via the MCP interface. These can then be accessed by any system or agent that supports the protocol.
|
|
8
8
|
|
|
@@ -64,7 +64,7 @@ export const testMcpClient = new MCPClient({
|
|
|
64
64
|
|
|
65
65
|
Visit [MCPClient](https://mastra.ai/reference/tools/mcp-client) for a full list of configuration options.
|
|
66
66
|
|
|
67
|
-
> **Authentication:** For connecting to OAuth-protected MCP servers
|
|
67
|
+
> **Authentication:** For connecting to OAuth-protected MCP servers, including completing the browser-based authorization flow with `authenticate()`, see the [OAuth Authentication](https://mastra.ai/reference/tools/mcp-client) section.
|
|
68
68
|
|
|
69
69
|
## Using `MCPClient` with an agent
|
|
70
70
|
|
|
@@ -84,7 +84,7 @@ export const testAgent = new Agent({
|
|
|
84
84
|
- US National Weather Service
|
|
85
85
|
|
|
86
86
|
Answer questions using the information you find using the MCP Servers.`,
|
|
87
|
-
model: 'openai/gpt-5.
|
|
87
|
+
model: 'openai/gpt-5.6-sol',
|
|
88
88
|
tools: await testMcpClient.listTools(),
|
|
89
89
|
})
|
|
90
90
|
```
|
|
@@ -106,7 +106,7 @@ export const mcp = new MCPClient({
|
|
|
106
106
|
})
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
You can also pass a function to decide
|
|
109
|
+
You can also pass a function to decide per runtime-call. See the [MCPClient reference](https://mastra.ai/reference/tools/mcp-client) for the full API.
|
|
110
110
|
|
|
111
111
|
## Configuring `MCPServer`
|
|
112
112
|
|
|
@@ -147,14 +147,14 @@ export const mastra = new Mastra({
|
|
|
147
147
|
})
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
## Static and
|
|
150
|
+
## Static and runtime tools
|
|
151
151
|
|
|
152
152
|
`MCPClient` offers two approaches to retrieving tools from connected servers, suitable for different application architectures:
|
|
153
153
|
|
|
154
154
|
| Feature | Static Configuration (`await mcp.listTools()`) | Dynamic Configuration (`await mcp.listToolsets()`) |
|
|
155
155
|
| ----------------- | ---------------------------------------------- | ---------------------------------------------------- |
|
|
156
|
-
| **Use Case** | Single-user, static config (e.g., CLI tool) | Multi-user,
|
|
157
|
-
| **Configuration** | Fixed at agent initialization | Per-request,
|
|
156
|
+
| **Use Case** | Single-user, static config (e.g., CLI tool) | Multi-user, runtime config (e.g., SaaS app) |
|
|
157
|
+
| **Configuration** | Fixed at agent initialization | Per-request, runtime |
|
|
158
158
|
| **Credentials** | Shared across all uses | Can vary per user/request |
|
|
159
159
|
| **Agent Setup** | Tools added in `Agent` constructor | Tools passed in `.generate()` or `.stream()` options |
|
|
160
160
|
|
|
@@ -257,7 +257,7 @@ const mcp = new MCPClient({
|
|
|
257
257
|
})
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
> **
|
|
260
|
+
> **Requirement:** Treat the mcp.run SSE URL like a password. Store it securely, for example, in an environment variable.
|
|
261
261
|
>
|
|
262
262
|
> ```bash
|
|
263
263
|
> MCP_RUN_SSE_URL=https://www.mcp.run/api/mcp/sse?nonce=...
|
|
@@ -410,7 +410,7 @@ As an alternative to MCP, Ampersand's AI SDK also has an adapter for Mastra, so
|
|
|
410
410
|
|
|
411
411
|
## MCP Apps
|
|
412
412
|
|
|
413
|
-
MCP servers can serve interactive HTML UIs via the MCP Apps extension. Tools with associated `ui://` resources render sandboxed iframes in Studio
|
|
413
|
+
MCP servers can serve interactive HTML UIs via the MCP Apps extension. Tools with associated `ui://` resources render sandboxed iframes in Studio, both on tool detail pages and inline in agent chat. The app iframe can call server tools and inject messages into the conversation. Visit [MCP Apps](https://mastra.ai/docs/mcp/mcp-apps) for setup instructions and the app bridge API.
|
|
414
414
|
|
|
415
415
|
## Related
|
|
416
416
|
|
|
@@ -74,10 +74,10 @@ resourceMapping: {
|
|
|
74
74
|
|
|
75
75
|
`deriveId()` receives:
|
|
76
76
|
|
|
77
|
-
- `user
|
|
78
|
-
- `resourceId
|
|
79
|
-
- `requestContext
|
|
80
|
-
- `metadata
|
|
77
|
+
- `user`: the authenticated user
|
|
78
|
+
- `resourceId`: the owning Mastra resource ID when available (for example, a thread's `resourceId`)
|
|
79
|
+
- `requestContext`: the current request context for advanced tenant resolution
|
|
80
|
+
- `metadata`: provider-specific metadata for the attempted action
|
|
81
81
|
|
|
82
82
|
Return `undefined` from `deriveId()` to fall back to the original Mastra resource ID.
|
|
83
83
|
|
|
@@ -254,6 +254,8 @@ class MyFGAProvider implements IFGAProvider {
|
|
|
254
254
|
}
|
|
255
255
|
```
|
|
256
256
|
|
|
257
|
+
> **Note:** See the [`IFGAProvider` reference](https://mastra.ai/reference/auth/fga) for every method, parameter, and the `ActorSignal` type.
|
|
258
|
+
|
|
257
259
|
## System actors
|
|
258
260
|
|
|
259
261
|
Autonomous and scheduled agents run without an end user. Mark these calls with an actor signal so FGA can tell them apart from user requests:
|
|
@@ -261,7 +263,7 @@ Autonomous and scheduled agents run without an end user. Mark these calls with a
|
|
|
261
263
|
- `true` or `{ actorKind: 'system' }` identifies an anonymous system actor.
|
|
262
264
|
- The object form can also carry `agentId`, `permissions`, and `scope` to identify and constrain the acting agent.
|
|
263
265
|
|
|
264
|
-
By default, a trusted actor skips the user-centric `require()` check after a tenant-scope check. To enforce per-agent least privilege, implement the optional `requireActor` method on your provider. It receives the actor and the same `FGACheckParams` as `require`, and throws `FGADeniedError` to deny. When your provider doesn't implement `requireActor`, the trusted-actor bypass is preserved, so adding it
|
|
266
|
+
By default, a trusted actor skips the user-centric `require()` check after a tenant-scope check. To enforce per-agent least privilege, implement the optional `requireActor` method on your provider. It receives the actor and the same `FGACheckParams` as `require`, and throws `FGADeniedError` to deny. When your provider doesn't implement `requireActor`, the trusted-actor bypass is preserved, so adding it's backward compatible.
|
|
265
267
|
|
|
266
268
|
```typescript
|
|
267
269
|
import { FGADeniedError } from '@mastra/core/auth/ee'
|
|
@@ -291,10 +293,11 @@ The actor signal is trusted input, so construct it server-side:
|
|
|
291
293
|
- Establish tenant scope server-side. Built-in agent HTTP routes ignore a client-supplied `organizationId` in the request context, and the trusted-actor path requires an `organizationId` to be set.
|
|
292
294
|
- Durable resume keeps its existing request-context recovery and merge behavior. This doesn't make a persisted actor trusted for a later workflow segment.
|
|
293
295
|
- The tenant-scope check confirms that a trusted `organizationId` exists. It doesn't verify that `actor.agentId` belongs to that organization. When that relationship matters, verify it in `requireActor` using authoritative provider data.
|
|
294
|
-
- Treat `actor.permissions` as
|
|
296
|
+
- Treat `actor.permissions` as an unverified claim. Resolve authoritative grants from a trusted source. A provider that enforces least privilege resolves the agent's authoritative permissions from a trusted source, for example a manifest or your FGA backend keyed by `agentId`, rather than trusting the inline values.
|
|
295
297
|
- Once a provider implements `requireActor`, errors from that method stop execution. Mastra doesn't fall back to organization-only authorization.
|
|
296
298
|
|
|
297
299
|
## Related
|
|
298
300
|
|
|
301
|
+
- [`IFGAProvider` reference](https://mastra.ai/reference/auth/fga)
|
|
299
302
|
- [Authentication overview](https://mastra.ai/docs/server/auth)
|
|
300
303
|
- [WorkOS authentication](https://mastra.ai/docs/server/auth/workos)
|
|
@@ -125,7 +125,7 @@ const mcp = new MCPClient({
|
|
|
125
125
|
})
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
Per the MCP specification
|
|
128
|
+
Per the MCP specification: **clients MUST consider tool annotations to be untrusted unless they come from trusted servers**. Annotations are advisory hints and provide no security boundary. A malicious or buggy server can claim a tool is read-only when it isn't. Only use annotations to relax approval requirements for servers you trust.
|
|
129
129
|
|
|
130
130
|
The same annotations are also exposed on the tools returned by `listTools()` and `listToolsets()` under `tool.mcp.annotations`, so you can inspect them when wiring tools into an agent.
|
|
131
131
|
|
|
@@ -182,7 +182,7 @@ console.log(errors)
|
|
|
182
182
|
|
|
183
183
|
### `listToolsets()`
|
|
184
184
|
|
|
185
|
-
Returns an object mapping namespaced tool names (in the format `serverName.toolName`) to their tool implementations. Intended to be passed
|
|
185
|
+
Returns an object mapping namespaced tool names (in the format `serverName.toolName`) to their tool implementations. Intended to be passed at runtime into the generate or stream method.
|
|
186
186
|
|
|
187
187
|
```typescript
|
|
188
188
|
const res = await agent.stream(prompt, {
|
|
@@ -227,9 +227,9 @@ getServerAuthState(serverName: string): 'needs-auth' | 'authorized' | undefined
|
|
|
227
227
|
|
|
228
228
|
### `cancelAuthentication()`
|
|
229
229
|
|
|
230
|
-
Cancels an in-progress `authenticate()` flow for a server, so an abandoned browser authorization
|
|
230
|
+
Cancels an in-progress `authenticate()` flow for a server, so an abandoned browser authorization doesn't leave the client waiting indefinitely. It aborts the flow (including its setup phase, before the callback server binds), closes the local callback server if one is listening, and the pending `authenticate()` call rejects. Returns `true` if a flow was cancelled, or `false` when no flow was in progress.
|
|
231
231
|
|
|
232
|
-
The resulting `getServerAuthState()` depends on how far the flow
|
|
232
|
+
The resulting `getServerAuthState()` depends on how far the flow progressed. A flow cancelled after a `401` rejection stays at `'needs-auth'` and can be retried immediately. Cancellation during setup leaves the state unchanged (typically `undefined`) if no connection was attempted.
|
|
233
233
|
|
|
234
234
|
```typescript
|
|
235
235
|
async cancelAuthentication(serverName: string): Promise<boolean>
|
|
@@ -324,7 +324,7 @@ for (const serverName in templatesByServer) {
|
|
|
324
324
|
|
|
325
325
|
#### `resources.read(serverName: string, uri: string)`
|
|
326
326
|
|
|
327
|
-
Reads the content of a specific resource from a
|
|
327
|
+
Reads the content of a specific resource from a server.
|
|
328
328
|
|
|
329
329
|
```typescript
|
|
330
330
|
async read(serverName: string, uri: string): Promise<ReadResourceResult>
|
|
@@ -342,7 +342,7 @@ console.log('Current weather:', content.contents[0].text)
|
|
|
342
342
|
|
|
343
343
|
#### `resources.subscribe(serverName: string, uri: string)`
|
|
344
344
|
|
|
345
|
-
Subscribes to updates for a specific resource on a
|
|
345
|
+
Subscribes to updates for a specific resource on a server.
|
|
346
346
|
|
|
347
347
|
```typescript
|
|
348
348
|
async subscribe(serverName: string, uri: string): Promise<object>
|
|
@@ -356,7 +356,7 @@ await mcpClient.resources.subscribe('myWeatherServer', 'weather://current')
|
|
|
356
356
|
|
|
357
357
|
#### `resources.unsubscribe(serverName: string, uri: string)`
|
|
358
358
|
|
|
359
|
-
Unsubscribes from updates for a specific resource on a
|
|
359
|
+
Unsubscribes from updates for a specific resource on a server.
|
|
360
360
|
|
|
361
361
|
```typescript
|
|
362
362
|
async unsubscribe(serverName: string, uri: string): Promise<object>
|
|
@@ -388,7 +388,7 @@ mcpClient.resources.onUpdated('myWeatherServer', params => {
|
|
|
388
388
|
|
|
389
389
|
#### `resources.onListChanged(serverName: string, handler: () => void)`
|
|
390
390
|
|
|
391
|
-
Sets a notification handler that will be called when the
|
|
391
|
+
Sets a notification handler that will be called when the list of available resources changes on a specific server.
|
|
392
392
|
|
|
393
393
|
```typescript
|
|
394
394
|
async onListChanged(serverName: string, handler: () => void): Promise<void>
|
|
@@ -847,7 +847,7 @@ Give each server its own `MCPOAuthClientProvider` instance. A provider holds per
|
|
|
847
847
|
|
|
848
848
|
### Interactive browser authentication
|
|
849
849
|
|
|
850
|
-
When a server rejects a connection because authorization is required, the client records a `'needs-auth'` state instead of failing outright. Calling `authenticate()`
|
|
850
|
+
When a server rejects a connection because authorization is required, the client records a `'needs-auth'` state instead of failing outright. Calling `authenticate()` completes the flow. It starts a one-shot callback server on the provider's loopback redirect URL, falling back to the next sequential ports when it's in use. The SDK then performs discovery and client registration at runtime. `onRedirectToAuthorization` receives the authorization URL so your application can open it in the user's browser. The token exchange finishes after the browser returns the authorization code:
|
|
851
851
|
|
|
852
852
|
```typescript
|
|
853
853
|
import { MCPClient, MCPOAuthClientProvider } from '@mastra/mcp'
|
|
@@ -884,9 +884,9 @@ try {
|
|
|
884
884
|
}
|
|
885
885
|
```
|
|
886
886
|
|
|
887
|
-
Concurrent `authenticate()` calls for the same server join the pending flow
|
|
887
|
+
Concurrent `authenticate()` calls for the same server join the pending flow. Different servers authenticate independently. With valid stored tokens the call reconnects without opening a browser.
|
|
888
888
|
|
|
889
|
-
Hosts that drive the flow themselves can capture the authorization code with the exported `createOAuthCallbackServer` helper, which binds a one-shot loopback server, validates the OAuth `state` parameter, and resolves with the code. It creates a plain HTTP server, so it
|
|
889
|
+
Hosts that drive the flow themselves can capture the authorization code with the exported `createOAuthCallbackServer` helper, which binds a one-shot loopback server, validates the OAuth `state` parameter, and resolves with the code. It creates a plain HTTP server, so it's only for local loopback redirects. Web applications that use an HTTPS redirect URL must host their own callback endpoint and drive the provider directly rather than using this helper:
|
|
890
890
|
|
|
891
891
|
```typescript
|
|
892
892
|
import { createOAuthCallbackServer, getCallbackUrlCandidates } from '@mastra/mcp'
|
|
@@ -1013,7 +1013,7 @@ const agent = new Agent({
|
|
|
1013
1013
|
id: 'multi-tool-agent',
|
|
1014
1014
|
name: 'Multi-tool Agent',
|
|
1015
1015
|
instructions: 'You have access to multiple tool servers.',
|
|
1016
|
-
model: 'openai/gpt-5.
|
|
1016
|
+
model: 'openai/gpt-5.6-sol',
|
|
1017
1017
|
tools: await mcp.listTools(),
|
|
1018
1018
|
})
|
|
1019
1019
|
|
|
@@ -1064,7 +1064,7 @@ const agent = new Agent({
|
|
|
1064
1064
|
id: 'multi-tool-agent',
|
|
1065
1065
|
name: 'Multi-tool Agent',
|
|
1066
1066
|
instructions: 'You help users check stocks and weather.',
|
|
1067
|
-
model: 'openai/gpt-5.
|
|
1067
|
+
model: 'openai/gpt-5.6-sol',
|
|
1068
1068
|
})
|
|
1069
1069
|
|
|
1070
1070
|
// Later, configure MCP with user-specific settings
|
|
@@ -1139,9 +1139,9 @@ MCPClient handles server connections gracefully:
|
|
|
1139
1139
|
2. Graceful server shutdown to prevent error messages during development
|
|
1140
1140
|
3. Proper cleanup of resources when disconnecting
|
|
1141
1141
|
|
|
1142
|
-
## Using custom fetch for
|
|
1142
|
+
## Using custom fetch for runtime-defined authentication
|
|
1143
1143
|
|
|
1144
|
-
For HTTP servers, you can provide a custom `fetch` function to handle
|
|
1144
|
+
For HTTP servers, you can provide a custom `fetch` function to handle runtime-defined authentication or request interception. It can also handle other custom behavior. This is particularly useful when you need to refresh tokens on each request or forward user credentials from the incoming request to the MCP server.
|
|
1145
1145
|
|
|
1146
1146
|
The custom `fetch` function receives an optional third `requestContext` parameter, which provides access to request-scoped data (e.g., authentication cookies, bearer tokens) set by middleware or passed during agent/tool execution. The `requestContext` is `null` during the initial connection handshake.
|
|
1147
1147
|
|
|
@@ -24,7 +24,7 @@ const myAgent = new Agent({
|
|
|
24
24
|
name: 'MyExampleAgent',
|
|
25
25
|
description: 'A generalist to help with basic questions.',
|
|
26
26
|
instructions: 'You are a helpful assistant.',
|
|
27
|
-
model: 'openai/gpt-5.
|
|
27
|
+
model: 'openai/gpt-5.6-sol',
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
const weatherTool = createTool({
|
|
@@ -101,20 +101,20 @@ A powerful feature of `MCPServer` is its ability to automatically expose your Ma
|
|
|
101
101
|
|
|
102
102
|
- **Description**: The generated tool's description will be in the format: "Ask agent `<AgentName>` a question. Original agent instructions: `<agent description>`".
|
|
103
103
|
- **Input**: The tool expects a single object argument with a `message` property (string): `{ message: "Your question for the agent" }`.
|
|
104
|
-
- **Execution**: When this tool is called, it invokes the `generate()` method
|
|
104
|
+
- **Execution**: When this tool is called, it invokes the corresponding agent's `generate()` method with the provided `query`.
|
|
105
105
|
- **Output**: The direct result from the agent's `generate()` method is returned as the output of the tool.
|
|
106
106
|
|
|
107
|
-
- **Name
|
|
107
|
+
- **Name collisions.** If an explicit tool defined in the `tools` configuration has the same name as an agent-derived tool (e.g., a tool named `ask_myAgentKey` alongside an agent keyed as `myAgentKey`), the _explicitly defined tool will take precedence_. The agent won't be converted into a tool in this conflicting case, and a warning will be logged.
|
|
108
108
|
|
|
109
109
|
This makes it straightforward to allow MCP clients to interact with your agents using natural language queries, like any other tool.
|
|
110
110
|
|
|
111
111
|
### Agent-to-Tool Conversion
|
|
112
112
|
|
|
113
|
-
When you provide agents in the `agents` configuration property, `MCPServer` will automatically create a corresponding tool for each agent. The tool will be
|
|
113
|
+
When you provide agents in the `agents` configuration property, `MCPServer` will automatically create a corresponding tool for each agent. The tool will be `ask_<agentIdentifier>`, where `<agentIdentifier>` is the key you used in the `agents` object.
|
|
114
114
|
|
|
115
115
|
The description for this generated tool will be: "Ask agent `<agent.name>` a question. Agent description: `<agent.description>`".
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
For an agent to be converted into a tool, it **must** have a non-empty `description` string property set in its configuration when it was instantiated (e.g., `new Agent({ id: 'my-agent', name: 'myAgent', description: 'This agent does X.', ... })`). If an agent is passed to `MCPServer` with a missing or empty `description`, an error will be thrown when the `MCPServer` is instantiated, and server setup will fail.
|
|
118
118
|
|
|
119
119
|
This allows you to quickly expose the generative capabilities of your agents through the MCP, enabling clients to "ask" your agents questions directly.
|
|
120
120
|
|
|
@@ -412,7 +412,7 @@ serve(async req => {
|
|
|
412
412
|
>
|
|
413
413
|
> This is still stateless: no `mcp-session-id` is required or persisted. It only enables notifications scoped to the current request (such as progress). The session-dependent features below remain unavailable.
|
|
414
414
|
>
|
|
415
|
-
>
|
|
415
|
+
> The following MCP features require session state or persistent connections and **won't work** in serverless mode (including with `serverlessStreaming: true`):
|
|
416
416
|
>
|
|
417
417
|
> - **Elicitation** - Interactive user input requests during tool execution require session management to route responses back to the correct client
|
|
418
418
|
> - **Resource subscriptions** - `resources/subscribe` and `resources/unsubscribe` need persistent connections to maintain subscription state
|
|
@@ -439,7 +439,7 @@ The `StreamableHTTPServerTransportOptions` object allows you to customize the be
|
|
|
439
439
|
|
|
440
440
|
**serverless** (`boolean`): If true, runs in stateless mode without session management. Each request is handled independently with a fresh server instance. Essential for serverless environments (Cloudflare Workers, Supabase Edge Functions, Vercel Edge, etc.) where sessions cannot persist between invocations. Defaults to false.
|
|
441
441
|
|
|
442
|
-
**serverlessStreaming** (`boolean`): If true, serverless requests use request-scoped SSE streaming instead of a buffered JSON response, allowing in-request notifications/progress to reach the client before the final result. Only takes effect together with serverless: true. Defaults to false (buffered JSON responses), which preserves backward-compatible behavior.
|
|
442
|
+
**serverlessStreaming** (`boolean`): If true, serverless requests use request-scoped SSE streaming instead of a buffered JSON response, allowing in-request notifications/progress to reach the client before the final result. Only takes effect together with serverless: true. Defaults to false (buffered JSON responses), which preserves backward-compatible behavior. It enables only request-scoped notifications such as progress; elicitation, subscriptions, and out-of-request notifications still require session state.
|
|
443
443
|
|
|
444
444
|
**sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return undefined to disable session management.
|
|
445
445
|
|
|
@@ -459,7 +459,7 @@ async close(): Promise<void>
|
|
|
459
459
|
|
|
460
460
|
### `getServerInfo()`
|
|
461
461
|
|
|
462
|
-
|
|
462
|
+
The method returns the server's basic information.
|
|
463
463
|
|
|
464
464
|
```typescript
|
|
465
465
|
getServerInfo(): ServerInfo
|
|
@@ -467,7 +467,7 @@ getServerInfo(): ServerInfo
|
|
|
467
467
|
|
|
468
468
|
### `getServerDetail()`
|
|
469
469
|
|
|
470
|
-
|
|
470
|
+
The method returns details about the server's information.
|
|
471
471
|
|
|
472
472
|
```typescript
|
|
473
473
|
getServerDetail(): ServerDetail
|
|
@@ -475,7 +475,7 @@ getServerDetail(): ServerDetail
|
|
|
475
475
|
|
|
476
476
|
### `getToolListInfo()`
|
|
477
477
|
|
|
478
|
-
|
|
478
|
+
The method returns the tools that were set up when you created the server. It's a read-only list, useful for debugging purposes.
|
|
479
479
|
|
|
480
480
|
```typescript
|
|
481
481
|
getToolListInfo(): ToolListInfo
|
|
@@ -483,7 +483,7 @@ getToolListInfo(): ToolListInfo
|
|
|
483
483
|
|
|
484
484
|
### `getToolInfo()`
|
|
485
485
|
|
|
486
|
-
|
|
486
|
+
The method returns details about a specific tool.
|
|
487
487
|
|
|
488
488
|
```typescript
|
|
489
489
|
getToolInfo(toolName: string): ToolInfo
|
|
@@ -565,7 +565,7 @@ Resources are identified by unique URIs (e.g., `file:///home/user/documents/repo
|
|
|
565
565
|
Clients can discover resources through:
|
|
566
566
|
|
|
567
567
|
1. **Direct resources**: Servers expose a list of concrete resources via a `resources/list` endpoint.
|
|
568
|
-
2. **Resource templates**: For
|
|
568
|
+
2. **Resource templates**: For runtime-defined resources, servers can expose URI templates (RFC 6570) that clients use to construct resource URIs.
|
|
569
569
|
|
|
570
570
|
To read a resource, clients make a `resources/read` request with the URI. Servers can also notify clients about changes to the resource list (`notifications/resources/list_changed`) or updates to specific resource content (`notifications/resources/updated`) if a client has subscribed to that resource.
|
|
571
571
|
|
|
@@ -659,7 +659,7 @@ await serverWithResources.resources.notifyUpdated({ uri: 'file://data.txt' })
|
|
|
659
659
|
|
|
660
660
|
#### `server.resources.notifyListChanged()`
|
|
661
661
|
|
|
662
|
-
Call this method when the
|
|
662
|
+
Call this method when the list of available resources has changed (e.g., a resource was added or removed). This will send a `notifications/resources/list_changed` message to clients, prompting them to re-fetch the list of resources.
|
|
663
663
|
|
|
664
664
|
```typescript
|
|
665
665
|
async server.resources.notifyListChanged(): Promise<void>
|
|
@@ -676,9 +676,9 @@ await serverWithResources.resources.notifyListChanged()
|
|
|
676
676
|
|
|
677
677
|
### What are MCP Prompts?
|
|
678
678
|
|
|
679
|
-
Prompts are reusable templates or workflows that MCP servers expose to clients. They can accept arguments
|
|
679
|
+
Prompts are reusable templates or workflows that MCP servers expose to clients. They can accept arguments and include resource context. They also support versioning and standardize LLM interactions.
|
|
680
680
|
|
|
681
|
-
Prompts are identified by a unique name (and optional version) and can be
|
|
681
|
+
Prompts are identified by a unique name (and optional version) and can be runtime-defined or static.
|
|
682
682
|
|
|
683
683
|
### `MCPServerPrompts` Type
|
|
684
684
|
|
|
@@ -773,7 +773,7 @@ If the available prompts change, your server can notify connected clients:
|
|
|
773
773
|
|
|
774
774
|
#### `server.prompts.notifyListChanged()`
|
|
775
775
|
|
|
776
|
-
Call this method when the
|
|
776
|
+
Call this method when the list of available prompts has changed (e.g., a prompt was added or removed). This will send a `notifications/prompts/list_changed` message to clients, prompting them to re-fetch the list of prompts.
|
|
777
777
|
|
|
778
778
|
```typescript
|
|
779
779
|
await serverWithPrompts.prompts.notifyListChanged()
|
|
@@ -793,7 +793,7 @@ await serverWithPrompts.prompts.notifyListChanged()
|
|
|
793
793
|
|
|
794
794
|
Tools are usually provided when constructing the `MCPServer`, but you can also add or remove tools while the server is running. The server exposes these operations through the `toolActions` property. When the tool list changes, connected clients receive a `notifications/tools/list_changed` message prompting them to re-fetch the tool list.
|
|
795
795
|
|
|
796
|
-
The property is
|
|
796
|
+
The property is `toolActions` because `tools()` is the method that returns the registered tool registry.
|
|
797
797
|
|
|
798
798
|
### `toolActions.add(tools)`
|
|
799
799
|
|
|
@@ -821,7 +821,7 @@ await server.toolActions.add({ searchTool })
|
|
|
821
821
|
|
|
822
822
|
### `toolActions.remove(toolIds)`
|
|
823
823
|
|
|
824
|
-
Removes tools from the running server by tool ID and notifies connected clients. Unknown tool IDs are ignored.
|
|
824
|
+
Removes tools from the running server by tool ID and notifies connected clients. Unknown tool IDs are ignored. A notification is sent only when at least one tool is removed.
|
|
825
825
|
|
|
826
826
|
```typescript
|
|
827
827
|
async server.toolActions.remove(toolIds: string[]): Promise<void>
|
|
@@ -847,7 +847,7 @@ When the server is registered with a Mastra instance, `toolActions.add()` and `t
|
|
|
847
847
|
|
|
848
848
|
## Logging
|
|
849
849
|
|
|
850
|
-
MCP servers can send structured log messages to clients using `notifications/message`. Clients control verbosity by sending a `logging/setLevel` request
|
|
850
|
+
MCP servers can send structured log messages to clients using `notifications/message`. Clients control verbosity by sending a `logging/setLevel` request. The server drops messages below the requested minimum level (following RFC 5424 severity ordering). The level is tracked per session, so different clients can request different verbosity.
|
|
851
851
|
|
|
852
852
|
### `sendLoggingMessage()`
|
|
853
853
|
|
|
@@ -937,7 +937,7 @@ The example at the beginning of this page also demonstrates how to instantiate `
|
|
|
937
937
|
|
|
938
938
|
### What's Elicitation?
|
|
939
939
|
|
|
940
|
-
Elicitation is a feature in the Model Context Protocol (MCP) that allows servers to request structured information from users.
|
|
940
|
+
Elicitation is a feature in the Model Context Protocol (MCP) that allows servers to request structured information from users. It supports interactive workflows where servers can collect additional data at runtime.
|
|
941
941
|
|
|
942
942
|
The `MCPServer` class automatically includes elicitation capabilities. Tools receive a `context.mcp` object in their `execute` function that includes an `elicitation.sendRequest()` method for requesting user input.
|
|
943
943
|
|
|
@@ -1126,7 +1126,7 @@ execute: async (inputData, context) => {
|
|
|
1126
1126
|
}
|
|
1127
1127
|
```
|
|
1128
1128
|
|
|
1129
|
-
|
|
1129
|
+
Elicitation is **session-aware** when using HTTP-based transports (SSE or HTTP). When multiple clients are connected to the same server, elicitation requests are routed to the client session that initiated the tool execution.
|
|
1130
1130
|
|
|
1131
1131
|
The `ElicitResult` type:
|
|
1132
1132
|
|