@mastra/mcp 0.4.1 → 0.4.2-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.
@@ -1,23 +1,23 @@
1
1
 
2
- > @mastra/mcp@0.4.1-alpha.9 build /home/runner/work/mastra/mastra/packages/mcp
2
+ > @mastra/mcp@0.4.2-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 16988ms
9
+ TSC ⚡️ Build success in 18020ms
10
10
  DTS Build start
11
11
  CLI Target: es2022
12
12
  Analysis will use the bundled TypeScript version 5.8.3
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.3
15
15
  Writing package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 13694ms
16
+ DTS ⚡️ Build success in 14020ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 205.23 KB
21
- CJS ⚡️ Build success in 4572ms
22
- ESM dist/index.js 204.37 KB
23
- ESM ⚡️ Build success in 4572ms
20
+ ESM dist/index.js 204.28 KB
21
+ ESM ⚡️ Build success in 4394ms
22
+ CJS dist/index.cjs 205.14 KB
23
+ CJS ⚡️ Build success in 4394ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 0.4.2-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8bb9b4d: Deprecation warning was on the subclass, rather than the deprecated class. So the deprecation warning would show even if you used the new class.
8
+ - Updated dependencies [b804723]
9
+ - @mastra/core@0.9.2-alpha.1
10
+
11
+ ## 0.4.2-alpha.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [0097d50]
16
+ - @mastra/core@0.9.2-alpha.0
17
+
3
18
  ## 0.4.1
4
19
 
5
20
  ### Patch Changes
