@mastra/mcp 1.13.0 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/dist/client/client.d.ts +5 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-tools-mcp-client.md +2 -2
- package/dist/docs/references/reference-tools-mcp-server.md +12 -12
- package/dist/index.cjs +31247 -263
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31156 -172
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.13.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed MCP client tools missing output schemas in tool listings. Fixes #18850. ([#18854](https://github.com/mastra-ai/mastra/pull/18854))
|
|
8
|
+
|
|
9
|
+
MCP tools that declare an `outputSchema` now expose that schema on the Mastra tool wrapper, so Studio and other consumers can document expected tool outputs.
|
|
10
|
+
|
|
11
|
+
Mastra does not re-validate MCP tool results. The MCP SDK still validates `structuredContent` via AJV. This keeps full `CallToolResult` envelopes and extra fields intact while making output shapes visible again.
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
const tools = await mcp.listTools();
|
|
15
|
+
const outputSchema = tools['weather_getForecast'].outputSchema?.['~standard'].jsonSchema.output({
|
|
16
|
+
target: 'draft-07',
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`b291760`](https://github.com/mastra-ai/mastra/commit/b291760df9d6c7e4fc72606c8f0a4af2cf6e946c), [`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`6ef59fe`](https://github.com/mastra-ai/mastra/commit/6ef59fef1da52ed8da5fbb2a892c71cf4fb6c739), [`4039488`](https://github.com/mastra-ai/mastra/commit/403948898af7293198d9e8b3e7fb47f623c78b94), [`29b7ea6`](https://github.com/mastra-ai/mastra/commit/29b7ea64e72b5523d5bdcbd34ee03d2b854d54e1), [`b2c9d70`](https://github.com/mastra-ai/mastra/commit/b2c9d70757207fb01a9069549e69b6f0d73a6636), [`a51c63d`](https://github.com/mastra-ai/mastra/commit/a51c63d8ee639e4daeba2a0be093efa6a1b5e52f), [`252f63d`](https://github.com/mastra-ai/mastra/commit/252f63d8fec723955adb2202be2f01a75ad0e69c), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`e2b9f33`](https://github.com/mastra-ai/mastra/commit/e2b9f33456fd638eca555f9466c6519d8d049666), [`10959d5`](https://github.com/mastra-ai/mastra/commit/10959d509d824f682d40ff96e05ee044aec3b0e5), [`c547a77`](https://github.com/mastra-ai/mastra/commit/c547a7729bdf64dfc2df29c965046c0712a18f10), [`a0085fa`](https://github.com/mastra-ai/mastra/commit/a0085fa0934e52c37c8c8b3d75a6bb5cd199af36), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`ffc3c17`](https://github.com/mastra-ai/mastra/commit/ffc3c17274ea17c11aa6f73d3140649cd7fc8abc), [`81542c1`](https://github.com/mastra-ai/mastra/commit/81542c1835c35bc32f2ce4fa9136ee11993cd299), [`3908e53`](https://github.com/mastra-ai/mastra/commit/3908e53ce04bbea04f5e0c097d7aa298c35fabee), [`cb24ce7`](https://github.com/mastra-ai/mastra/commit/cb24ce76bd16ca88eb6a963f6277f8780e703029), [`02705fd`](https://github.com/mastra-ai/mastra/commit/02705fd2f5a9062210d64ea061adeeb10dc9452e), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964), [`5f9858f`](https://github.com/mastra-ai/mastra/commit/5f9858f791f1137ca7d52d23559fb4568f7a9026)]:
|
|
21
|
+
- @mastra/core@1.50.0
|
|
22
|
+
|
|
23
|
+
## 1.13.1-alpha.0
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Fixed MCP client tools missing output schemas in tool listings. Fixes #18850. ([#18854](https://github.com/mastra-ai/mastra/pull/18854))
|
|
28
|
+
|
|
29
|
+
MCP tools that declare an `outputSchema` now expose that schema on the Mastra tool wrapper, so Studio and other consumers can document expected tool outputs.
|
|
30
|
+
|
|
31
|
+
Mastra does not re-validate MCP tool results. The MCP SDK still validates `structuredContent` via AJV. This keeps full `CallToolResult` envelopes and extra fields intact while making output shapes visible again.
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const tools = await mcp.listTools();
|
|
35
|
+
const outputSchema = tools['weather_getForecast'].outputSchema?.['~standard'].jsonSchema.output({
|
|
36
|
+
target: 'draft-07',
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`3ffb8b7`](https://github.com/mastra-ai/mastra/commit/3ffb8b720e90f5e6977129ec1f6707d43c2bebe0), [`5ea76a7`](https://github.com/mastra-ai/mastra/commit/5ea76a723d966c72da9aa3ab30ae20276e049765), [`6445560`](https://github.com/mastra-ai/mastra/commit/6445560327045d20b239585fc63fed72e9ce36ec), [`a2ba369`](https://github.com/mastra-ai/mastra/commit/a2ba369e796dfab610f41c6875965b488272fa55), [`ae51e81`](https://github.com/mastra-ai/mastra/commit/ae51e818825582d42500338dfc1929a082eff0ba), [`6f304ef`](https://github.com/mastra-ai/mastra/commit/6f304ef319e99725e884bdb8d3193c001b6e5964)]:
|
|
41
|
+
- @mastra/core@1.50.0-alpha.1
|
|
42
|
+
|
|
3
43
|
## 1.13.0
|
|
4
44
|
|
|
5
45
|
### Minor Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -169,6 +169,11 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
169
169
|
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
170
170
|
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
171
171
|
private convertInputSchema;
|
|
172
|
+
/**
|
|
173
|
+
* Wraps the output schema with a validator that always succeeds. The MCP SDK validates
|
|
174
|
+
* structuredContent via AJV; the JSON schema is surfaced here for documentation only.
|
|
175
|
+
*/
|
|
176
|
+
private convertOutputSchema;
|
|
172
177
|
tools(): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
173
178
|
private stampServerIdInMeta;
|
|
174
179
|
}
|
|
@@ -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,CAAC;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EACnB,MAAM,oCAAoC,CAAC;AAoB5C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAGV,kBAAkB,EAClB,eAAe,EAEf,8BAA8B,EAC9B,IAAI,EAEL,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,kBAAkB,E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,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAQ/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;IA+LhE,OAAO,CAAC,mBAAmB;CAQ5B"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -43,7 +43,7 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
43
43
|
|
|
44
44
|
**eventSourceInit** (`EventSourceInit`): For SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE.
|
|
45
45
|
|
|
46
|
-
**fetch** (`MastraFetchLike`): For HTTP servers: Custom fetch implementation used for all network requests. Receives an optional third
|
|
46
|
+
**fetch** (`MastraFetchLike`): For HTTP servers: Custom fetch implementation used for all network requests. Receives an optional third requestContext parameter containing request-scoped data (e.g., authentication cookies, bearer tokens) from the incoming request. When provided, this function will be used for all HTTP requests, allowing you to add dynamic authentication headers, forward request-scoped credentials to the MCP server, customize request behavior per-request, or intercept and modify requests/responses. When fetch is provided, requestInit, eventSourceInit, and authProvider become optional, as you can handle these concerns within your custom fetch function.
|
|
47
47
|
|
|
48
48
|
**logger** (`LogHandler`): Optional additional handler for logging.
|
|
49
49
|
|
|
@@ -59,7 +59,7 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
|
|
|
59
59
|
|
|
60
60
|
**instructionsMaxLength** (`number`): Maximum number of server instruction characters to append to an agent's system prompt. (Default: `512`)
|
|
61
61
|
|
|
62
|
-
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to
|
|
62
|
+
**requireToolApproval** (`boolean | (params: RequireToolApprovalContext) => boolean | Promise<boolean>`): Require human approval before executing tools from this server. When set to true, all tools require approval. When set to a function, the function is called with the tool name, arguments, request context, and any tool annotations advertised by the server to dynamically decide whether approval is needed.
|
|
63
63
|
|
|
64
64
|
## Tool approval
|
|
65
65
|
|
|
@@ -59,19 +59,19 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
59
59
|
|
|
60
60
|
**version** (`string`): The semantic version of your server (e.g., '1.0.0').
|
|
61
61
|
|
|
62
|
-
**tools** (`ToolsInput`): An object where keys are tool names and values are Mastra tool definitions (created with
|
|
62
|
+
**tools** (`ToolsInput`): An object where keys are tool names and values are Mastra tool definitions (created with createTool or Vercel AI SDK). These tools will be directly exposed.
|
|
63
63
|
|
|
64
|
-
**agents** (`Record<string, Agent>`): An object where keys are agent identifiers and values are Mastra Agent instances. Each agent will be automatically converted into a tool named
|
|
64
|
+
**agents** (`Record<string, Agent>`): An object where keys are agent identifiers and values are Mastra Agent instances. Each agent will be automatically converted into a tool named ask\_\<agentIdentifier>. The agent \*\*must\*\* have a non-empty description string property defined in its constructor configuration. This description will be used in the tool's description. If an agent's description is missing or empty, an error will be thrown during MCPServer initialization.
|
|
65
65
|
|
|
66
|
-
**workflows** (`Record<string, Workflow>`): An object where keys are workflow identifiers and values are Mastra Workflow instances. Each workflow is converted into a tool named
|
|
66
|
+
**workflows** (`Record<string, Workflow>`): An object where keys are workflow identifiers and values are Mastra Workflow instances. Each workflow is converted into a tool named run\_\<workflowKey>. The workflow's inputSchema becomes the tool's input schema. The workflow \*\*must\*\* have a non-empty description string property, which is used for the tool's description. If a workflow's description is missing or empty, an error will be thrown. The tool executes the workflow by calling workflow\.createRun() followed by run.start({ inputData: \<tool\_input> }). If a tool name derived from an agent or workflow (e.g., ask\_myAgent or run\_myWorkflow) collides with an explicitly defined tool name or another derived name, the explicitly defined tool takes precedence, and a warning is logged. Agents/workflows leading to subsequent collisions are skipped.
|
|
67
67
|
|
|
68
68
|
**description** (`string`): Optional description of what the MCP server does.
|
|
69
69
|
|
|
70
70
|
**instructions** (`string`): Optional instructions describing how to use the server and its features.
|
|
71
71
|
|
|
72
|
-
**mapAuthInfoToUser** (`({ authInfo, extra, requestContext }) => unknown | null | undefined | Promise<unknown | null | undefined>`): Maps MCP transport auth data from
|
|
72
|
+
**mapAuthInfoToUser** (`({ authInfo, extra, requestContext }) => unknown | null | undefined | Promise<unknown | null | undefined>`): Maps MCP transport auth data from extra.authInfo into the user value used by Mastra FGA checks. Use this when an OAuth-protected MCP server is registered on a Mastra instance with an FGA provider.
|
|
73
73
|
|
|
74
|
-
**fga** (`{ resourceMapping?: Partial<Record<'tool' | 'tools', { fgaResourceType: string; deriveId?: ({ user, resourceId, requestContext }) => string | undefined }>>; permissionMapping?: Record<string, string> }`): Overrides resource and permission mappings for this MCP server's
|
|
74
|
+
**fga** (`{ resourceMapping?: Partial<Record<'tool' | 'tools', { fgaResourceType: string; deriveId?: ({ user, resourceId, requestContext }) => string | undefined }>>; permissionMapping?: Record<string, string> }`): Overrides resource and permission mappings for this MCP server's tools/list and tools/call FGA checks. Use this when MCP authorization should be scoped differently from internal agent or workflow tool execution.
|
|
75
75
|
|
|
76
76
|
**repository** (`Repository`): Optional repository information for the server's source code.
|
|
77
77
|
|
|
@@ -89,7 +89,7 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
89
89
|
|
|
90
90
|
**prompts** (`MCPServerPrompts`): An object defining how the server should handle MCP prompts. See Prompt Handling section for details.
|
|
91
91
|
|
|
92
|
-
**appResources** (`AppResources`): A map of
|
|
92
|
+
**appResources** (`AppResources`): A map of ui:// URIs to app resource configurations. Each entry defines an interactive HTML UI served via the MCP Apps extension (SEP-1865). See the MCP Apps section for details.
|
|
93
93
|
|
|
94
94
|
## Exposing agents as tools
|
|
95
95
|
|
|
@@ -422,13 +422,13 @@ Here are the details for the values needed by the `startHTTP` method:
|
|
|
422
422
|
|
|
423
423
|
The `StreamableHTTPServerTransportOptions` object allows you to customize the behavior of the HTTP transport. Here are the available options:
|
|
424
424
|
|
|
425
|
-
**serverless** (`boolean`): If
|
|
425
|
+
**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.
|
|
426
426
|
|
|
427
|
-
**sessionIdGenerator** (`(() => string) | undefined`): A function that generates a unique session ID. This should be a cryptographically secure, globally unique string. Return
|
|
427
|
+
**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.
|
|
428
428
|
|
|
429
429
|
**onsessioninitialized** (`(sessionId: string) => void`): A callback that is invoked when a new session is initialized. This is useful for tracking active MCP sessions.
|
|
430
430
|
|
|
431
|
-
**enableJsonResponse** (`boolean`): If
|
|
431
|
+
**enableJsonResponse** (`boolean`): If true, the server will return plain JSON responses instead of using Server-Sent Events (SSE) for streaming. Defaults to false.
|
|
432
432
|
|
|
433
433
|
**eventStore** (`EventStore`): An event store for message resumability. Providing this enables clients to reconnect and resume message streams.
|
|
434
434
|
|
|
@@ -1350,7 +1350,7 @@ The `appResources` option lets you serve interactive HTML UIs from your MCP serv
|
|
|
1350
1350
|
|
|
1351
1351
|
### `AppResources` type
|
|
1352
1352
|
|
|
1353
|
-
**Key (URI)** (`string`): A
|
|
1353
|
+
**Key (URI)** (`string`): A ui:// URI that identifies the app resource (e.g., ui://calculator/main).
|
|
1354
1354
|
|
|
1355
1355
|
Each value is an `AppResource` object:
|
|
1356
1356
|
|
|
@@ -1358,9 +1358,9 @@ Each value is an `AppResource` object:
|
|
|
1358
1358
|
|
|
1359
1359
|
**description** (`string`): Optional description of the UI resource.
|
|
1360
1360
|
|
|
1361
|
-
**html** (`string`): Inline HTML content for the UI. Provide either
|
|
1361
|
+
**html** (`string`): Inline HTML content for the UI. Provide either html or htmlPath.
|
|
1362
1362
|
|
|
1363
|
-
**htmlPath** (`string`): Path to an HTML file. Resolved at server startup. Provide either
|
|
1363
|
+
**htmlPath** (`string`): Path to an HTML file. Resolved at server startup. Provide either html or htmlPath.
|
|
1364
1364
|
|
|
1365
1365
|
**meta** (`McpUiResourceMeta`): UI resource metadata (CSP, permissions, rendering preferences) from the official ext-apps SDK.
|
|
1366
1366
|
|