@mastra/mcp 1.3.0 → 1.3.1-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 +22 -0
- package/dist/client/client.d.ts +1 -1
- 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 +20 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -39
- package/dist/index.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.3.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed MCP tool results to preserve the standard CallToolResult envelope shape. Previously, content was extracted from the envelope which broke consumers expecting the standard MCP result format. Output schema validation is now handled internally by the MCP SDK's AJV validator instead of Zod, preventing unrecognized keys from being stripped. ([#14519](https://github.com/mastra-ai/mastra/pull/14519))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`da93115`](https://github.com/mastra-ai/mastra/commit/da931155c1a9bc63d455d3d86b4ec984db5991fe), [`0efe12a`](https://github.com/mastra-ai/mastra/commit/0efe12a5f008a939a1aac71699486ba40138054e)]:
|
|
10
|
+
- @mastra/core@1.15.0-alpha.4
|
|
11
|
+
|
|
12
|
+
## 1.3.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fix MCP tool results returning empty `{}` when tool has no outputSchema ([#14372](https://github.com/mastra-ai/mastra/pull/14372))
|
|
17
|
+
|
|
18
|
+
- Fixed child processes started by the MCP client staying alive after the terminal session closes. ([#13977](https://github.com/mastra-ai/mastra/pull/13977))
|
|
19
|
+
|
|
20
|
+
- Fixed regular tools executed via MCPServer now receive `requestContext` populated from `mcp.extra`, matching the behavior of agent and workflow tools. All tool types now consistently propagate authentication and request context. ([#14349](https://github.com/mastra-ai/mastra/pull/14349))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0)]:
|
|
23
|
+
- @mastra/core@1.15.0-alpha.0
|
|
24
|
+
|
|
3
25
|
## 1.3.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
package/dist/client/client.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
28
28
|
private operationContextStore;
|
|
29
29
|
private exitHookUnsubscribe?;
|
|
30
30
|
private sigTermHandler?;
|
|
31
|
+
private sigHupHandler?;
|
|
31
32
|
private _roots;
|
|
32
33
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
33
34
|
readonly resources: ResourceClientActions;
|
|
@@ -176,7 +177,6 @@ export declare class InternalMastraMCPClient extends MastraBase {
|
|
|
176
177
|
setElicitationRequestHandler(handler: ElicitationHandler): void;
|
|
177
178
|
setProgressNotificationHandler(handler: ProgressHandler): void;
|
|
178
179
|
private convertInputSchema;
|
|
179
|
-
private convertOutputSchema;
|
|
180
180
|
tools(): Promise<Record<string, Tool<any, any, any, any>>>;
|
|
181
181
|
}
|
|
182
182
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @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C,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IASvG;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE,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;IAQ/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;IA+B1B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CA2GjE"}
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -416,6 +416,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
416
416
|
operationContextStore = new async_hooks.AsyncLocalStorage();
|
|
417
417
|
exitHookUnsubscribe;
|
|
418
418
|
sigTermHandler;
|
|
419
|
+
sigHupHandler;
|
|
419
420
|
_roots;
|
|
420
421
|
/** Provides access to resource operations (list, read, subscribe, etc.) */
|
|
421
422
|
resources;
|
|
@@ -674,6 +675,10 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
674
675
|
this.sigTermHandler = () => exitHook.gracefulExit();
|
|
675
676
|
process.on("SIGTERM", this.sigTermHandler);
|
|
676
677
|
}
|
|
678
|
+
if (!this.sigHupHandler) {
|
|
679
|
+
this.sigHupHandler = () => exitHook.gracefulExit();
|
|
680
|
+
process.on("SIGHUP", this.sigHupHandler);
|
|
681
|
+
}
|
|
677
682
|
this.log("debug", `Successfully connected to MCP server`);
|
|
678
683
|
return this.isConnected;
|
|
679
684
|
}
|
|
@@ -730,6 +735,10 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
730
735
|
process.off("SIGTERM", this.sigTermHandler);
|
|
731
736
|
this.sigTermHandler = void 0;
|
|
732
737
|
}
|
|
738
|
+
if (this.sigHupHandler) {
|
|
739
|
+
process.off("SIGHUP", this.sigHupHandler);
|
|
740
|
+
this.sigHupHandler = void 0;
|
|
741
|
+
}
|
|
733
742
|
}
|
|
734
743
|
}
|
|
735
744
|
/**
|
|
@@ -894,34 +903,6 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
894
903
|
});
|
|
895
904
|
}
|
|
896
905
|
}
|
|
897
|
-
async convertOutputSchema(outputSchema) {
|
|
898
|
-
if (!outputSchema) return;
|
|
899
|
-
try {
|
|
900
|
-
await $RefParser__default.default.dereference(outputSchema);
|
|
901
|
-
return "jsonSchema" in outputSchema ? outputSchema.jsonSchema : outputSchema;
|
|
902
|
-
} catch (error$1) {
|
|
903
|
-
let errorDetails;
|
|
904
|
-
if (error$1 instanceof Error) {
|
|
905
|
-
errorDetails = error$1.stack;
|
|
906
|
-
} else {
|
|
907
|
-
try {
|
|
908
|
-
errorDetails = JSON.stringify(error$1);
|
|
909
|
-
} catch {
|
|
910
|
-
errorDetails = String(error$1);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
this.log("error", "Failed to dereference JSON schema", {
|
|
914
|
-
error: errorDetails,
|
|
915
|
-
originalJsonSchema: outputSchema
|
|
916
|
-
});
|
|
917
|
-
throw new error.MastraError({
|
|
918
|
-
id: "MCP_TOOL_OUTPUT_SCHEMA_CONVERSION_FAILED",
|
|
919
|
-
domain: error.ErrorDomain.MCP,
|
|
920
|
-
category: error.ErrorCategory.USER,
|
|
921
|
-
details: { error: errorDetails ?? "Unknown error" }
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
906
|
async tools() {
|
|
926
907
|
this.log("debug", `Requesting tools from MCP server`);
|
|
927
908
|
const { tools: tools$1 } = await this.client.listTools({}, { timeout: this.timeout });
|
|
@@ -933,7 +914,10 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
933
914
|
id: `${this.name}_${tool.name}`,
|
|
934
915
|
description: tool.description || "",
|
|
935
916
|
inputSchema: await this.convertInputSchema(tool.inputSchema),
|
|
936
|
-
outputSchema
|
|
917
|
+
// Don't pass outputSchema to createTool — the MCP SDK's Client.callTool()
|
|
918
|
+
// already validates structuredContent against the tool's outputSchema using AJV.
|
|
919
|
+
// Passing it here causes Zod to strip unrecognized keys from the CallToolResult
|
|
920
|
+
// envelope, returning {} for tools without structuredContent.
|
|
937
921
|
mcpMetadata: {
|
|
938
922
|
serverName: this.name,
|
|
939
923
|
serverVersion: this.client.getServerVersion()?.version
|
|
@@ -960,16 +944,6 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
960
944
|
if (res.structuredContent !== void 0) {
|
|
961
945
|
return res.structuredContent;
|
|
962
946
|
}
|
|
963
|
-
if (tool.outputSchema && !res.isError) {
|
|
964
|
-
const content = res.content;
|
|
965
|
-
if (content && content.length === 1 && content[0].type === "text" && content[0].text !== void 0) {
|
|
966
|
-
try {
|
|
967
|
-
return JSON.parse(content[0].text);
|
|
968
|
-
} catch {
|
|
969
|
-
return content[0].text;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
947
|
return res;
|
|
974
948
|
};
|
|
975
949
|
try {
|
|
@@ -2821,9 +2795,16 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
|
|
|
2821
2795
|
return this.handleElicitationRequest(request2, serverInstance, options);
|
|
2822
2796
|
}
|
|
2823
2797
|
};
|
|
2798
|
+
const proxiedContext = new requestContext.RequestContext();
|
|
2799
|
+
if (extra) {
|
|
2800
|
+
Object.entries(extra).forEach(([key, value]) => {
|
|
2801
|
+
proxiedContext.set(key, value);
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2824
2804
|
const mcpOptions = {
|
|
2825
2805
|
messages: [],
|
|
2826
2806
|
toolCallId: "",
|
|
2807
|
+
requestContext: proxiedContext,
|
|
2827
2808
|
// Pass MCP-specific context through the mcp property
|
|
2828
2809
|
mcp: {
|
|
2829
2810
|
elicitation: sessionElicitation,
|