@mastra/mcp 0.3.5-alpha.0 → 0.3.5

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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/mcp@0.3.5-alpha.0 build /home/runner/work/mastra/mastra/packages/mcp
2
+ > @mastra/mcp@0.3.5-alpha.1 build /home/runner/work/mastra/mastra/packages/mcp
3
3
  > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
4
4
 
5
5
  CLI Building entry: src/index.ts
6
6
  CLI Using tsconfig: tsconfig.json
7
7
  CLI tsup v8.4.0
8
8
  TSC Build start
9
- TSC ⚡️ Build success in 9949ms
9
+ TSC ⚡️ Build success in 10820ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.2
13
13
  Writing package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.ts
14
14
  Analysis will use the bundled TypeScript version 5.8.2
15
15
  Writing package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 10541ms
16
+ DTS ⚡️ Build success in 9756ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- ESM dist/index.js 6.91 KB
21
- ESM ⚡️ Build success in 503ms
22
- CJS dist/index.cjs 6.96 KB
23
- CJS ⚡️ Build success in 503ms
20
+ CJS dist/index.cjs 7.27 KB
21
+ CJS ⚡️ Build success in 594ms
22
+ ESM dist/index.js 7.24 KB
23
+ ESM ⚡️ Build success in 594ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 0.3.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 2621e3f: Added MCP client timeout option used for tool calls.
8
+ - Updated dependencies [6794797]
9
+ - Updated dependencies [fb68a80]
10
+ - Updated dependencies [b56a681]
11
+ - Updated dependencies [248cb07]
12
+ - @mastra/core@0.6.4
13
+
14
+ ## 0.3.5-alpha.1
15
+
16
+ ### Patch Changes
17
+
18
+ - 2621e3f: Added MCP client timeout option used for tool calls.
19
+ - Updated dependencies [6794797]
20
+ - @mastra/core@0.6.4-alpha.1
21
+
3
22
  ## 0.3.5-alpha.0
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -38,6 +38,7 @@ const sseClient = new MastraMCPClient({
38
38
  headers: { Authorization: 'Bearer your-token' },
39
39
  },
40
40
  },
41
+ timeout: 60000, // optional timeout for tool calls in milliseconds
41
42
  });
42
43
 
43
44
  // Connect to the MCP server
