@mastra/mcp 0.11.3-alpha.2 → 0.11.3

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 CHANGED
@@ -1,5 +1,72 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 0.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - de3cbc6: Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
8
+ - b42a961: New createMCPTool helper for correct types for MCP Server tools
9
+ - ad78bfc: "piped tracingContext through inngest and mcp packages"
10
+ - 3b8972b: Turn MCPTool into a generic to get parameter typing
11
+ - 6cffb99: Fix log level not being handled by server
12
+ - 3e0153a: Fix mcp getTools when using Zod v4
13
+ - Updated dependencies [ab48c97]
14
+ - Updated dependencies [85ef90b]
15
+ - Updated dependencies [aedbbfa]
16
+ - Updated dependencies [ff89505]
17
+ - Updated dependencies [637f323]
18
+ - Updated dependencies [de3cbc6]
19
+ - Updated dependencies [c19bcf7]
20
+ - Updated dependencies [4474d04]
21
+ - Updated dependencies [183dc95]
22
+ - Updated dependencies [a1111e2]
23
+ - Updated dependencies [b42a961]
24
+ - Updated dependencies [61debef]
25
+ - Updated dependencies [9beaeff]
26
+ - Updated dependencies [29de0e1]
27
+ - Updated dependencies [f643c65]
28
+ - Updated dependencies [00c74e7]
29
+ - Updated dependencies [fef7375]
30
+ - Updated dependencies [e3d8fea]
31
+ - Updated dependencies [45e4d39]
32
+ - Updated dependencies [9eee594]
33
+ - Updated dependencies [7149d8d]
34
+ - Updated dependencies [822c2e8]
35
+ - Updated dependencies [979912c]
36
+ - Updated dependencies [7dcf4c0]
37
+ - Updated dependencies [4106a58]
38
+ - Updated dependencies [ad78bfc]
39
+ - Updated dependencies [0302f50]
40
+ - Updated dependencies [6ac697e]
41
+ - Updated dependencies [74db265]
42
+ - Updated dependencies [0ce418a]
43
+ - Updated dependencies [af90672]
44
+ - Updated dependencies [8387952]
45
+ - Updated dependencies [7f3b8da]
46
+ - Updated dependencies [905352b]
47
+ - Updated dependencies [599d04c]
48
+ - Updated dependencies [56041d0]
49
+ - Updated dependencies [3412597]
50
+ - Updated dependencies [5eca5d2]
51
+ - Updated dependencies [f2cda47]
52
+ - Updated dependencies [5de1555]
53
+ - Updated dependencies [cfd377a]
54
+ - Updated dependencies [1ed5a3e]
55
+ - @mastra/core@0.15.3
56
+
57
+ ## 0.11.3-alpha.3
58
+
59
+ ### Patch Changes
60
+
61
+ - [#7383](https://github.com/mastra-ai/mastra/pull/7383) [`b42a961`](https://github.com/mastra-ai/mastra/commit/b42a961a5aefd19d6e938a7705fc0ecc90e8f756) Thanks [@DanielSLew](https://github.com/DanielSLew)! - New createMCPTool helper for correct types for MCP Server tools
62
+
63
+ - [#7389](https://github.com/mastra-ai/mastra/pull/7389) [`3b8972b`](https://github.com/mastra-ai/mastra/commit/3b8972bab8161d9fd96f6a41f57181443636cd43) Thanks [@DanielSLew](https://github.com/DanielSLew)! - Turn MCPTool into a generic to get parameter typing
64
+
65
+ - [#7349](https://github.com/mastra-ai/mastra/pull/7349) [`6cffb99`](https://github.com/mastra-ai/mastra/commit/6cffb99030dc46256e4c3c0e6730565a2825d7a4) Thanks [@adeleke5140](https://github.com/adeleke5140)! - Fix log level not being handled by server
66
+
67
+ - Updated dependencies [[`c19bcf7`](https://github.com/mastra-ai/mastra/commit/c19bcf7b43542b02157b5e17303e519933a153ab), [`b42a961`](https://github.com/mastra-ai/mastra/commit/b42a961a5aefd19d6e938a7705fc0ecc90e8f756), [`45e4d39`](https://github.com/mastra-ai/mastra/commit/45e4d391a2a09fc70c48e4d60f505586ada1ba0e), [`0302f50`](https://github.com/mastra-ai/mastra/commit/0302f50861a53c66ff28801fc371b37c5f97e41e), [`74db265`](https://github.com/mastra-ai/mastra/commit/74db265b96aa01a72ffd91dcae0bc3b346cca0f2), [`7f3b8da`](https://github.com/mastra-ai/mastra/commit/7f3b8da6dd21c35d3672e44b4f5dd3502b8f8f92), [`905352b`](https://github.com/mastra-ai/mastra/commit/905352bcda134552400eb252bca1cb05a7975c14), [`f2cda47`](https://github.com/mastra-ai/mastra/commit/f2cda47ae911038c5d5489f54c36517d6f15bdcc), [`cfd377a`](https://github.com/mastra-ai/mastra/commit/cfd377a3a33a9c88b644f6540feed9cd9832db47)]:
68
+ - @mastra/core@0.15.3-alpha.6
69
+
3
70
  ## 0.11.3-alpha.2
4
71
 
5
72
  ### Patch Changes
@@ -69,7 +69,7 @@ export declare class MCPClient extends MastraBase {
69
69
  };
70
70
  get prompts(): {
71
71
  list: () => Promise<Record<string, Prompt[]>>;
72
- get: ({ serverName, name, args, version }: {
72
+ get: ({ serverName, name, args, version, }: {
73
73
  serverName: string;
74
74
  name: string;
75
75
  args?: Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../src/client/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAI1H,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAI1D,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,iBAAiB,CAA8B;gBAE3C,IAAI,EAAE,gBAAgB;IA0ClC,IAAW,WAAW;gCAGY,MAAM,WAAW,CAAC,OAAO,EAAE,aAAa,CAAC,QAA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B,MAAM,WAAW,CAAC,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,KAAK,IAAI;oCAkB9C,MAAM,WAAW,MAAM,IAAI;MAmBhE;IAED,IAAW,OAAO;oBAGE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oDA6B9C;YACD,UAAU,EAAE,MAAM,CAAC;YACnB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;YAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAmBiC,MAAM,WAAW,MAAM,IAAI;MAmBhE;IAED,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,MAAM;IAOD,UAAU;IAsBV,QAAQ;IAwBR,WAAW;IAwBxB;;OAEG;IACU,YAAY;;;;;;;;;;;IAIzB;;;OAGG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvC;YAEa,kBAAkB;YAyDlB,2BAA2B;YAQ3B,eAAe;CAe9B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,IAAI,EAAE,gBAAgB;CAMnC"}
@@ -24,7 +24,7 @@ export declare class PromptClientActions {
24
24
  * @param version Optional version of the prompt to get.
25
25
  * @returns The prompt content.
26
26
  */
27
- get({ name, args, version }: {
27
+ get({ name, args, version, }: {
28
28
  name: string;
29
29
  args?: Record<string, any>;
30
30
  version?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"promptActions.d.ts","sourceRoot":"","sources":["../../src/client/promptActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,UAAU,yBAAyB;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAKzD;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBtC;;;;;;OAMG;IACU,GAAG,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAI/H;;;OAGG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
1
+ {"version":3,"file":"promptActions.d.ts","sourceRoot":"","sources":["../../src/client/promptActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD,UAAU,yBAAyB;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;gBAE3B,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAKzD;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAyBtC;;;;;;OAMG;IACU,GAAG,CAAC,EACf,IAAI,EACJ,IAAI,EACJ,OAAO,GACR,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,eAAe,CAAC;IAI5B;;;OAGG;IACU,aAAa,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/D"}
package/dist/index.cjs CHANGED
@@ -89,7 +89,11 @@ var PromptClientActions = class {
89
89
  * @param version Optional version of the prompt to get.
90
90
  * @returns The prompt content.
91
91
  */
92
- async get({ name, args, version }) {
92
+ async get({
93
+ name,
94
+ args,
95
+ version
96
+ }) {
93
97
  return this.client.getPrompt({ name, args, version });
94
98
  }
95
99
  /**
@@ -691,14 +695,17 @@ To fix this you have three different options:
691
695
  const internalClient = await this.getConnectedClientForServer(serverName);
692
696
  return internalClient.elicitation.onRequest(handler);
693
697
  } catch (err) {
694
- throw new error.MastraError({
695
- id: "MCP_CLIENT_ON_REQUEST_ELICITATION_FAILED",
696
- domain: error.ErrorDomain.MCP,
697
- category: error.ErrorCategory.THIRD_PARTY,
698
- details: {
699
- serverName
700
- }
701
- }, err);
698
+ throw new error.MastraError(
699
+ {
700
+ id: "MCP_CLIENT_ON_REQUEST_ELICITATION_FAILED",
701
+ domain: error.ErrorDomain.MCP,
702
+ category: error.ErrorCategory.THIRD_PARTY,
703
+ details: {
704
+ serverName
705
+ }
706
+ },
707
+ err
708
+ );
702
709
  }
703
710
  }
704
711
  };
@@ -713,14 +720,17 @@ To fix this you have three different options:
713
720
  const internalClient = await this.getConnectedClientForServer(serverName);
714
721
  allResources[serverName] = await internalClient.resources.list();
715
722
  } catch (error$1) {
716
- const mastraError = new error.MastraError({
717
- id: "MCP_CLIENT_LIST_RESOURCES_FAILED",
718
- domain: error.ErrorDomain.MCP,
719
- category: error.ErrorCategory.THIRD_PARTY,
720
- details: {
721
- serverName
722
- }
723
- }, error$1);
723
+ const mastraError = new error.MastraError(
724
+ {
725
+ id: "MCP_CLIENT_LIST_RESOURCES_FAILED",
726
+ domain: error.ErrorDomain.MCP,
727
+ category: error.ErrorCategory.THIRD_PARTY,
728
+ details: {
729
+ serverName
730
+ }
731
+ },
732
+ error$1
733
+ );
724
734
  this.logger.trackException(mastraError);
725
735
  this.logger.error("Failed to list resources from server:", { error: mastraError.toString() });
726
736
  }
@@ -734,14 +744,17 @@ To fix this you have three different options:
734
744
  const internalClient = await this.getConnectedClientForServer(serverName);
735
745
  allTemplates[serverName] = await internalClient.resources.templates();
736
746
  } catch (error$1) {
737
- const mastraError = new error.MastraError({
738
- id: "MCP_CLIENT_LIST_RESOURCE_TEMPLATES_FAILED",
739
- domain: error.ErrorDomain.MCP,
740
- category: error.ErrorCategory.THIRD_PARTY,
741
- details: {
742
- serverName
743
- }
744
- }, error$1);
747
+ const mastraError = new error.MastraError(
748
+ {
749
+ id: "MCP_CLIENT_LIST_RESOURCE_TEMPLATES_FAILED",
750
+ domain: error.ErrorDomain.MCP,
751
+ category: error.ErrorCategory.THIRD_PARTY,
752
+ details: {
753
+ serverName
754
+ }
755
+ },
756
+ error$1
757
+ );
745
758
  this.logger.trackException(mastraError);
746
759
  this.logger.error("Failed to list resource templates from server:", { error: mastraError.toString() });
747
760
  }
@@ -753,15 +766,18 @@ To fix this you have three different options:
753
766
  const internalClient = await this.getConnectedClientForServer(serverName);
754
767
  return internalClient.resources.read(uri);
755
768
  } catch (error$1) {
756
- throw new error.MastraError({
757
- id: "MCP_CLIENT_READ_RESOURCE_FAILED",
758
- domain: error.ErrorDomain.MCP,
759
- category: error.ErrorCategory.THIRD_PARTY,
760
- details: {
761
- serverName,
762
- uri
763
- }
764
- }, error$1);
769
+ throw new error.MastraError(
770
+ {
771
+ id: "MCP_CLIENT_READ_RESOURCE_FAILED",
772
+ domain: error.ErrorDomain.MCP,
773
+ category: error.ErrorCategory.THIRD_PARTY,
774
+ details: {
775
+ serverName,
776
+ uri
777
+ }
778
+ },
779
+ error$1
780
+ );
765
781
  }
766
782
  },
767
783
  subscribe: async (serverName, uri) => {
@@ -769,15 +785,18 @@ To fix this you have three different options:
769
785
  const internalClient = await this.getConnectedClientForServer(serverName);
770
786
  return internalClient.resources.subscribe(uri);
771
787
  } catch (error$1) {
772
- throw new error.MastraError({
773
- id: "MCP_CLIENT_SUBSCRIBE_RESOURCE_FAILED",
774
- domain: error.ErrorDomain.MCP,
775
- category: error.ErrorCategory.THIRD_PARTY,
776
- details: {
777
- serverName,
778
- uri
779
- }
780
- }, error$1);
788
+ throw new error.MastraError(
789
+ {
790
+ id: "MCP_CLIENT_SUBSCRIBE_RESOURCE_FAILED",
791
+ domain: error.ErrorDomain.MCP,
792
+ category: error.ErrorCategory.THIRD_PARTY,
793
+ details: {
794
+ serverName,
795
+ uri
796
+ }
797
+ },
798
+ error$1
799
+ );
781
800
  }
782
801
  },
783
802
  unsubscribe: async (serverName, uri) => {
@@ -785,15 +804,18 @@ To fix this you have three different options:
785
804
  const internalClient = await this.getConnectedClientForServer(serverName);
786
805
  return internalClient.resources.unsubscribe(uri);
787
806
  } catch (err) {
788
- throw new error.MastraError({
789
- id: "MCP_CLIENT_UNSUBSCRIBE_RESOURCE_FAILED",
790
- domain: error.ErrorDomain.MCP,
791
- category: error.ErrorCategory.THIRD_PARTY,
792
- details: {
793
- serverName,
794
- uri
795
- }
796
- }, err);
807
+ throw new error.MastraError(
808
+ {
809
+ id: "MCP_CLIENT_UNSUBSCRIBE_RESOURCE_FAILED",
810
+ domain: error.ErrorDomain.MCP,
811
+ category: error.ErrorCategory.THIRD_PARTY,
812
+ details: {
813
+ serverName,
814
+ uri
815
+ }
816
+ },
817
+ err
818
+ );
797
819
  }
798
820
  },
799
821
  onUpdated: async (serverName, handler) => {
@@ -801,14 +823,17 @@ To fix this you have three different options:
801
823
  const internalClient = await this.getConnectedClientForServer(serverName);
802
824
  return internalClient.resources.onUpdated(handler);
803
825
  } catch (err) {
804
- throw new error.MastraError({
805
- id: "MCP_CLIENT_ON_UPDATED_RESOURCE_FAILED",
806
- domain: error.ErrorDomain.MCP,
807
- category: error.ErrorCategory.THIRD_PARTY,
808
- details: {
809
- serverName
810
- }
811
- }, err);
826
+ throw new error.MastraError(
827
+ {
828
+ id: "MCP_CLIENT_ON_UPDATED_RESOURCE_FAILED",
829
+ domain: error.ErrorDomain.MCP,
830
+ category: error.ErrorCategory.THIRD_PARTY,
831
+ details: {
832
+ serverName
833
+ }
834
+ },
835
+ err
836
+ );
812
837
  }
813
838
  },
814
839
  onListChanged: async (serverName, handler) => {
@@ -816,14 +841,17 @@ To fix this you have three different options:
816
841
  const internalClient = await this.getConnectedClientForServer(serverName);
817
842
  return internalClient.resources.onListChanged(handler);
818
843
  } catch (err) {
819
- throw new error.MastraError({
820
- id: "MCP_CLIENT_ON_LIST_CHANGED_RESOURCE_FAILED",
821
- domain: error.ErrorDomain.MCP,
822
- category: error.ErrorCategory.THIRD_PARTY,
823
- details: {
824
- serverName
825
- }
826
- }, err);
844
+ throw new error.MastraError(
845
+ {
846
+ id: "MCP_CLIENT_ON_LIST_CHANGED_RESOURCE_FAILED",
847
+ domain: error.ErrorDomain.MCP,
848
+ category: error.ErrorCategory.THIRD_PARTY,
849
+ details: {
850
+ serverName
851
+ }
852
+ },
853
+ err
854
+ );
827
855
  }
828
856
  }
829
857
  };
@@ -838,34 +866,45 @@ To fix this you have three different options:
838
866
  const internalClient = await this.getConnectedClientForServer(serverName);
839
867
  allPrompts[serverName] = await internalClient.prompts.list();
840
868
  } catch (error$1) {
841
- const mastraError = new error.MastraError({
842
- id: "MCP_CLIENT_LIST_PROMPTS_FAILED",
843
- domain: error.ErrorDomain.MCP,
844
- category: error.ErrorCategory.THIRD_PARTY,
845
- details: {
846
- serverName
847
- }
848
- }, error$1);
869
+ const mastraError = new error.MastraError(
870
+ {
871
+ id: "MCP_CLIENT_LIST_PROMPTS_FAILED",
872
+ domain: error.ErrorDomain.MCP,
873
+ category: error.ErrorCategory.THIRD_PARTY,
874
+ details: {
875
+ serverName
876
+ }
877
+ },
878
+ error$1
879
+ );
849
880
  this.logger.trackException(mastraError);
850
881
  this.logger.error("Failed to list prompts from server:", { error: mastraError.toString() });
851
882
  }
852
883
  }
853
884
  return allPrompts;
854
885
  },
855
- get: async ({ serverName, name, args, version }) => {
886
+ get: async ({
887
+ serverName,
888
+ name,
889
+ args,
890
+ version
891
+ }) => {
856
892
  try {
857
893
  const internalClient = await this.getConnectedClientForServer(serverName);
858
894
  return internalClient.prompts.get({ name, args, version });
859
895
  } catch (error$1) {
860
- throw new error.MastraError({
861
- id: "MCP_CLIENT_GET_PROMPT_FAILED",
862
- domain: error.ErrorDomain.MCP,
863
- category: error.ErrorCategory.THIRD_PARTY,
864
- details: {
865
- serverName,
866
- name
867
- }
868
- }, error$1);
896
+ throw new error.MastraError(
897
+ {
898
+ id: "MCP_CLIENT_GET_PROMPT_FAILED",
899
+ domain: error.ErrorDomain.MCP,
900
+ category: error.ErrorCategory.THIRD_PARTY,
901
+ details: {
902
+ serverName,
903
+ name
904
+ }
905
+ },
906
+ error$1
907
+ );
869
908
  }
870
909
  },
871
910
  onListChanged: async (serverName, handler) => {
@@ -873,14 +912,17 @@ To fix this you have three different options:
873
912
  const internalClient = await this.getConnectedClientForServer(serverName);
874
913
  return internalClient.prompts.onListChanged(handler);
875
914
  } catch (error$1) {
876
- throw new error.MastraError({
877
- id: "MCP_CLIENT_ON_LIST_CHANGED_PROMPT_FAILED",
878
- domain: error.ErrorDomain.MCP,
879
- category: error.ErrorCategory.THIRD_PARTY,
880
- details: {
881
- serverName
882
- }
883
- }, error$1);
915
+ throw new error.MastraError(
916
+ {
917
+ id: "MCP_CLIENT_ON_LIST_CHANGED_PROMPT_FAILED",
918
+ domain: error.ErrorDomain.MCP,
919
+ category: error.ErrorCategory.THIRD_PARTY,
920
+ details: {
921
+ serverName
922
+ }
923
+ },
924
+ error$1
925
+ );
884
926
  }
885
927
  }
886
928
  };
@@ -920,11 +962,14 @@ To fix this you have three different options:
920
962
  }
921
963
  });
922
964
  } catch (error$1) {
923
- throw new error.MastraError({
924
- id: "MCP_CLIENT_GET_TOOLS_FAILED",
925
- domain: error.ErrorDomain.MCP,
926
- category: error.ErrorCategory.THIRD_PARTY
927
- }, error$1);
965
+ throw new error.MastraError(
966
+ {
967
+ id: "MCP_CLIENT_GET_TOOLS_FAILED",
968
+ domain: error.ErrorDomain.MCP,
969
+ category: error.ErrorCategory.THIRD_PARTY
970
+ },
971
+ error$1
972
+ );
928
973
  }
929
974
  return connectedTools;
930
975
  }
@@ -938,11 +983,14 @@ To fix this you have three different options:
938
983
  }
939
984
  });
940
985
  } catch (error$1) {
941
- throw new error.MastraError({
942
- id: "MCP_CLIENT_GET_TOOLSETS_FAILED",
943
- domain: error.ErrorDomain.MCP,
944
- category: error.ErrorCategory.THIRD_PARTY
945
- }, error$1);
986
+ throw new error.MastraError(
987
+ {
988
+ id: "MCP_CLIENT_GET_TOOLSETS_FAILED",
989
+ domain: error.ErrorDomain.MCP,
990
+ category: error.ErrorCategory.THIRD_PARTY
991
+ },
992
+ error$1
993
+ );
946
994
  }
947
995
  return connectedToolsets;
948
996
  }
@@ -990,15 +1038,18 @@ To fix this you have three different options:
990
1038
  try {
991
1039
  await mcpClient.connect();
992
1040
  } catch (e) {
993
- const mastraError = new error.MastraError({
994
- id: "MCP_CLIENT_CONNECT_FAILED",
995
- domain: error.ErrorDomain.MCP,
996
- category: error.ErrorCategory.THIRD_PARTY,
997
- text: `Failed to connect to MCP server ${name}: ${e instanceof Error ? e.stack || e.message : String(e)}`,
998
- details: {
999
- name
1000
- }
1001
- }, e);
1041
+ const mastraError = new error.MastraError(
1042
+ {
1043
+ id: "MCP_CLIENT_CONNECT_FAILED",
1044
+ domain: error.ErrorDomain.MCP,
1045
+ category: error.ErrorCategory.THIRD_PARTY,
1046
+ text: `Failed to connect to MCP server ${name}: ${e instanceof Error ? e.stack || e.message : String(e)}`,
1047
+ details: {
1048
+ name
1049
+ }
1050
+ },
1051
+ e
1052
+ );
1002
1053
  this.logger.trackException(mastraError);
1003
1054
  this.logger.error("MCPClient errored connecting to MCP server:", { error: mastraError.toString() });
1004
1055
  this.mcpClientsById.delete(name);
@@ -1406,6 +1457,7 @@ var MCPServer = class extends mcp.MCPServerBase {
1406
1457
  definedPrompts;
1407
1458
  promptOptions;
1408
1459
  subscriptions = /* @__PURE__ */ new Set();
1460
+ currentLoggingLevel;
1409
1461
  resources;
1410
1462
  prompts;
1411
1463
  elicitation;
@@ -1650,6 +1702,11 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1650
1702
  };
1651
1703
  }
1652
1704
  });
1705
+ serverInstance.setRequestHandler(types_js.SetLevelRequestSchema, async (request) => {
1706
+ this.currentLoggingLevel = request.params.level;
1707
+ this.logger.debug(`Logging level set to: ${request.params.level}`);
1708
+ return {};
1709
+ });
1653
1710
  if (this.resourceOptions) {
1654
1711
  this.registerResourceHandlersOnServer(serverInstance);
1655
1712
  }
@@ -1967,7 +2024,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
1967
2024
  /**
1968
2025
  * Convert and validate all provided tools, logging registration status.
1969
2026
  * Also converts agents and workflows into tools.
1970
- * @param tools Tool definitions
2027
+ * @param tools Tool definitions (supports ToolsInput, MCPToolsInput)
1971
2028
  * @param agentsConfig Agent definitions to be converted to tools, expected from MCPServerConfig
1972
2029
  * @param workflowsConfig Workflow definitions to be converted to tools, expected from MCPServerConfig
1973
2030
  * @returns Converted tools registry
@@ -2000,7 +2057,7 @@ Provided arguments: ${JSON.stringify(request.params.arguments, null, 2)}`
2000
2057
  outputSchema: coreTool.outputSchema,
2001
2058
  execute: coreTool.execute
2002
2059
  };
2003
- this.logger.info(`Registered explicit tool: '${toolName}'`);
2060
+ this.logger.info(`Registered tool: '${toolName}'`);
2004
2061
  }
2005
2062
  this.logger.info(`Total defined tools registered: ${Object.keys(definedConvertedTools).length}`);
2006
2063
  let agentDerivedTools = {};
@@ -2593,10 +2650,61 @@ Provided arguments: ${JSON.stringify(args, null, 2)}`,
2593
2650
  }
2594
2651
  }
2595
2652
  };
2653
+ function createMCPTool(opts) {
2654
+ let parameters;
2655
+ let outputSchema;
2656
+ if (opts.inputSchema) {
2657
+ parameters = {
2658
+ jsonSchema: opts.inputSchema,
2659
+ validate: (value) => {
2660
+ try {
2661
+ const result = opts.inputSchema.safeParse(value);
2662
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
2663
+ } catch (e) {
2664
+ return { success: false, error: e };
2665
+ }
2666
+ }
2667
+ };
2668
+ } else {
2669
+ parameters = void 0;
2670
+ }
2671
+ if (opts.outputSchema) {
2672
+ outputSchema = {
2673
+ jsonSchema: opts.outputSchema,
2674
+ validate: (value) => {
2675
+ try {
2676
+ const result = opts.outputSchema.safeParse(value);
2677
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
2678
+ } catch (e) {
2679
+ return { success: false, error: e };
2680
+ }
2681
+ }
2682
+ };
2683
+ }
2684
+ return {
2685
+ id: opts.id,
2686
+ description: opts.description,
2687
+ parameters,
2688
+ outputSchema,
2689
+ execute: async (params, options) => {
2690
+ const mcpOptions = {
2691
+ context: params,
2692
+ elicitation: options.elicitation,
2693
+ extra: options.extra
2694
+ };
2695
+ const { data, error } = tools.validateToolInput(opts.inputSchema, params, opts.id);
2696
+ if (error) {
2697
+ return error;
2698
+ }
2699
+ return opts.execute(data, mcpOptions);
2700
+ }
2701
+ };
2702
+ }
2596
2703
 
2597
2704
  exports.MCPClient = MCPClient;
2598
2705
  exports.MCPConfiguration = MCPConfiguration;
2599
2706
  exports.MCPServer = MCPServer;
2600
2707
  exports.MastraMCPClient = MastraMCPClient;
2708
+ exports.createMCPTool = createMCPTool;
2601
2709
  //# sourceMappingURL=index.cjs.map
2602
2710
  //# sourceMappingURL=index.cjs.map