@mastra/mcp 1.12.1 → 1.13.0-alpha.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 +39 -0
- package/dist/client/client.d.ts +1 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/types.d.ts +15 -0
- package/dist/client/types.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/docs-mcp-mcp-apps.md +2 -0
- package/dist/docs/references/docs-mcp-overview.md +2 -0
- package/dist/docs/references/docs-server-auth-fga.md +2 -0
- package/dist/docs/references/reference-tools-mcp-client.md +3 -0
- package/dist/docs/references/reference-tools-mcp-server.md +3 -1
- package/dist/index.cjs +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.13.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Security hardening from CodeQL review: MCP serverless 500 responses no longer echo internal error messages to clients (details are still logged server-side), and macOS system notifications now escape backslashes and run osascript without a shell so notification text can't inject commands. ([#18805](https://github.com/mastra-ai/mastra/pull/18805))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b)]:
|
|
10
|
+
- @mastra/core@1.49.0-alpha.3
|
|
11
|
+
|
|
12
|
+
## 1.13.0-alpha.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- Fixed MCP tool execution failures being recorded as successes. ([#18482](https://github.com/mastra-ai/mastra/pull/18482))
|
|
17
|
+
|
|
18
|
+
A failing MCP tool used to look like it succeeded. The call was traced and saved as a success, and error handling like retries and Studio error states never ran. For tools with an `outputSchema`, the error message was thrown away, so neither the model nor the user saw why the call failed.
|
|
19
|
+
|
|
20
|
+
This happened because the server reports the failure inside a normal result (with an `isError` flag), and `MCPClient` did not check that flag.
|
|
21
|
+
|
|
22
|
+
Now `isError: true` results are surfaced on the failed-tool-call path: the tool throws with the server's error text, so spans, stream chunks, scorers, and persisted messages reflect the failure and the model can self-correct.
|
|
23
|
+
|
|
24
|
+
You can opt back into the previous behavior per server with `onToolError: 'return'`, which resolves with the raw result instead of throwing:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
const mcp = new MCPClient({
|
|
28
|
+
servers: {
|
|
29
|
+
weather: {
|
|
30
|
+
url: new URL('https://example.com/mcp'),
|
|
31
|
+
onToolError: 'return', // default is 'throw'
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [[`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae)]:
|
|
40
|
+
- @mastra/core@1.49.0-alpha.1
|
|
41
|
+
|
|
3
42
|
## 1.12.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
32
32
|
private serverInstructions?;
|
|
33
33
|
private _roots;
|
|
34
34
|
private readonly requireToolApproval;
|
|
35
|
+
private readonly onToolError;
|
|
35
36
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
36
37
|
readonly resources: ResourceClientActions;
|
|
37
38
|
/** Provides access to prompt operations (list, get, notifications) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MA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AAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAkMhE,OAAO,CAAC,mBAAmB;CAQ5B"}
|
package/dist/client/types.d.ts
CHANGED
|
@@ -200,6 +200,21 @@ export type BaseServerOptions = {
|
|
|
200
200
|
* ```
|
|
201
201
|
*/
|
|
202
202
|
requireToolApproval?: RequireToolApproval;
|
|
203
|
+
/**
|
|
204
|
+
* How to handle MCP tool *execution* failures, which a spec-compliant server
|
|
205
|
+
* reports in-band by returning a normal `CallToolResult` with `isError: true`
|
|
206
|
+
* and the failure details in `content`.
|
|
207
|
+
*
|
|
208
|
+
* - `'throw'` (default): surface the failure on Mastra's failed-tool-call path
|
|
209
|
+
* by throwing a `MastraError` that carries the server's `content` text. Tool
|
|
210
|
+
* spans, stream chunks, scorers, and persisted message parts then reflect the
|
|
211
|
+
* failure, and the model sees the error text so it can self-correct.
|
|
212
|
+
* - `'return'`: preserve the legacy behaviour and resolve successfully with the
|
|
213
|
+
* raw result (or `structuredContent`), ignoring `isError`.
|
|
214
|
+
*
|
|
215
|
+
* @default 'throw'
|
|
216
|
+
*/
|
|
217
|
+
onToolError?: 'throw' | 'return';
|
|
203
218
|
/**
|
|
204
219
|
* Optional custom JSON Schema validator forwarded to the underlying MCP SDK
|
|
205
220
|
* client. Use this to opt into a non-default validator implementation.
|
|
@@ -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,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oDAAoD,CAAC;AAE/G,YAAY,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EAC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AE,oCAAoC,CAAC,qBAAqB,CAAC,CAAC;IAClF,8CAA8C;IAC9C,SAAS,CAAC,EAAE,oCAAoC,CAAC,WAAW,CAAC,CAAC;IAC9D;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,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"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# MCP Apps
|
|
2
4
|
|
|
3
5
|
The [MCP Apps extension](https://github.com/modelcontextprotocol/ext-apps) allows MCP tools to serve interactive HTML UIs via `ui://` resources. When a tool has an associated app resource, Mastra Studio renders it in a sandboxed iframe alongside the tool form or inline in agent chat.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# MCP overview
|
|
2
4
|
|
|
3
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 serves as a universal plugin system, enabling agents to call tools regardless of language or hosting environment.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Fine-Grained Authorization (FGA)
|
|
2
4
|
|
|
3
5
|
> **Note:** Fine-Grained Authorization is part of the Mastra Enterprise Edition. Production deployments require a valid EE license. [Contact sales](https://mastra.ai/contact) for more information.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# MCPClient
|
|
2
4
|
|
|
3
5
|
The `MCPClient` class provides a way to manage multiple MCP server connections and their tools in a Mastra application. It handles connection lifecycle, tool namespacing, and provides access to tools across all configured servers.
|
|
@@ -1063,6 +1065,7 @@ const mcpClient = new MCPClient({
|
|
|
1063
1065
|
|
|
1064
1066
|
// Use with an agent — requestContext is automatically forwarded
|
|
1065
1067
|
const agent = new Agent({
|
|
1068
|
+
id: 'my-agent',
|
|
1066
1069
|
name: 'My Agent',
|
|
1067
1070
|
instructions: 'You are a helpful assistant.',
|
|
1068
1071
|
model: openai('gpt-5.4'),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# MCPServer
|
|
2
4
|
|
|
3
5
|
The `MCPServer` class provides the functionality to expose your existing Mastra tools and Agents as a Model Context Protocol (MCP) server. This allows any MCP client (like Cursor, Windsurf, or Claude Desktop) to connect to these capabilities and make them available to an agent.
|
|
@@ -112,7 +114,7 @@ When you provide agents in the `agents` configuration property, `MCPServer` will
|
|
|
112
114
|
|
|
113
115
|
The description for this generated tool will be: "Ask agent `<agent.name>` a question. Agent description: `<agent.description>`".
|
|
114
116
|
|
|
115
|
-
**Important**: 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({ 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.
|
|
117
|
+
**Important**: 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.
|
|
116
118
|
|
|
117
119
|
This allows you to quickly expose the generative capabilities of your agents through the MCP, enabling clients to "ask" your agents questions directly.
|
|
118
120
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var async_hooks = require('async_hooks');
|
|
4
4
|
var module$1 = require('module');
|
|
5
5
|
var base = require('@mastra/core/base');
|
|
6
|
+
var error = require('@mastra/core/error');
|
|
6
7
|
var tools = require('@mastra/core/tools');
|
|
7
8
|
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
8
9
|
var sse_js = require('@modelcontextprotocol/sdk/client/sse.js');
|
|
@@ -12,7 +13,6 @@ var protocol_js = require('@modelcontextprotocol/sdk/shared/protocol.js');
|
|
|
12
13
|
var types_js = require('@modelcontextprotocol/sdk/types.js');
|
|
13
14
|
var exitHook = require('exit-hook');
|
|
14
15
|
var crypto$1 = require('crypto');
|
|
15
|
-
var error = require('@mastra/core/error');
|
|
16
16
|
var equal = require('fast-deep-equal');
|
|
17
17
|
var mcp = require('@mastra/core/mcp');
|
|
18
18
|
var schema = require('@mastra/core/schema');
|
|
@@ -431,6 +431,14 @@ var DATADOG_TRACER_TEST_SYMBOL = /* @__PURE__ */ Symbol.for("mastra.mcp.dd-trace
|
|
|
431
431
|
function shouldDetachPersistentTransportRequest(init) {
|
|
432
432
|
return (init?.method ?? "GET").toUpperCase() === "GET";
|
|
433
433
|
}
|
|
434
|
+
function extractToolErrorText(content) {
|
|
435
|
+
const fallback = "MCP tool execution failed";
|
|
436
|
+
if (!Array.isArray(content)) return fallback;
|
|
437
|
+
const text = content.filter((part) => {
|
|
438
|
+
return !!part && typeof part === "object" && part.type === "text";
|
|
439
|
+
}).map((part) => part.text).join("\n").trim();
|
|
440
|
+
return text || fallback;
|
|
441
|
+
}
|
|
434
442
|
function getDatadogScope() {
|
|
435
443
|
const testTracer = globalThis[DATADOG_TRACER_TEST_SYMBOL];
|
|
436
444
|
const tracer = testTracer ?? loadDatadogTracer();
|
|
@@ -512,6 +520,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
512
520
|
serverInstructions;
|
|
513
521
|
_roots;
|
|
514
522
|
requireToolApproval;
|
|
523
|
+
onToolError;
|
|
515
524
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
516
525
|
resources;
|
|
517
526
|
/** Provides access to prompt operations (list, get, notifications) */
|
|
@@ -538,6 +547,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
538
547
|
this.serverConfig = server;
|
|
539
548
|
this.enableProgressTracking = !!server.enableProgressTracking;
|
|
540
549
|
this.requireToolApproval = server.requireToolApproval;
|
|
550
|
+
this.onToolError = server.onToolError ?? "throw";
|
|
541
551
|
this._roots = server.roots ?? [];
|
|
542
552
|
const hasRoots = this._roots.length > 0 || !!capabilities.roots;
|
|
543
553
|
const clientCapabilities = {
|
|
@@ -1058,6 +1068,17 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
1058
1068
|
signal: context?.abortSignal
|
|
1059
1069
|
}
|
|
1060
1070
|
);
|
|
1071
|
+
if (res.isError && this.onToolError === "throw") {
|
|
1072
|
+
const errorText = extractToolErrorText(res.content);
|
|
1073
|
+
this.log("debug", `Tool reported an error: ${tool.name}`, { error: errorText });
|
|
1074
|
+
throw new error.MastraError({
|
|
1075
|
+
id: "MCP_CLIENT_TOOL_EXECUTION_FAILED",
|
|
1076
|
+
domain: error.ErrorDomain.MCP,
|
|
1077
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
1078
|
+
text: errorText,
|
|
1079
|
+
details: { toolName: tool.name, serverName: this.name }
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1061
1082
|
this.log("debug", `Tool executed successfully: ${tool.name}`);
|
|
1062
1083
|
if (res.structuredContent !== void 0) {
|
|
1063
1084
|
return res.structuredContent;
|
|
@@ -4195,8 +4216,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
4195
4216
|
jsonrpc: "2.0",
|
|
4196
4217
|
error: {
|
|
4197
4218
|
code: -32603,
|
|
4198
|
-
message: "Internal server error"
|
|
4199
|
-
data: error$1 instanceof Error ? error$1.message : String(error$1)
|
|
4219
|
+
message: "Internal server error"
|
|
4200
4220
|
},
|
|
4201
4221
|
id: null
|
|
4202
4222
|
})
|