@@ -9,11 +9,13 @@ declare class MastraMCPClient extends MastraBase {
9
9
  name: string;
10
10
  private transport;
11
11
  private client;
12
- constructor({ name, version, server, capabilities, }: {
12
+ private readonly timeout;
13
+ constructor({ name, version, server, capabilities, timeout, }: {
13
14
  name: string;
14
15
  server: MastraMCPServerDefinition;
15
16
  capabilities?: ClientCapabilities;
16
17
  version?: string;
18
+ timeout?: number;
17
19
  });
18
20
  private isConnected;
19
21
  connect(): Promise<void>;
@@ -9,11 +9,13 @@ declare class MastraMCPClient extends MastraBase {
9
9
  name: string;
10
10
  private transport;
11
11
  private client;
12
- constructor({ name, version, server, capabilities, }: {
12
+ private readonly timeout;
13
+ constructor({ name, version, server, capabilities, timeout, }: {
13
14
  name: string;
14
15
  server: MastraMCPServerDefinition;
15
16
  capabilities?: ClientCapabilities;
16
17
  version?: string;
18
+ timeout?: number;
17
19
  });
18
20
  private isConnected;
19
21
  connect(): Promise<void>;
package/dist/index.cjs CHANGED
@@ -6,6 +6,7 @@ var utils = require('@mastra/core/utils');
6
6
  var index_js = require('@modelcontextprotocol/sdk/client/index.js');
7
7
  var sse_js = require('@modelcontextprotocol/sdk/client/sse.js');
8
8
  var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
9
+ var protocol_js = require('@modelcontextprotocol/sdk/shared/protocol.js');
9
10
  var types_js = require('@modelcontextprotocol/sdk/types.js');
10
11
  var exitHook = require('exit-hook');
11
12
  var uuid = require('uuid');
@@ -15,14 +16,17 @@ var MastraMCPClient = class extends base.MastraBase {
15
16
  name;
16
17
  transport;
17
18
  client;
19
+ timeout;
18
20
  constructor({
19
21
  name,
20
22
  version = "1.0.0",
21
23
  server,
22
- capabilities = {}
24
+ capabilities = {},
25
+ timeout = protocol_js.DEFAULT_REQUEST_TIMEOUT_MSEC
23
26
  }) {
24
27
  super({ name: "MastraMCPClient" });
25
28
  this.name = name;
29
+ this.timeout = timeout;
26
30
  if (`url` in server) {
27
31
  this.transport = new sse_js.SSEClientTransport(server.url, {
28
32
  requestInit: server.requestInit,
@@ -93,10 +97,16 @@ ${e instanceof Error ? e.stack : JSON.stringify(e, null, 2)}`
93
97
  inputSchema: s,
94
98
  execute: async ({ context }) => {
95
99
  try {
96
- const res = await this.client.callTool({
97
- name: tool.name,
98
- arguments: context
99
- });
100
+ const res = await this.client.callTool(
101
+ {
102
+ name: tool.name,
103
+ arguments: context
104
+ },
105
+ types_js.CallToolResultSchema,
106
+ {
107
+ timeout: this.timeout
108
+ }
109
+ );
100
110
  return res;
101
111
  } catch (e) {
102
112
  console.log("Error calling tool", tool.name);
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import { jsonSchemaToModel } from '@mastra/core/utils';
4
4
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
5
  import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
6
6
  import { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/sdk/client/stdio.js';
7
- import { ListResourcesResultSchema } from '@modelcontextprotocol/sdk/types.js';
7
+ import { DEFAULT_REQUEST_TIMEOUT_MSEC } from '@modelcontextprotocol/sdk/shared/protocol.js';
8
+ import { ListResourcesResultSchema, CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
8
9
  import { asyncExitHook, gracefulExit } from 'exit-hook';
9
10
  import { v5 } from 'uuid';
10
11
 
@@ -13,14 +14,17 @@ var MastraMCPClient = class extends MastraBase {
13
14
  name;
14
15
  transport;
15
16
  client;
17
+ timeout;
16
18
  constructor({
17
19
  name,
18
20
  version = "1.0.0",
19
21
  server,
20
- capabilities = {}
22
+ capabilities = {},
23
+ timeout = DEFAULT_REQUEST_TIMEOUT_MSEC
21
24
  }) {
22
25
  super({ name: "MastraMCPClient" });
23
26
  this.name = name;
27
+ this.timeout = timeout;
24
28
  if (`url` in server) {
25
29
  this.transport = new SSEClientTransport(server.url, {
26
30
  requestInit: server.requestInit,
@@ -91,10 +95,16 @@ ${e instanceof Error ? e.stack : JSON.stringify(e, null, 2)}`
91
95
  inputSchema: s,
92
96
  execute: async ({ context }) => {
93
97
  try {
94
- const res = await this.client.callTool({
95
- name: tool.name,
96
- arguments: context
97
- });
98
+ const res = await this.client.callTool(
99
+ {
100
+ name: tool.name,
101
+ arguments: context
102
+ },
103
+ CallToolResultSchema,
104
+ {
105
+ timeout: this.timeout
106
+ }
107
+ );
98
108
  return res;
99
109
  } catch (e) {
100
110
  console.log("Error calling tool", tool.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp",
3
- "version": "0.3.5-alpha.0",
3
+ "version": "0.3.5",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "date-fns": "^4.1.0",
27
27
  "exit-hook": "^4.0.0",
28
28
  "uuid": "^11.1.0",
29
- "@mastra/core": "^0.6.4-alpha.0"
29
+ "@mastra/core": "^0.6.4"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@ai-sdk/anthropic": "^1.1.15",
package/src/client.ts CHANGED
@@ -5,10 +5,11 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
5
5
  import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
6
6
  import { getDefaultEnvironment, StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
7
7
  import type { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
8
+ import { DEFAULT_REQUEST_TIMEOUT_MSEC } from '@modelcontextprotocol/sdk/shared/protocol.js';
8
9
  import type { Protocol } from '@modelcontextprotocol/sdk/shared/protocol.js';
9
10
  import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
10
11
  import type { ClientCapabilities } from '@modelcontextprotocol/sdk/types.js';
11
- import { ListResourcesResultSchema } from '@modelcontextprotocol/sdk/types.js';
12
+ import { CallToolResultSchema, ListResourcesResultSchema } from '@modelcontextprotocol/sdk/types.js';
12
13
 
13
14
  import { asyncExitHook, gracefulExit } from 'exit-hook';
14
15
 
@@ -22,19 +23,23 @@ export class MastraMCPClient extends MastraBase {
22
23
  name: string;
23
24
  private transport: Transport;
24
25
  private client: Client;
26
+ private readonly timeout: number;
25
27
  constructor({
26
28
  name,
27
29
  version = '1.0.0',
28
30
  server,
29
31
  capabilities = {},
32
+ timeout = DEFAULT_REQUEST_TIMEOUT_MSEC,
30
33
  }: {
31
34
  name: string;
32
35
  server: MastraMCPServerDefinition;
33
36
  capabilities?: ClientCapabilities;
34
37
  version?: string;
38
+ timeout?: number;
35
39
  }) {
36
40
  super({ name: 'MastraMCPClient' });
37
41
  this.name = name;
42
+ this.timeout = timeout;
38
43
 
39
44
  if (`url` in server) {
40
45
  this.transport = new SSEClientTransport(server.url, {
@@ -113,10 +118,16 @@ export class MastraMCPClient extends MastraBase {
113
118
  inputSchema: s,
114
119
  execute: async ({ context }) => {
115
120
  try {
116
- const res = await this.client.callTool({
117
- name: tool.name,
118
- arguments: context,
119
- });
121
+ const res = await this.client.callTool(
122
+ {
123
+ name: tool.name,
124
+ arguments: context,
125
+ },
126
+ CallToolResultSchema,
127
+ {
128
+ timeout: this.timeout,
129
+ },
130
+ );
120
131
 
121
132
  return res;
122
133
  } catch (e) {