@mastra/mcp 1.15.1 → 1.16.0-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 +59 -0
- package/dist/client/actions/elicitation.d.ts +1 -1
- package/dist/client/actions/elicitation.d.ts.map +1 -1
- package/dist/client/actions/progress.d.ts +1 -1
- package/dist/client/actions/progress.d.ts.map +1 -1
- package/dist/client/actions/prompt.d.ts +1 -1
- package/dist/client/actions/prompt.d.ts.map +1 -1
- package/dist/client/actions/resource.d.ts +38 -11
- package/dist/client/actions/resource.d.ts.map +1 -1
- package/dist/client/client.d.ts +3 -2
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +50 -14
- package/dist/client/configuration.d.ts.map +1 -1
- package/dist/client/types.d.ts +65 -10
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/url-policy.d.ts +67 -0
- package/dist/client/url-policy.d.ts.map +1 -0
- package/dist/docs/SKILL.md +3 -3
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-connections-overview.md +94 -0
- package/dist/docs/references/docs-mcp-overview.md +229 -278
- package/dist/docs/references/reference-tools-mcp-client.md +54 -0
- package/dist/docs/references/reference-tools-mcp-server.md +1 -1
- package/dist/index.cjs +2435 -275
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2403 -243
- package/dist/index.js.map +1 -1
- package/dist/server/__tests__/mock-extra.d.ts +15 -0
- package/dist/server/__tests__/mock-extra.d.ts.map +1 -0
- package/dist/server/notificationBroadcast.d.ts +1 -1
- package/dist/server/notificationBroadcast.d.ts.map +1 -1
- package/dist/server/promptActions.d.ts +1 -1
- package/dist/server/promptActions.d.ts.map +1 -1
- package/dist/server/resourceActions.d.ts +1 -1
- package/dist/server/resourceActions.d.ts.map +1 -1
- package/dist/server/server.d.ts +10 -12
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/toolActions.d.ts +1 -1
- package/dist/server/toolActions.d.ts.map +1 -1
- package/dist/server/types.d.ts +7 -7
- package/dist/server/types.d.ts.map +1 -1
- package/dist/shared/oauth-types.d.ts +8 -6
- package/dist/shared/oauth-types.d.ts.map +1 -1
- package/package.json +18 -14
- package/dist/docs/references/docs-mcp-mcp-apps.md +0 -306
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.16.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Updated the MCP client and server to run on the MCP 2.0 packages. Request context, authentication, logging, and progress behavior are unchanged, so tools that read `context.mcp.extra.authInfo`, send progress, or use elicitation keep working as before. ([#18683](https://github.com/mastra-ai/mastra/pull/18683))
|
|
8
|
+
|
|
9
|
+
Tool schemas advertised over MCP no longer declare a draft-07 `$schema` dialect. The MCP 2.0 default validator rejects that dialect, which previously made tools with output schemas fail on the client.
|
|
10
|
+
|
|
11
|
+
**If you pass a custom schema validator**
|
|
12
|
+
|
|
13
|
+
The optional `jsonSchemaValidator` option now takes its validator from the MCP packages. Update the import path:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// Before
|
|
17
|
+
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/cfworker';
|
|
18
|
+
|
|
19
|
+
// After
|
|
20
|
+
import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/client/validators/cf-worker';
|
|
21
|
+
|
|
22
|
+
const mcp = new MCPClient({
|
|
23
|
+
servers: {
|
|
24
|
+
weather: { url: new URL('https://example.com/mcp'), jsonSchemaValidator: new CfWorkerJsonSchemaValidator() },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**If you import MCP protocol types directly**
|
|
30
|
+
|
|
31
|
+
Types re-exported by `@mastra/mcp` (such as `ToolAnnotations`, `LoggingLevel`, and the OAuth helpers) are unchanged and need no edits. Only imports that reached past `@mastra/mcp` into `@modelcontextprotocol/sdk` need repointing to `@modelcontextprotocol/client` or `@modelcontextprotocol/server`.
|
|
32
|
+
|
|
33
|
+
- Add opt-in security hardening options to the MCP client. Both options are opt-in; default behavior is unchanged. ([#20868](https://github.com/mastra-ai/mastra/pull/20868))
|
|
34
|
+
|
|
35
|
+
- `allowedHosts` on HTTP server configs restricts which hosts the client's HTTP requests may target, covering the initial connection, the SSE fallback, and OAuth discovery. On the default fetch path redirect hops are blocked before they are sent; with a custom `fetch`, the final response URL is validated after the request runs, so custom fetch implementations must enforce redirect policy themselves when preventing outbound contact is required.
|
|
36
|
+
- `inheritDefaultEnv: false` on stdio server configs stops the subprocess from inheriting the SDK's default environment variables; only the entries you list in `env` are passed.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
const mcp = new MCPClient({
|
|
40
|
+
servers: {
|
|
41
|
+
weather: {
|
|
42
|
+
url: new URL('https://weather.example/mcp'),
|
|
43
|
+
allowedHosts: ['weather.example'],
|
|
44
|
+
},
|
|
45
|
+
local: {
|
|
46
|
+
command: 'npx',
|
|
47
|
+
args: ['tsx', 'stdio-server.ts'],
|
|
48
|
+
inheritDefaultEnv: false,
|
|
49
|
+
env: { WEATHER_API_KEY: process.env.WEATHER_API_KEY! },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Fix SSE transport fallback against MCP 2.0 servers. The Streamable HTTP transport reports non-OK responses as `SdkHttpError`, which carries the HTTP status on `status` while `code` holds a string error code, so the fallback check read a string where it expected a status number and rethrew instead of retrying over the deprecated HTTP+SSE transport. Servers that only speak HTTP+SSE are reachable again. ([#18683](https://github.com/mastra-ai/mastra/pull/18683))
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [[`e7109ee`](https://github.com/mastra-ai/mastra/commit/e7109ee6f731bacc79c885906f3c7dca8d8f013a), [`772c0c8`](https://github.com/mastra-ai/mastra/commit/772c0c897cec383258de2e6178147f8014767c7b), [`578bf2e`](https://github.com/mastra-ai/mastra/commit/578bf2e6a88e9d5b8bf502204e15a95dfbb679ae), [`06b2d87`](https://github.com/mastra-ai/mastra/commit/06b2d87e63bcdd0ed59215c6789692b9b12de376), [`ac01d63`](https://github.com/mastra-ai/mastra/commit/ac01d6355974aec73fdb8781449ed12bac582094), [`a810a05`](https://github.com/mastra-ai/mastra/commit/a810a058f62ad407cfc1701e0be36ae91145d7cf), [`f8da216`](https://github.com/mastra-ai/mastra/commit/f8da21633e7eb0e31c9ce0fc30567870d19416d3), [`6104347`](https://github.com/mastra-ai/mastra/commit/61043473ba6bfd0a25156824e853e13165562e6c), [`45bfb88`](https://github.com/mastra-ai/mastra/commit/45bfb88fd52f1dd3be20e2a38905777c96499c90), [`e3b9307`](https://github.com/mastra-ai/mastra/commit/e3b9307098daefbfae2a52ae2ef51bc9fc701190), [`d6834c5`](https://github.com/mastra-ai/mastra/commit/d6834c5a7866b16734d23900163c2414ed70d791), [`c52d346`](https://github.com/mastra-ai/mastra/commit/c52d3462ec831a5d95926ecd3d3373f5928ad2e5), [`0023e79`](https://github.com/mastra-ai/mastra/commit/0023e7919431078280abd11c89d1edeae35fcc69), [`c2ad51e`](https://github.com/mastra-ai/mastra/commit/c2ad51e2467f901eecba8c9f4a45e22a50bd7c18), [`3dc97ea`](https://github.com/mastra-ai/mastra/commit/3dc97ea415fad353b48a13095fad1835933cc12a), [`3d01cd3`](https://github.com/mastra-ai/mastra/commit/3d01cd387321b6f9c5cac31d487c84bf51b19c78), [`7bf3086`](https://github.com/mastra-ai/mastra/commit/7bf308663f0115ca74ad20554ade740f06640859), [`a8dd139`](https://github.com/mastra-ai/mastra/commit/a8dd1391a9fe9a6632c25809ef236980afa9a020), [`e5786be`](https://github.com/mastra-ai/mastra/commit/e5786be02bb903073082bd9d6da880ebaacc343f), [`2093fbd`](https://github.com/mastra-ai/mastra/commit/2093fbd53bb744bae19ec89f6d73db9a66fbe8a7), [`e7a5da4`](https://github.com/mastra-ai/mastra/commit/e7a5da4ef8e4dd452d2f232961b4e682a85ffe43), [`7b4393d`](https://github.com/mastra-ai/mastra/commit/7b4393d557411fdcf07b0e30e5acaf7cc85154ae)]:
|
|
60
|
+
- @mastra/core@1.58.0-alpha.1
|
|
61
|
+
|
|
3
62
|
## 1.15.1
|
|
4
63
|
|
|
5
64
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
-
import type { ElicitRequest, ElicitResult } from '@modelcontextprotocol/
|
|
2
|
+
import type { ElicitRequest, ElicitResult } from '@modelcontextprotocol/client';
|
|
3
3
|
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface ElicitationClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../../src/client/actions/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../../../src/client/actions/elicitation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,8BAA8B;IACtC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;;;;;GAMG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;OAEG;gBACS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,8BAA8B;IAK9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACI,SAAS,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;CAG7F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
-
import type { ProgressNotification } from '@modelcontextprotocol/
|
|
2
|
+
import type { ProgressNotification } from '@modelcontextprotocol/client';
|
|
3
3
|
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface ProgressClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/client/actions/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/client/actions/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,2BAA2B;IACnC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,2BAA2B;IAK3D;;;OAGG;IACI,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,IAAI,GAAG,IAAI;CAGjF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
-
import type { GetPromptResult, Prompt } from '@modelcontextprotocol/
|
|
2
|
+
import type { GetPromptResult, Prompt } from '@modelcontextprotocol/client';
|
|
3
3
|
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface PromptClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/client/actions/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/client/actions/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,UAAU,yBAAyB;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;OAEG;gBACS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAKzD;;;;;;;;;;;;;;;OAeG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IA2BtC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACU,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAIxG;;;;;;;;;;;;;;;OAeG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
-
import type { Resource,
|
|
2
|
+
import type { Resource, ResourceTemplateType } from '@modelcontextprotocol/client';
|
|
3
3
|
import type { InternalMastraMCPClient } from '../client.js';
|
|
4
4
|
interface ResourceClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
@@ -53,7 +53,7 @@ export declare class ResourceClientActions {
|
|
|
53
53
|
* });
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
templates(): Promise<
|
|
56
|
+
templates(): Promise<ResourceTemplateType[]>;
|
|
57
57
|
/**
|
|
58
58
|
* Reads the content of a specific resource from the MCP server.
|
|
59
59
|
*
|
|
@@ -86,9 +86,18 @@ export declare class ResourceClientActions {
|
|
|
86
86
|
})[];
|
|
87
87
|
_meta?: {
|
|
88
88
|
[x: string]: unknown;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
90
|
+
version: string;
|
|
91
|
+
name: string;
|
|
92
|
+
websiteUrl?: string | undefined;
|
|
93
|
+
description?: string | undefined;
|
|
94
|
+
icons?: {
|
|
95
|
+
src: string;
|
|
96
|
+
mimeType?: string | undefined;
|
|
97
|
+
sizes?: string[] | undefined;
|
|
98
|
+
theme?: "light" | "dark" | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
title?: string | undefined;
|
|
92
101
|
} | undefined;
|
|
93
102
|
} | undefined;
|
|
94
103
|
}>;
|
|
@@ -110,9 +119,18 @@ export declare class ResourceClientActions {
|
|
|
110
119
|
subscribe(uri: string): Promise<{
|
|
111
120
|
_meta?: {
|
|
112
121
|
[x: string]: unknown;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
123
|
+
version: string;
|
|
124
|
+
name: string;
|
|
125
|
+
websiteUrl?: string | undefined;
|
|
126
|
+
description?: string | undefined;
|
|
127
|
+
icons?: {
|
|
128
|
+
src: string;
|
|
129
|
+
mimeType?: string | undefined;
|
|
130
|
+
sizes?: string[] | undefined;
|
|
131
|
+
theme?: "light" | "dark" | undefined;
|
|
132
|
+
}[] | undefined;
|
|
133
|
+
title?: string | undefined;
|
|
116
134
|
} | undefined;
|
|
117
135
|
} | undefined;
|
|
118
136
|
}>;
|
|
@@ -133,9 +151,18 @@ export declare class ResourceClientActions {
|
|
|
133
151
|
unsubscribe(uri: string): Promise<{
|
|
134
152
|
_meta?: {
|
|
135
153
|
[x: string]: unknown;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
155
|
+
version: string;
|
|
156
|
+
name: string;
|
|
157
|
+
websiteUrl?: string | undefined;
|
|
158
|
+
description?: string | undefined;
|
|
159
|
+
icons?: {
|
|
160
|
+
src: string;
|
|
161
|
+
mimeType?: string | undefined;
|
|
162
|
+
sizes?: string[] | undefined;
|
|
163
|
+
theme?: "light" | "dark" | undefined;
|
|
164
|
+
}[] | undefined;
|
|
165
|
+
title?: string | undefined;
|
|
139
166
|
} | undefined;
|
|
140
167
|
} | undefined;
|
|
141
168
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/client/actions/resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,q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OAAO,CAAC,IAAI,CAAC;CAG/D"}
|
package/dist/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Stream } from 'node:stream';
|
|
2
2
|
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { Tool } from '@mastra/core/tools';
|
|
4
|
-
import type { EmptyResult, GetPromptResult, ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult } from '@modelcontextprotocol/
|
|
4
|
+
import type { EmptyResult, GetPromptResult, ListPromptsResult, ListResourcesResult, ListResourceTemplatesResult, ReadResourceResult } from '@modelcontextprotocol/client';
|
|
5
5
|
import { ElicitationClientActions } from './actions/elicitation.js';
|
|
6
6
|
import { ProgressClientActions } from './actions/progress.js';
|
|
7
7
|
import { PromptClientActions } from './actions/prompt.js';
|
|
@@ -106,6 +106,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
106
106
|
* the updated list.
|
|
107
107
|
*/
|
|
108
108
|
sendRootsListChanged(): Promise<void>;
|
|
109
|
+
private buildStdioEnv;
|
|
109
110
|
private connectStdio;
|
|
110
111
|
private connectHttp;
|
|
111
112
|
/**
|
|
@@ -243,7 +244,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
243
244
|
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
244
245
|
private convertInputSchema;
|
|
245
246
|
/**
|
|
246
|
-
* Wraps the output schema with a validator that always succeeds. The MCP
|
|
247
|
+
* Wraps the output schema with a validator that always succeeds. The MCP client validates
|
|
247
248
|
* structuredContent via AJV; the JSON schema is surfaced here for documentation only.
|
|
248
249
|
*/
|
|
249
250
|
private convertOutputSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CA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;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAU/C;;;;OAIG;IACG,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAQvG;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE;;;OAGG;IACH,qCAAqC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOhE,qCAAqC,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAO3E,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAoB/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;IAMhC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAcrB,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAgMhE,OAAO,CAAC,mBAAmB;CAQ5B"}
|
|
@@ -2,7 +2,7 @@ import type { Stream } from 'node:stream';
|
|
|
2
2
|
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { MCPServerBase } from '@mastra/core/mcp';
|
|
4
4
|
import type { Tool } from '@mastra/core/tools';
|
|
5
|
-
import type { ElicitRequest, ElicitResult, ProgressNotification, Prompt, Resource,
|
|
5
|
+
import type { ElicitRequest, ElicitResult, ProgressNotification, Prompt, Resource, ResourceTemplateType } from '@modelcontextprotocol/client';
|
|
6
6
|
import type { MastraMCPServerDefinition, MCPServerAuthState } from './client.js';
|
|
7
7
|
/**
|
|
8
8
|
* Configuration options for creating an MCPClient instance.
|
|
@@ -210,7 +210,7 @@ export declare class MCPClient extends MastraBase {
|
|
|
210
210
|
* console.log(templates.weatherServer); // Array of resource templates
|
|
211
211
|
* ```
|
|
212
212
|
*/
|
|
213
|
-
templates: () => Promise<Record<string,
|
|
213
|
+
templates: () => Promise<Record<string, ResourceTemplateType[]>>;
|
|
214
214
|
/**
|
|
215
215
|
* Reads the content of a specific resource from a server.
|
|
216
216
|
*
|
|
@@ -244,9 +244,18 @@ export declare class MCPClient extends MastraBase {
|
|
|
244
244
|
})[];
|
|
245
245
|
_meta?: {
|
|
246
246
|
[x: string]: unknown;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
248
|
+
version: string;
|
|
249
|
+
name: string;
|
|
250
|
+
websiteUrl?: string | undefined;
|
|
251
|
+
description?: string | undefined;
|
|
252
|
+
icons?: {
|
|
253
|
+
src: string;
|
|
254
|
+
mimeType?: string | undefined;
|
|
255
|
+
sizes?: string[] | undefined;
|
|
256
|
+
theme?: "light" | "dark" | undefined;
|
|
257
|
+
}[] | undefined;
|
|
258
|
+
title?: string | undefined;
|
|
250
259
|
} | undefined;
|
|
251
260
|
} | undefined;
|
|
252
261
|
}>;
|
|
@@ -266,9 +275,18 @@ export declare class MCPClient extends MastraBase {
|
|
|
266
275
|
subscribe: (serverName: string, uri: string) => Promise<{
|
|
267
276
|
_meta?: {
|
|
268
277
|
[x: string]: unknown;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
279
|
+
version: string;
|
|
280
|
+
name: string;
|
|
281
|
+
websiteUrl?: string | undefined;
|
|
282
|
+
description?: string | undefined;
|
|
283
|
+
icons?: {
|
|
284
|
+
src: string;
|
|
285
|
+
mimeType?: string | undefined;
|
|
286
|
+
sizes?: string[] | undefined;
|
|
287
|
+
theme?: "light" | "dark" | undefined;
|
|
288
|
+
}[] | undefined;
|
|
289
|
+
title?: string | undefined;
|
|
272
290
|
} | undefined;
|
|
273
291
|
} | undefined;
|
|
274
292
|
}>;
|
|
@@ -288,9 +306,18 @@ export declare class MCPClient extends MastraBase {
|
|
|
288
306
|
unsubscribe: (serverName: string, uri: string) => Promise<{
|
|
289
307
|
_meta?: {
|
|
290
308
|
[x: string]: unknown;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
309
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
310
|
+
version: string;
|
|
311
|
+
name: string;
|
|
312
|
+
websiteUrl?: string | undefined;
|
|
313
|
+
description?: string | undefined;
|
|
314
|
+
icons?: {
|
|
315
|
+
src: string;
|
|
316
|
+
mimeType?: string | undefined;
|
|
317
|
+
sizes?: string[] | undefined;
|
|
318
|
+
theme?: "light" | "dark" | undefined;
|
|
319
|
+
}[] | undefined;
|
|
320
|
+
title?: string | undefined;
|
|
294
321
|
} | undefined;
|
|
295
322
|
} | undefined;
|
|
296
323
|
}>;
|
|
@@ -483,9 +510,18 @@ export declare class MCPClient extends MastraBase {
|
|
|
483
510
|
}[];
|
|
484
511
|
_meta?: {
|
|
485
512
|
[x: string]: unknown;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
513
|
+
"io.modelcontextprotocol/serverInfo"?: {
|
|
514
|
+
version: string;
|
|
515
|
+
name: string;
|
|
516
|
+
websiteUrl?: string | undefined;
|
|
517
|
+
description?: string | undefined;
|
|
518
|
+
icons?: {
|
|
519
|
+
src: string;
|
|
520
|
+
mimeType?: string | undefined;
|
|
521
|
+
sizes?: string[] | undefined;
|
|
522
|
+
theme?: "light" | "dark" | undefined;
|
|
523
|
+
}[] | undefined;
|
|
524
|
+
title?: string | undefined;
|
|
489
525
|
} | undefined;
|
|
490
526
|
} | undefined;
|
|
491
527
|
description?: string | undefined;
|
|
@@ -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,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,QAAQ,EACR,
|
|
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,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,MAAM,EACN,QAAQ,EACR,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAgC9E;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wHAAwH;IACxH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACnD,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,cAAc,CAAS;IAC/B,O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U,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAMzD,OAAO,CAAC,eAAe;YAQT,iBAAiB;YAiCjB,kBAAkB;IAchC,OAAO,CAAC,kBAAkB;YAyBZ,2BAA2B;YAI3B,kBAAkB;YAIlB,iBAAiB;CAuBhC"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { IOType } from 'node:child_process';
|
|
2
2
|
import type { RequestContext } from '@mastra/core/di';
|
|
3
|
-
import type { SSEClientTransportOptions } from '@modelcontextprotocol/
|
|
4
|
-
|
|
5
|
-
export type {
|
|
6
|
-
import type { ClientCapabilities, ElicitRequest, ElicitResult, LoggingLevel, ProgressNotification, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
export type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
-
import type { jsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/types.js';
|
|
3
|
+
import type { SSEClientTransportOptions, StreamableHTTPClientTransportOptions, ClientCapabilities, ElicitRequest, ElicitResult, LoggingLevel, ProgressNotification, ToolAnnotations, jsonSchemaValidator } from '@modelcontextprotocol/client';
|
|
4
|
+
export type { FetchLike } from '@modelcontextprotocol/client';
|
|
5
|
+
export type { ToolAnnotations } from '@modelcontextprotocol/client';
|
|
9
6
|
/**
|
|
10
7
|
* Extended fetch function type that receives the current request context as a third argument.
|
|
11
8
|
*
|
|
@@ -35,7 +32,7 @@ import type { jsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/t
|
|
|
35
32
|
* ```
|
|
36
33
|
*/
|
|
37
34
|
export type MastraFetchLike = (url: string | URL, init?: RequestInit, requestContext?: RequestContext | null) => Promise<Response>;
|
|
38
|
-
export type { LoggingLevel } from '@modelcontextprotocol/
|
|
35
|
+
export type { LoggingLevel } from '@modelcontextprotocol/client';
|
|
39
36
|
/**
|
|
40
37
|
* Log message structure for MCP client logging.
|
|
41
38
|
*/
|
|
@@ -216,18 +213,18 @@ export type BaseServerOptions = {
|
|
|
216
213
|
*/
|
|
217
214
|
onToolError?: 'throw' | 'return';
|
|
218
215
|
/**
|
|
219
|
-
* Optional custom JSON Schema validator forwarded to the underlying MCP
|
|
216
|
+
* Optional custom JSON Schema validator forwarded to the underlying MCP
|
|
220
217
|
* client. Use this to opt into a non-default validator implementation.
|
|
221
218
|
*
|
|
222
219
|
* Pass `CfWorkerJsonSchemaValidator` (from
|
|
223
|
-
* `@modelcontextprotocol/
|
|
220
|
+
* `@modelcontextprotocol/client/validators/cf-worker`) when running in
|
|
224
221
|
* Cloudflare Workers / V8 isolates: the default `AjvJsonSchemaValidator`
|
|
225
222
|
* compiles validators with `new Function(...)`, which workerd refuses to
|
|
226
223
|
* evaluate when a tool advertises an `outputSchema`.
|
|
227
224
|
*
|
|
228
225
|
* @example
|
|
229
226
|
* ```typescript
|
|
230
|
-
* import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/
|
|
227
|
+
* import { CfWorkerJsonSchemaValidator } from '@modelcontextprotocol/client/validators/cf-worker';
|
|
231
228
|
*
|
|
232
229
|
* const mcp = new MCPClient({
|
|
233
230
|
* servers: {
|
|
@@ -276,6 +273,23 @@ export type StdioServerDefinition = BaseServerOptions & {
|
|
|
276
273
|
args?: string[];
|
|
277
274
|
/** Optional environment variables for the subprocess */
|
|
278
275
|
env?: Record<string, string>;
|
|
276
|
+
/**
|
|
277
|
+
* Whether the subprocess environment starts from the MCP SDK's default
|
|
278
|
+
* inherited environment. Defaults to `true`.
|
|
279
|
+
*
|
|
280
|
+
* The default is NOT the full `process.env`: the SDK's
|
|
281
|
+
* `getDefaultEnvironment()` inherits only a curated platform whitelist —
|
|
282
|
+
* on POSIX: `HOME`, `LOGNAME`, `PATH`, `SHELL`, `TERM`, `USER`; on Windows:
|
|
283
|
+
* `APPDATA`, `HOMEDRIVE`, `HOMEPATH`, `LOCALAPPDATA`, `PATH`,
|
|
284
|
+
* `PROCESSOR_ARCHITECTURE`, `SYSTEMDRIVE`, `SYSTEMROOT`, `TEMP`, `USERNAME`,
|
|
285
|
+
* `USERPROFILE` — and skips functions and variables starting with `()`.
|
|
286
|
+
*
|
|
287
|
+
* When `false`, the subprocess environment base is empty (`{}`) and only the
|
|
288
|
+
* variables explicitly listed in `env` are passed to the subprocess. Note
|
|
289
|
+
* that a subprocess without `PATH` may fail to spawn commands that are not
|
|
290
|
+
* absolute paths.
|
|
291
|
+
*/
|
|
292
|
+
inheritDefaultEnv?: boolean;
|
|
279
293
|
/**
|
|
280
294
|
* How to handle stderr of the child process. Matches the semantics of Node's `child_process.spawn`.
|
|
281
295
|
*
|
|
@@ -298,6 +312,7 @@ export type StdioServerDefinition = BaseServerOptions & {
|
|
|
298
312
|
sessionId?: never;
|
|
299
313
|
connectTimeout?: never;
|
|
300
314
|
fetch?: never;
|
|
315
|
+
allowedHosts?: never;
|
|
301
316
|
};
|
|
302
317
|
/**
|
|
303
318
|
* Configuration for MCP servers using HTTP-based transport (Streamable HTTP or SSE fallback).
|
|
@@ -314,6 +329,7 @@ export type HttpServerDefinition = BaseServerOptions & {
|
|
|
314
329
|
command?: never;
|
|
315
330
|
args?: never;
|
|
316
331
|
env?: never;
|
|
332
|
+
inheritDefaultEnv?: never;
|
|
317
333
|
stderr?: never;
|
|
318
334
|
cwd?: never;
|
|
319
335
|
/**
|
|
@@ -349,6 +365,45 @@ export type HttpServerDefinition = BaseServerOptions & {
|
|
|
349
365
|
* ```
|
|
350
366
|
*/
|
|
351
367
|
fetch?: MastraFetchLike;
|
|
368
|
+
/**
|
|
369
|
+
* Optional allowlist of hosts this server's HTTP requests may target.
|
|
370
|
+
*
|
|
371
|
+
* When set, every outgoing request made on behalf of this server (initial
|
|
372
|
+
* connect, Streamable HTTP POSTs, the SSE fallback and its event stream,
|
|
373
|
+
* OAuth discovery/token requests routed through the transport fetch, and
|
|
374
|
+
* every redirect hop) is checked against this list. When unset, no
|
|
375
|
+
* restriction applies (current behavior).
|
|
376
|
+
*
|
|
377
|
+
* Matching semantics:
|
|
378
|
+
* - Entries are host values matched against `URL.host` — the hostname plus
|
|
379
|
+
* the port when the URL carries a non-default port. WHATWG URL elides
|
|
380
|
+
* default ports, so `https://x.com:443` has host `x.com` and matches the
|
|
381
|
+
* entry `'x.com'`, not `'x.com:443'`. Examples: `'api.example.com'`,
|
|
382
|
+
* `'localhost:8080'`.
|
|
383
|
+
* - Matching is exact and case-insensitive on the hostname. No wildcards.
|
|
384
|
+
* - The URL scheme is NOT checked — matching is host-only, so `http://` and
|
|
385
|
+
* `https://` URLs to an allowed host both pass. The `Authorization` header
|
|
386
|
+
* is still dropped on any cross-origin redirect hop (scheme, host, or port
|
|
387
|
+
* change), so a same-host scheme downgrade never re-sends credentials.
|
|
388
|
+
* - An empty array (`allowedHosts: []`) denies all hosts.
|
|
389
|
+
*
|
|
390
|
+
* Enforcement strength varies by path:
|
|
391
|
+
* - On the default path (no custom `fetch`), requests to disallowed hosts —
|
|
392
|
+
* including redirect hops, via manual redirect following — are blocked
|
|
393
|
+
* BEFORE being sent.
|
|
394
|
+
* - When a custom `fetch` (or a caller-supplied `eventSourceInit.fetch`) is
|
|
395
|
+
* in play, the initial URL is checked before the request, but redirect
|
|
396
|
+
* hops are validated post-hoc via `response.url`: the outbound hop may
|
|
397
|
+
* occur, but the response never reaches the caller or the model. A
|
|
398
|
+
* hand-built `Response` with an empty `response.url` skips the post-hoc
|
|
399
|
+
* check (documented limitation — custom fetches legitimately construct
|
|
400
|
+
* such responses).
|
|
401
|
+
*
|
|
402
|
+
* OAuth note: the SDK routes OAuth discovery and token requests through the
|
|
403
|
+
* transport's fetch, so when using an `authProvider` whose authorization
|
|
404
|
+
* server lives on a different host, that host must also be allowlisted.
|
|
405
|
+
*/
|
|
406
|
+
allowedHosts?: string[];
|
|
352
407
|
/** Optional request configuration for HTTP requests (optional when `fetch` is provided) */
|
|
353
408
|
requestInit?: StreamableHTTPClientTransportOptions['requestInit'];
|
|
354
409
|
/** Optional configuration for SSE fallback (required when using custom headers with SSE, optional when `fetch` is provided) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,yBAAyB,EACzB,oCAAoC,EACpC,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,EAClB,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,KACnC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAGvB,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,KAAK,EAAE,YAAY,CAAC;IACpB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,SAAS,EAAE,IAAI,CAAC;IAChB,oDAAoD;IACpD,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,OAAO,CAAC,EAA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AM,8BAA8B,GAAG;IAC3C,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,yBAAyB,CAAC;IAClC,8DAA8D;IAC9D,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal structural view of a fetch response. Both the platform `Response`
|
|
3
|
+
* and the eventsource package's `FetchLikeResponse` (used for a caller-supplied
|
|
4
|
+
* `eventSourceInit.fetch`) satisfy it.
|
|
5
|
+
*/
|
|
6
|
+
type ResponseLike = {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly body?: unknown;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Assert that the URL's host is in the allowlist.
|
|
12
|
+
*
|
|
13
|
+
* Matching is exact and case-insensitive against `URL.host` (hostname plus
|
|
14
|
+
* port when the URL carries a non-default port — WHATWG URL elides default
|
|
15
|
+
* ports, so `https://x.com:443` has host `x.com`). No wildcards. An empty
|
|
16
|
+
* allowlist denies every host. The URL scheme is not checked.
|
|
17
|
+
*
|
|
18
|
+
* @returns the parsed URL, for callers that need it.
|
|
19
|
+
* @throws {MastraError} `MCP_CLIENT_HOST_NOT_ALLOWED` when the host is not allowed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assertHostAllowed(url: string | URL, allowedHosts: readonly string[], detail?: string): URL;
|
|
22
|
+
/**
|
|
23
|
+
* Post-hoc validation for responses produced by a caller-supplied fetch.
|
|
24
|
+
*
|
|
25
|
+
* A custom fetch may auto-follow redirects, so the final URL can differ from
|
|
26
|
+
* the (already validated) request URL. When `response.url` lands on a
|
|
27
|
+
* disallowed host the response is discarded by throwing — the outbound hop
|
|
28
|
+
* already happened, but the data never reaches the caller or the model.
|
|
29
|
+
*
|
|
30
|
+
* Limitation (fail-open by design): a hand-built or proxied `Response` with an
|
|
31
|
+
* empty `response.url` skips this check, because custom fetch implementations
|
|
32
|
+
* legitimately construct such responses.
|
|
33
|
+
*/
|
|
34
|
+
export declare function assertResponseHostAllowed<R extends ResponseLike>(response: R, allowedHosts: readonly string[]): R;
|
|
35
|
+
export declare function isUrlPolicyError(error: unknown): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Wrap a caller-supplied fetch with the allowedHosts policy: the request URL is
|
|
38
|
+
* validated before the wrapped fetch runs, and the response is validated
|
|
39
|
+
* post-hoc via {@link assertResponseHostAllowed}.
|
|
40
|
+
*
|
|
41
|
+
* Variadic over the trailing arguments deliberately: the same wrapper serves
|
|
42
|
+
* the 3-arg `MastraFetchLike` (url, init, requestContext) and the 2-arg
|
|
43
|
+
* eventsource stream fetch (url, init).
|
|
44
|
+
*/
|
|
45
|
+
export declare function wrapFetchWithHostPolicy<Args extends [url: string | URL, ...rest: any[]], R extends ResponseLike>(fetchImpl: (...args: Args) => Promise<R>, allowedHosts: readonly string[]): (...args: Args) => Promise<R>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch with manual redirect handling so every redirect hop is validated
|
|
48
|
+
* against the allowlist BEFORE the hop request is sent. Platform fetch follows
|
|
49
|
+
* redirects transparently, which would bypass a per-call host check.
|
|
50
|
+
*
|
|
51
|
+
* Semantics follow platform conventions:
|
|
52
|
+
* - `Location` is resolved against the current hop's URL (relative Locations are legal).
|
|
53
|
+
* - 303 switches the method to GET and drops the body; 301/302 on POST do the same.
|
|
54
|
+
* - 307/308 preserve method and body; a non-replayable body (anything other
|
|
55
|
+
* than a string) throws rather than silently re-sending an empty body.
|
|
56
|
+
* - 301/302 on non-POST methods preserve the method and body, matching
|
|
57
|
+
* platform behavior.
|
|
58
|
+
* - The `Authorization` header is not carried across hops to a different
|
|
59
|
+
* origin (scheme, host, or port change), matching the WHATWG Fetch
|
|
60
|
+
* credential-stripping rule — same host over a downgraded scheme still
|
|
61
|
+
* drops the header.
|
|
62
|
+
* - A redirect status with no `Location` header throws.
|
|
63
|
+
* - More than {@link MAX_REDIRECT_HOPS} hops throws.
|
|
64
|
+
*/
|
|
65
|
+
export declare function fetchFollowingAllowedRedirects(fetchImpl: (url: string | URL, init?: RequestInit) => Promise<Response>, url: string | URL, init: RequestInit | undefined, allowedHosts: readonly string[]): Promise<Response>;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=url-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-policy.d.ts","sourceRoot":"","sources":["../../src/client/url-policy.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,KAAK,YAAY,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAgDtE;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,YAAY,EAAE,SAAS,MAAM,EAAE,EAC/B,MAAM,SAA8B,GACnC,GAAG,CAML;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,YAAY,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,CAcjH;AAmBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS,YAAY,EAC9G,SAAS,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EACxC,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAM/B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,EACvE,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAoEnB"}
|
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.
|
|
6
|
+
version: "1.16.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,8 +16,8 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [
|
|
20
|
-
- [MCP overview](references/docs-mcp-overview.md) -
|
|
19
|
+
- [Connections overview](references/docs-connections-overview.md) - Connect Mastra to remote agents, coding agents, provider software development kit runtimes, and external tools and resources.
|
|
20
|
+
- [MCP overview](references/docs-mcp-overview.md) - Connect Mastra agents to external MCP servers, expose Mastra tools through MCPServer, and build interactive MCP Apps for Studio.
|
|
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
|