@@ -46,16 +46,9 @@ export declare class InternalMastraMCPClient extends MastraBase {
46
46
  private readonly timeout;
47
47
  private logHandler?;
48
48
  private enableServerLogs?;
49
- private static hasWarned;
50
49
  private serverConfig;
51
50
  private transport?;
52
- constructor({ name, version, server, capabilities, timeout, }: {
53
- name: string;
54
- server: MastraMCPServerDefinition;
55
- capabilities?: ClientCapabilities;
56
- version?: string;
57
- timeout?: number;
58
- });
51
+ constructor({ name, version, server, capabilities, timeout, }: InternalMastraMCPClientOptions);
59
52
  /**
60
53
  * Log a message at the specified level
61
54
  * @param level Log level
@@ -78,6 +71,14 @@ export declare class InternalMastraMCPClient extends MastraBase {
78
71
  tools(): Promise<Record<string, any>>;
79
72
  }
80
73
 
74
+ export declare type InternalMastraMCPClientOptions = {
75
+ name: string;
76
+ server: MastraMCPServerDefinition;
77
+ capabilities?: ClientCapabilities;
78
+ version?: string;
79
+ timeout?: number;
80
+ };
81
+
81
82
  export declare interface Logger {
82
83
  info: (message: string, data?: any) => Promise<void>;
83
84
  warning: (message: string, data?: any) => Promise<void>;
@@ -107,7 +108,9 @@ export { LogMessage as LogMessage_alias_1 }
107
108
  /**
108
109
  * @deprecated MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead.
109
110
  */
110
- declare const MastraMCPClient: typeof InternalMastraMCPClient;
111
+ declare class MastraMCPClient extends InternalMastraMCPClient {
112
+ constructor(args: InternalMastraMCPClientOptions);
113
+ }
111
114
  export { MastraMCPClient }
112
115
  export { MastraMCPClient as MastraMCPClient_alias_1 }
113
116
 
@@ -46,16 +46,9 @@ export declare class InternalMastraMCPClient extends MastraBase {
46
46
  private readonly timeout;
47
47
  private logHandler?;
48
48
  private enableServerLogs?;
49
- private static hasWarned;
50
49
  private serverConfig;
51
50
  private transport?;
52
- constructor({ name, version, server, capabilities, timeout, }: {
53
- name: string;
54
- server: MastraMCPServerDefinition;
55
- capabilities?: ClientCapabilities;
56
- version?: string;
57
- timeout?: number;
58
- });
51
+ constructor({ name, version, server, capabilities, timeout, }: InternalMastraMCPClientOptions);
59
52
  /**
60
53
  * Log a message at the specified level
61
54
  * @param level Log level
@@ -78,6 +71,14 @@ export declare class InternalMastraMCPClient extends MastraBase {
78
71
  tools(): Promise<Record<string, any>>;
79
72
  }
80
73
 
74
+ export declare type InternalMastraMCPClientOptions = {
75
+ name: string;
76
+ server: MastraMCPServerDefinition;
77
+ capabilities?: ClientCapabilities;
78
+ version?: string;
79
+ timeout?: number;
80
+ };
81
+
81
82
  export declare interface Logger {
82
83
  info: (message: string, data?: any) => Promise<void>;
83
84
  warning: (message: string, data?: any) => Promise<void>;
@@ -107,7 +108,9 @@ export { LogMessage as LogMessage_alias_1 }
107
108
  /**
108
109
  * @deprecated MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead.
109
110
  */
110
- declare const MastraMCPClient: typeof InternalMastraMCPClient;
111
+ declare class MastraMCPClient extends InternalMastraMCPClient {
112
+ constructor(args: InternalMastraMCPClientOptions);
113
+ }
111
114
  export { MastraMCPClient }
112
115
  export { MastraMCPClient as MastraMCPClient_alias_1 }
113
116
 
package/dist/index.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
  var base = require('@mastra/core/base');
4
4
  var tools = require('@mastra/core/tools');
5
5
  var utils = require('@mastra/core/utils');
6
- var index_js = require('@modelcontextprotocol/sdk/client/index.js');
7
- var sse_js = require('@modelcontextprotocol/sdk/client/sse.js');
8
- var stdio_js = require('@modelcontextprotocol/sdk/client/stdio.js');
6
+ var index_js$1 = require('@modelcontextprotocol/sdk/client/index.js');
7
+ var sse_js$1 = require('@modelcontextprotocol/sdk/client/sse.js');
8
+ var stdio_js$1 = require('@modelcontextprotocol/sdk/client/stdio.js');
9
9
  var streamableHttp_js = require('@modelcontextprotocol/sdk/client/streamableHttp.js');
10
10
  var protocol_js = require('@modelcontextprotocol/sdk/shared/protocol.js');
11
11
  var types_js = require('@modelcontextprotocol/sdk/types.js');
@@ -13,9 +13,9 @@ var exitHook = require('exit-hook');
13
13
  var equal = require('fast-deep-equal');
14
14
  var uuid = require('uuid');
15
15
  var core = require('@mastra/core');
16
- var index_js$1 = require('@modelcontextprotocol/sdk/server/index.js');
17
- var sse_js$1 = require('@modelcontextprotocol/sdk/server/sse.js');
18
- var stdio_js$1 = require('@modelcontextprotocol/sdk/server/stdio.js');
16
+ var index_js = require('@modelcontextprotocol/sdk/server/index.js');
17
+ var sse_js = require('@modelcontextprotocol/sdk/server/sse.js');
18
+ var stdio_js = require('@modelcontextprotocol/sdk/server/stdio.js');
19
19
  var fs = require('fs');
20
20
  var os = require('os');
21
21
  var path = require('path');
@@ -4122,13 +4122,12 @@ function convertLogLevelToLoggerMethod(level) {
4122
4122
  return "info";
4123
4123
  }
4124
4124
  }
4125
- var InternalMastraMCPClient = class _InternalMastraMCPClient extends base.MastraBase {
4125
+ var InternalMastraMCPClient = class extends base.MastraBase {
4126
4126
  name;
4127
4127
  client;
4128
4128
  timeout;
4129
4129
  logHandler;
4130
4130
  enableServerLogs;
4131
- static hasWarned = false;
4132
4131
  serverConfig;
4133
4132
  transport;
4134
4133
  constructor({
@@ -4139,18 +4138,12 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends base.Mastra
4139
4138
  timeout = protocol_js.DEFAULT_REQUEST_TIMEOUT_MSEC
4140
4139
  }) {
4141
4140
  super({ name: "MastraMCPClient" });
4142
- if (!_InternalMastraMCPClient.hasWarned) {
4143
- console.warn(
4144
- "[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead."
4145
- );
4146
- _InternalMastraMCPClient.hasWarned = true;
4147
- }
4148
4141
  this.name = name;
4149
4142
  this.timeout = timeout;
4150
4143
  this.logHandler = server.logger;
4151
4144
  this.enableServerLogs = server.enableServerLogs ?? true;
4152
4145
  this.serverConfig = server;
4153
- this.client = new index_js.Client(
4146
+ this.client = new index_js$1.Client(
4154
4147
  {
4155
4148
  name,
4156
4149
  version
@@ -4200,10 +4193,10 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends base.Mastra
4200
4193
  async connectStdio(command) {
4201
4194
  this.log("debug", `Using Stdio transport for command: ${command}`);
4202
4195
  try {
4203
- this.transport = new stdio_js.StdioClientTransport({
4196
+ this.transport = new stdio_js$1.StdioClientTransport({
4204
4197
  command,
4205
4198
  args: this.serverConfig.args,
4206
- env: { ...stdio_js.getDefaultEnvironment(), ...this.serverConfig.env || {} }
4199
+ env: { ...stdio_js$1.getDefaultEnvironment(), ...this.serverConfig.env || {} }
4207
4200
  });
4208
4201
  await this.client.connect(this.transport, { timeout: this.serverConfig.timeout ?? this.timeout });
4209
4202
  this.log("debug", `Successfully connected to MCP server via Stdio`);
@@ -4240,7 +4233,7 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends base.Mastra
4240
4233
  if (shouldTrySSE) {
4241
4234
  this.log("debug", "Falling back to deprecated HTTP+SSE transport...");
4242
4235
  try {
4243
- const sseTransport = new sse_js.SSEClientTransport(url, { requestInit, eventSourceInit });
4236
+ const sseTransport = new sse_js$1.SSEClientTransport(url, { requestInit, eventSourceInit });
4244
4237
  await this.client.connect(sseTransport, { timeout: this.serverConfig.timeout ?? this.timeout });
4245
4238
  this.transport = sseTransport;
4246
4239
  this.log("debug", "Successfully connected using deprecated HTTP+SSE transport.");
@@ -4361,7 +4354,14 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends base.Mastra
4361
4354
  return toolsRes;
4362
4355
  }
4363
4356
  };
4364
- var MastraMCPClient = InternalMastraMCPClient;
4357
+ var MastraMCPClient = class extends InternalMastraMCPClient {
4358
+ constructor(args) {
4359
+ super(args);
4360
+ this.logger.warn(
4361
+ "[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead."
4362
+ );
4363
+ }
4364
+ };
4365
4365
  var mcpClientInstances = /* @__PURE__ */ new Map();
4366
4366
  var MCPClient = class extends base.MastraBase {
4367
4367
  serverConfigs = {};
@@ -6453,7 +6453,7 @@ var MCPServer = class {
6453
6453
  * @param opts.tools - Tool definitions to register
6454
6454
  */
6455
6455
  constructor({ name, version, tools }) {
6456
- this.server = new index_js$1.Server({ name, version }, { capabilities: { tools: {}, logging: { enabled: true } } });
6456
+ this.server = new index_js.Server({ name, version }, { capabilities: { tools: {}, logging: { enabled: true } } });
6457
6457
  this.convertedTools = this.convertTools(tools);
6458
6458
  void logger2.info(
6459
6459
  `Initialized MCPServer '${name}' v${version} with tools: ${Object.keys(this.convertedTools).join(", ")}`
@@ -6587,7 +6587,7 @@ var MCPServer = class {
6587
6587
  * Start the MCP server using stdio transport (for Windsurf integration).
6588
6588
  */
6589
6589
  async startStdio() {
6590
- this.stdioTransport = new stdio_js$1.StdioServerTransport();
6590
+ this.stdioTransport = new stdio_js.StdioServerTransport();
6591
6591
  await this.server.connect(this.stdioTransport);
6592
6592
  await logger2.info("Started MCP Server (stdio)");
6593
6593
  }
@@ -6610,7 +6610,7 @@ var MCPServer = class {
6610
6610
  }) {
6611
6611
  if (url.pathname === ssePath) {
6612
6612
  await logger2.debug("Received SSE connection");
6613
- this.sseTransport = new sse_js$1.SSEServerTransport(messagePath, res);
6613
+ this.sseTransport = new sse_js.SSEServerTransport(messagePath, res);
6614
6614
  await this.server.connect(this.sseTransport);
6615
6615
  this.server.onclose = async () => {
6616
6616
  await this.server.close();
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
6
6
  import { StdioClientTransport, getDefaultEnvironment } from '@modelcontextprotocol/sdk/client/stdio.js';
7
7
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
8
8
  import { DEFAULT_REQUEST_TIMEOUT_MSEC } from '@modelcontextprotocol/sdk/shared/protocol.js';
9
- import { ListResourcesResultSchema, CallToolResultSchema, ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
9
+ import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesResultSchema, CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js';
10
10
  import { asyncExitHook, gracefulExit } from 'exit-hook';
11
11
  import equal from 'fast-deep-equal';
12
12
  import { v5 } from 'uuid';
@@ -4095,13 +4095,12 @@ function convertLogLevelToLoggerMethod(level) {
4095
4095
  return "info";
4096
4096
  }
4097
4097
  }
4098
- var InternalMastraMCPClient = class _InternalMastraMCPClient extends MastraBase {
4098
+ var InternalMastraMCPClient = class extends MastraBase {
4099
4099
  name;
4100
4100
  client;
4101
4101
  timeout;
4102
4102
  logHandler;
4103
4103
  enableServerLogs;
4104
- static hasWarned = false;
4105
4104
  serverConfig;
4106
4105
  transport;
4107
4106
  constructor({
@@ -4112,12 +4111,6 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends MastraBase
4112
4111
  timeout = DEFAULT_REQUEST_TIMEOUT_MSEC
4113
4112
  }) {
4114
4113
  super({ name: "MastraMCPClient" });
4115
- if (!_InternalMastraMCPClient.hasWarned) {
4116
- console.warn(
4117
- "[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead."
4118
- );
4119
- _InternalMastraMCPClient.hasWarned = true;
4120
- }
4121
4114
  this.name = name;
4122
4115
  this.timeout = timeout;
4123
4116
  this.logHandler = server.logger;
@@ -4334,7 +4327,14 @@ var InternalMastraMCPClient = class _InternalMastraMCPClient extends MastraBase
4334
4327
  return toolsRes;
4335
4328
  }
4336
4329
  };
4337
- var MastraMCPClient = InternalMastraMCPClient;
4330
+ var MastraMCPClient = class extends InternalMastraMCPClient {
4331
+ constructor(args) {
4332
+ super(args);
4333
+ this.logger.warn(
4334
+ "[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead."
4335
+ );
4336
+ }
4337
+ };
4338
4338
  var mcpClientInstances = /* @__PURE__ */ new Map();
4339
4339
  var MCPClient = class extends MastraBase {
4340
4340
  serverConfigs = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/mcp",
3
- "version": "0.4.1",
3
+ "version": "0.4.2-alpha.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "exit-hook": "^4.0.0",
28
28
  "fast-deep-equal": "^3.1.3",
29
29
  "uuid": "^11.1.0",
30
- "@mastra/core": "^0.9.1"
30
+ "@mastra/core": "^0.9.2-alpha.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@ai-sdk/anthropic": "^1.1.15",
package/src/client.ts CHANGED
@@ -89,13 +89,20 @@ function convertLogLevelToLoggerMethod(level: LoggingLevel): 'debug' | 'info' |
89
89
  }
90
90
  }
91
91
 
92
+ export type InternalMastraMCPClientOptions = {
93
+ name: string;
94
+ server: MastraMCPServerDefinition;
95
+ capabilities?: ClientCapabilities;
96
+ version?: string;
97
+ timeout?: number;
98
+ };
99
+
92
100
  export class InternalMastraMCPClient extends MastraBase {
93
101
  name: string;
94
102
  private client: Client;
95
103
  private readonly timeout: number;
96
104
  private logHandler?: LogHandler;
97
105
  private enableServerLogs?: boolean;
98
- private static hasWarned = false;
99
106
  private serverConfig: MastraMCPServerDefinition;
100
107
  private transport?: Transport;
101
108
 
@@ -105,21 +112,8 @@ export class InternalMastraMCPClient extends MastraBase {
105
112
  server,
106
113
  capabilities = {},
107
114
  timeout = DEFAULT_REQUEST_TIMEOUT_MSEC,
108
- }: {
109
- name: string;
110
- server: MastraMCPServerDefinition;
111
- capabilities?: ClientCapabilities;
112
- version?: string;
113
- timeout?: number;
114
- }) {
115
+ }: InternalMastraMCPClientOptions) {
115
116
  super({ name: 'MastraMCPClient' });
116
- if (!InternalMastraMCPClient.hasWarned) {
117
- // eslint-disable-next-line no-console
118
- console.warn(
119
- '[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead.',
120
- );
121
- InternalMastraMCPClient.hasWarned = true;
122
- }
123
117
  this.name = name;
124
118
  this.timeout = timeout;
125
119
  this.logHandler = server.logger;
@@ -374,4 +368,12 @@ export class InternalMastraMCPClient extends MastraBase {
374
368
  /**
375
369
  * @deprecated MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead.
376
370
  */
377
- export const MastraMCPClient = InternalMastraMCPClient;
371
+
372
+ export class MastraMCPClient extends InternalMastraMCPClient {
373
+ constructor(args: InternalMastraMCPClientOptions) {
374
+ super(args);
375
+ this.logger.warn(
376
+ '[DEPRECATION] MastraMCPClient is deprecated and will be removed in a future release. Please use MCPClient instead.',
377
+ );
378
+ }
379
+ }