@mastra/mcp 1.16.0-alpha.0 → 1.16.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 +17 -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/index.cjs +80 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -10
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.16.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- **Fixed spurious MCP reconnects when tool-execution errors contain transport-like substrings.** ([#20793](https://github.com/mastra-ai/mastra/pull/20793))
|
|
8
|
+
|
|
9
|
+
When an MCP tool returns an in-band error (\`isError: true\`) whose text contains words like "session", "404", or "connection closed", the client no longer misclassifies it as a transport failure and triggers a reconnect + retry. This prevents duplicate calls for non-idempotent tools (e.g. payments, writes).
|
|
10
|
+
|
|
11
|
+
**Surface the real failure after a failed reconnect.**
|
|
12
|
+
|
|
13
|
+
When a transport-level reconnect fails, the caller now receives the actual reconnection error instead of the stale tool/transport error that triggered the recovery attempt.
|
|
14
|
+
|
|
15
|
+
- Fixed MCP tools with outputSchema to send LLM-facing content text to the model via toModelOutput while keeping structuredContent on tool.execute() results. ([#20176](https://github.com/mastra-ai/mastra/pull/20176))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`d7cf7fa`](https://github.com/mastra-ai/mastra/commit/d7cf7fafc1ae1b50bd8462dd0e6c671a8606db93), [`0f9a448`](https://github.com/mastra-ai/mastra/commit/0f9a448502157e59f7b76f24360ad497168f5ef8), [`289f4ce`](https://github.com/mastra-ai/mastra/commit/289f4ce16e3293370440172132c52ee787cbc09f), [`4f16ff8`](https://github.com/mastra-ai/mastra/commit/4f16ff824bf2f9b0ddc93f210477c10c8a4fb1ab), [`1c67d85`](https://github.com/mastra-ai/mastra/commit/1c67d85e9da8285662f4dbbf47e0378c3fee0747), [`ba24be6`](https://github.com/mastra-ai/mastra/commit/ba24be662439c331ab23a600041f93803c89eca8), [`842b5fe`](https://github.com/mastra-ai/mastra/commit/842b5fe22b6a7fa811bd14e48eb9af523ac989f2), [`80bdf3a`](https://github.com/mastra-ai/mastra/commit/80bdf3ae16ade6ff63bde0cb16fa2df8ab7dd4dd), [`9ba1247`](https://github.com/mastra-ai/mastra/commit/9ba12470c77f1c03642d720ce67e517e878f666e), [`fd96298`](https://github.com/mastra-ai/mastra/commit/fd96298a8367622f4ebfcaa97b5b6c1fbbd14564), [`6a84954`](https://github.com/mastra-ai/mastra/commit/6a84954a2667f85b6d59da652dab1bbff007ccb0), [`52d8ef0`](https://github.com/mastra-ai/mastra/commit/52d8ef03801f1deb7ee48532fc4190dd4a33916c), [`cdd5c33`](https://github.com/mastra-ai/mastra/commit/cdd5c33ac6c7118a9f139e6dc0e14e6a8ae31658), [`efd5c81`](https://github.com/mastra-ai/mastra/commit/efd5c81cc25fde3c2ddd86fc1178deb4ec176e19), [`0976933`](https://github.com/mastra-ai/mastra/commit/0976933142333ec78451feef265b68bcb45aa5e7), [`242b945`](https://github.com/mastra-ai/mastra/commit/242b94558777bfbdeb42cbfea84afff0b6ad0633), [`fea5cae`](https://github.com/mastra-ai/mastra/commit/fea5caedc7e2cfea51784a15e015952692027abf), [`4b59f78`](https://github.com/mastra-ai/mastra/commit/4b59f786cbc9a7d1ef07a07517dbd4b96865e99d), [`7010c5d`](https://github.com/mastra-ai/mastra/commit/7010c5d15728bf9c5dfe4fb6b1bf80ce23bf143a)]:
|
|
18
|
+
- @mastra/core@1.58.0-alpha.3
|
|
19
|
+
|
|
3
20
|
## 1.16.0-alpha.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export type { LoggingLevel, LogMessage, LogHandler, ElicitationHandler, Progress
|
|
|
18
18
|
* Servers without an authProvider never carry an auth state.
|
|
19
19
|
*/
|
|
20
20
|
export type MCPServerAuthState = 'needs-auth' | 'authorized';
|
|
21
|
+
/**
|
|
22
|
+
* Non-enumerable metadata attached to structured tool execute results so
|
|
23
|
+
* `toModelOutput` can read MCP `content` without changing the execute return shape.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MCP_CALL_TOOL_CONTENT: unique symbol;
|
|
21
26
|
/**
|
|
22
27
|
* Internal MCP client implementation for connecting to a single MCP server.
|
|
23
28
|
*
|
|
@@ -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;AAUhE,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAE3B,kBAAkB,EAEnB,MAAM,8BAA8B,CAAC;AAKtC,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;A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21378
21378
|
function extractToolErrorText(content) {
|
|
21379
21379
|
const fallback = "MCP tool execution failed";
|
|
21380
21380
|
if (!Array.isArray(content)) return fallback;
|
|
21381
|
+
return extractModelTextFromToolContent(content) || fallback;
|
|
21382
|
+
}
|
|
21383
|
+
/**
|
|
21384
|
+
* Extract LLM-facing text from a successful CallToolResult's `content` blocks.
|
|
21385
|
+
* Per MCP spec, `content` is the human/model-readable channel; `structuredContent`
|
|
21386
|
+
* is for client/UI consumption.
|
|
21387
|
+
*/
|
|
21388
|
+
function extractModelTextFromToolContent(content) {
|
|
21389
|
+
if (!Array.isArray(content)) return void 0;
|
|
21381
21390
|
return content.filter((part) => {
|
|
21382
21391
|
return !!part && typeof part === "object" && part.type === "text";
|
|
21383
|
-
}).map((part) => part.text).join("\n").trim() ||
|
|
21392
|
+
}).map((part) => part.text).join("\n").trim() || void 0;
|
|
21393
|
+
}
|
|
21394
|
+
/**
|
|
21395
|
+
* Non-enumerable metadata attached to structured tool execute results so
|
|
21396
|
+
* `toModelOutput` can read MCP `content` without changing the execute return shape.
|
|
21397
|
+
*/
|
|
21398
|
+
const MCP_CALL_TOOL_CONTENT = Symbol.for("mastra.mcp.callToolContent");
|
|
21399
|
+
function reserveScalarMcpContent(queue) {
|
|
21400
|
+
const reservation = { ready: false };
|
|
21401
|
+
queue.push(reservation);
|
|
21402
|
+
return reservation;
|
|
21403
|
+
}
|
|
21404
|
+
function removeScalarMcpContentReservation(queue, reservation) {
|
|
21405
|
+
if (!reservation) return;
|
|
21406
|
+
const index = queue.indexOf(reservation);
|
|
21407
|
+
if (index !== -1) queue.splice(index, 1);
|
|
21408
|
+
}
|
|
21409
|
+
function attachMcpCallToolContent(structuredContent, content, scalarMcpContentQueue, reservation) {
|
|
21410
|
+
if (structuredContent !== null && typeof structuredContent === "object") {
|
|
21411
|
+
removeScalarMcpContentReservation(scalarMcpContentQueue, reservation);
|
|
21412
|
+
Object.defineProperty(structuredContent, MCP_CALL_TOOL_CONTENT, {
|
|
21413
|
+
value: content,
|
|
21414
|
+
enumerable: false,
|
|
21415
|
+
configurable: true
|
|
21416
|
+
});
|
|
21417
|
+
return structuredContent;
|
|
21418
|
+
}
|
|
21419
|
+
if (reservation) {
|
|
21420
|
+
reservation.output = structuredContent;
|
|
21421
|
+
reservation.content = content;
|
|
21422
|
+
reservation.ready = true;
|
|
21423
|
+
}
|
|
21424
|
+
return structuredContent;
|
|
21425
|
+
}
|
|
21426
|
+
function getMcpCallToolContent(output, scalarMcpContentQueue) {
|
|
21427
|
+
if (output !== null && typeof output === "object") {
|
|
21428
|
+
const attached = output[MCP_CALL_TOOL_CONTENT];
|
|
21429
|
+
if (attached !== void 0) return attached;
|
|
21430
|
+
}
|
|
21431
|
+
const index = scalarMcpContentQueue.findIndex((entry) => entry.ready && Object.is(entry.output, output));
|
|
21432
|
+
if (index !== -1) return scalarMcpContentQueue.splice(index, 1)[0]?.content;
|
|
21433
|
+
}
|
|
21434
|
+
function createStructuredToolToModelOutput(scalarMcpContentQueue) {
|
|
21435
|
+
return (output) => {
|
|
21436
|
+
const modelText = extractModelTextFromToolContent(getMcpCallToolContent(output, scalarMcpContentQueue));
|
|
21437
|
+
if (modelText !== void 0) return {
|
|
21438
|
+
type: "text",
|
|
21439
|
+
value: modelText
|
|
21440
|
+
};
|
|
21441
|
+
return {
|
|
21442
|
+
type: "json",
|
|
21443
|
+
value: output
|
|
21444
|
+
};
|
|
21445
|
+
};
|
|
21384
21446
|
}
|
|
21385
21447
|
function getDatadogScope() {
|
|
21386
21448
|
const tracer = globalThis[DATADOG_TRACER_TEST_SYMBOL] ?? loadDatadogTracer();
|
|
@@ -22132,6 +22194,7 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
22132
22194
|
...toolMeta ? { _meta: toolMeta } : {},
|
|
22133
22195
|
...annotations ? { annotations } : {}
|
|
22134
22196
|
} } : {};
|
|
22197
|
+
const scalarMcpContentQueue = [];
|
|
22135
22198
|
const mastraTool = (0, _mastra_core_tools.createTool)({
|
|
22136
22199
|
id: `${this.name}_${tool.name}`,
|
|
22137
22200
|
description: tool.description || "",
|
|
@@ -22147,8 +22210,10 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
22147
22210
|
forwardInstructions: this.forwardInstructions,
|
|
22148
22211
|
instructionsMaxLength: this.instructionsMaxLength
|
|
22149
22212
|
},
|
|
22213
|
+
...tool.outputSchema ? { toModelOutput: createStructuredToolToModelOutput(scalarMcpContentQueue) } : {},
|
|
22150
22214
|
execute: async (input, context) => {
|
|
22151
22215
|
const operationContext = context?.requestContext ?? null;
|
|
22216
|
+
const scalarMcpContentReservation = tool.outputSchema ? reserveScalarMcpContent(scalarMcpContentQueue) : void 0;
|
|
22152
22217
|
return this.operationContextStore.run(operationContext, async () => {
|
|
22153
22218
|
const executeToolCall = async () => {
|
|
22154
22219
|
this.log("debug", `Executing tool: ${tool.name}`, {
|
|
@@ -22184,7 +22249,8 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
22184
22249
|
});
|
|
22185
22250
|
}
|
|
22186
22251
|
this.log("debug", `Tool executed successfully: ${tool.name}`);
|
|
22187
|
-
if (res.structuredContent !== void 0) return res.structuredContent;
|
|
22252
|
+
if (res.structuredContent !== void 0) return attachMcpCallToolContent(res.structuredContent, res.content, scalarMcpContentQueue, scalarMcpContentReservation);
|
|
22253
|
+
removeScalarMcpContentReservation(scalarMcpContentQueue, scalarMcpContentReservation);
|
|
22188
22254
|
return res;
|
|
22189
22255
|
};
|
|
22190
22256
|
const failedTransport = this.transport;
|
|
@@ -22192,7 +22258,7 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
22192
22258
|
try {
|
|
22193
22259
|
return await executeToolCall();
|
|
22194
22260
|
} catch (e) {
|
|
22195
|
-
if (isReconnectableMCPError(e)) {
|
|
22261
|
+
if (!(e instanceof _mastra_core_error.MastraError && e.id === "MCP_CLIENT_TOOL_EXECUTION_FAILED") && isReconnectableMCPError(e)) {
|
|
22196
22262
|
this.log("debug", `Session error detected for tool ${tool.name}, attempting reconnection...`, { error: e instanceof Error ? e.message : String(e) });
|
|
22197
22263
|
try {
|
|
22198
22264
|
await this.reconnectAfterTransportFailure(failedTransport, lifecycleGeneration);
|
|
@@ -22204,13 +22270,15 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
|
|
|
22204
22270
|
reconnectError: reconnectError instanceof Error ? reconnectError.stack : String(reconnectError),
|
|
22205
22271
|
toolArgs: input
|
|
22206
22272
|
});
|
|
22207
|
-
|
|
22273
|
+
removeScalarMcpContentReservation(scalarMcpContentQueue, scalarMcpContentReservation);
|
|
22274
|
+
throw reconnectError;
|
|
22208
22275
|
}
|
|
22209
22276
|
}
|
|
22210
22277
|
this.log("error", `Error calling tool: ${tool.name}`, {
|
|
22211
22278
|
error: e instanceof Error ? e.stack : JSON.stringify(e, null, 2),
|
|
22212
22279
|
toolArgs: input
|
|
22213
22280
|
});
|
|
22281
|
+
removeScalarMcpContentReservation(scalarMcpContentQueue, scalarMcpContentReservation);
|
|
22214
22282
|
throw e;
|
|
22215
22283
|
}
|
|
22216
22284
|
});
|
|
@@ -26973,11 +27041,13 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
|
|
|
26973
27041
|
}
|
|
26974
27042
|
response.structuredContent = structuredContent;
|
|
26975
27043
|
}
|
|
26976
|
-
if (response.structuredContent
|
|
26977
|
-
|
|
26978
|
-
|
|
26979
|
-
|
|
26980
|
-
|
|
27044
|
+
if (response.structuredContent !== void 0) {
|
|
27045
|
+
const authorContent = result && typeof result === "object" && "content" in result && Array.isArray(result.content) ? result.content : void 0;
|
|
27046
|
+
response.content = authorContent && authorContent.length > 0 ? authorContent : [{
|
|
27047
|
+
type: "text",
|
|
27048
|
+
text: JSON.stringify(response.structuredContent)
|
|
27049
|
+
}];
|
|
27050
|
+
} else response.content = [{
|
|
26981
27051
|
type: "text",
|
|
26982
27052
|
text: typeof result === "string" ? result : JSON.stringify(result)
|
|
26983
27053
|
}];
|
|
@@ -28582,6 +28652,7 @@ exports.MCPClient = MCPClient;
|
|
|
28582
28652
|
exports.MCPClientServerProxy = MCPClientServerProxy;
|
|
28583
28653
|
exports.MCPOAuthClientProvider = MCPOAuthClientProvider;
|
|
28584
28654
|
exports.MCPServer = MCPServer;
|
|
28655
|
+
exports.MCP_CALL_TOOL_CONTENT = MCP_CALL_TOOL_CONTENT;
|
|
28585
28656
|
Object.defineProperty(exports, "UnauthorizedError", {
|
|
28586
28657
|
enumerable: true,
|
|
28587
28658
|
get: function() {
|