@mastra/mcp 0.4.0-alpha.8 → 0.4.0-alpha.9

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.0-alpha.8 build /home/runner/work/mastra/mastra/packages/mcp
2
+ > @mastra/mcp@0.4.0-alpha.9 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 14746ms
9
+ TSC ⚡️ Build success in 14236ms
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 10120ms
16
+ DTS ⚡️ Build success in 13685ms
17
17
  CLI Cleaning output folder
18
18
  ESM Build start
19
19
  CJS Build start
20
- CJS dist/index.cjs 129.12 KB
21
- CJS ⚡️ Build success in 3335ms
22
- ESM dist/index.js 129.07 KB
23
- ESM ⚡️ Build success in 3335ms
20
+ ESM dist/index.js 199.82 KB
21
+ ESM ⚡️ Build success in 3988ms
22
+ CJS dist/index.cjs 200.48 KB
23
+ CJS ⚡️ Build success in 3974ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @mastra/mcp
2
2
 
3
+ ## 0.4.0-alpha.9
4
+
5
+ ### Patch Changes
6
+
7
+ - 0a033fa: Adds MCPServer component
8
+ - Updated dependencies [000a6d4]
9
+ - Updated dependencies [ed2f549]
10
+ - Updated dependencies [c0f22b4]
11
+ - Updated dependencies [0a033fa]
12
+ - Updated dependencies [9c26508]
13
+ - Updated dependencies [0f4eae3]
14
+ - Updated dependencies [16a8648]
15
+ - @mastra/core@0.9.0-alpha.8
16
+
3
17
  ## 0.4.0-alpha.8
4
18
 
5
19
  ### Patch Changes
@@ -4,7 +4,32 @@ import { MastraBase } from '@mastra/core/base';
4
4
  import type { Protocol } from '@modelcontextprotocol/sdk/shared/protocol.js';
5
5
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
6
  import type { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
7
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
7
8
  import type { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
9
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
10
+ import { Tool } from '@mastra/core/tools';
11
+ import { ToolExecutionContext } from '@mastra/core';
12
+ import type { ToolsInput } from '@mastra/core/agent';
13
+ import { z } from 'zod';
14
+
15
+ declare type ConvertedTool = {
16
+ name: string;
17
+ description?: string;
18
+ inputSchema: any;
19
+ zodSchema: z.ZodTypeAny;
20
+ execute: any;
21
+ };
22
+
23
+ export declare function createLogger(server?: Server): Logger;
24
+
25
+ export declare interface Logger {
26
+ info: (message: string, data?: any) => Promise<void>;
27
+ warning: (message: string, data?: any) => Promise<void>;
28
+ error: (message: string, error?: any) => Promise<void>;
29
+ debug: (message: string, data?: any) => Promise<void>;
30
+ }
31
+
32
+ export declare const logger: Logger;
8
33
 
9
34
  export { LoggingLevel }
10
35
  export { LoggingLevel as LoggingLevel_alias_1 }
@@ -88,6 +113,73 @@ declare interface MCPConfigurationOptions {
88
113
  export { MCPConfigurationOptions }
89
114
  export { MCPConfigurationOptions as MCPConfigurationOptions_alias_1 }
90
115
 
116
+ declare class MCPServer {
117
+ private server;
118
+ private convertedTools;
119
+ private stdioTransport?;
120
+ private sseTransport?;
121
+ /**
122
+ * Get the current stdio transport.
123
+ */
124
+ getStdioTransport(): StdioServerTransport | undefined;
125
+ /**
126
+ * Get the current SSE transport.
127
+ */
128
+ getSseTransport(): SSEServerTransport | undefined;
129
+ /**
130
+ * Get a read-only view of the registered tools (for testing/introspection).
131
+ */
132
+ tools(): Readonly<Record<string, ConvertedTool>>;
133
+ /**
134
+ * Construct a new MCPServer instance.
135
+ * @param opts.name - Server name
136
+ * @param opts.version - Server version
137
+ * @param opts.tools - Tool definitions to register
138
+ */
139
+ constructor({ name, version, tools }: {
140
+ name: string;
141
+ version: string;
142
+ tools: ToolsInput;
143
+ });
144
+ /**
145
+ * Convert and validate all provided tools, logging registration status.
146
+ * @param tools Tool definitions
147
+ * @returns Converted tools registry
148
+ */
149
+ private convertTools;
150
+ /**
151
+ * Register the ListTools handler for listing all available tools.
152
+ */
153
+ private registerListToolsHandler;
154
+ /**
155
+ * Register the CallTool handler for executing a tool by name.
156
+ */
157
+ private registerCallToolHandler;
158
+ /**
159
+ * Start the MCP server using stdio transport (for Windsurf integration).
160
+ */
161
+ startStdio(): Promise<void>;
162
+ /**
163
+ * Handles MCP-over-SSE protocol for user-provided HTTP servers.
164
+ * Call this from your HTTP server for both the SSE and message endpoints.
165
+ *
166
+ * @param url Parsed URL of the incoming request
167
+ * @param ssePath Path for establishing the SSE connection (e.g. '/sse')
168
+ * @param messagePath Path for POSTing client messages (e.g. '/message')
169
+ * @param req Incoming HTTP request
170
+ * @param res HTTP response (must support .write/.end)
171
+ */
172
+ startSSE({ url, ssePath, messagePath, req, res, }: {
173
+ url: URL;
174
+ ssePath: string;
175
+ messagePath: string;
176
+ req: any;
177
+ res: any;
178
+ }): Promise<void>;
179
+ }
180
+ export { MCPServer }
181
+ export { MCPServer as MCPServer_alias_1 }
182
+
91
183
  export declare const server: Server<{
92
184
  method: string;
93
185
  params?: {
@@ -140,4 +232,44 @@ declare type SSEClientParameters = {
140
232
  url: URL;
141
233
  } & SSEClientTransportOptions;
142
234
 
235
+ export declare const weatherTool: Tool<z.ZodObject<{
236
+ location: z.ZodString;
237
+ }, "strip", z.ZodTypeAny, {
238
+ location: string;
239
+ }, {
240
+ location: string;
241
+ }>, z.ZodObject<{
242
+ temperature: z.ZodNumber;
243
+ feelsLike: z.ZodNumber;
244
+ humidity: z.ZodNumber;
245
+ windSpeed: z.ZodNumber;
246
+ windGust: z.ZodNumber;
247
+ conditions: z.ZodString;
248
+ location: z.ZodString;
249
+ }, "strip", z.ZodTypeAny, {
250
+ location: string;
251
+ temperature: number;
252
+ feelsLike: number;
253
+ humidity: number;
254
+ windSpeed: number;
255
+ windGust: number;
256
+ conditions: string;
257
+ }, {
258
+ location: string;
259
+ temperature: number;
260
+ feelsLike: number;
261
+ humidity: number;
262
+ windSpeed: number;
263
+ windGust: number;
264
+ conditions: string;
265
+ }>, ToolExecutionContext<z.ZodObject<{
266
+ location: z.ZodString;
267
+ }, "strip", z.ZodTypeAny, {
268
+ location: string;
269
+ }, {
270
+ location: string;
271
+ }>>>;
272
+
273
+ export declare const writeErrorLog: (message: string, data?: any) => void;
274
+
143
275
  export { }
@@ -4,7 +4,32 @@ import { MastraBase } from '@mastra/core/base';
4
4
  import type { Protocol } from '@modelcontextprotocol/sdk/shared/protocol.js';
5
5
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
6
  import type { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
7
+ import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
7
8
  import type { StdioServerParameters } from '@modelcontextprotocol/sdk/client/stdio.js';
9
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
10
+ import { Tool } from '@mastra/core/tools';
11
+ import { ToolExecutionContext } from '@mastra/core';
12
+ import type { ToolsInput } from '@mastra/core/agent';
13
+ import { z } from 'zod';
14
+
15
+ declare type ConvertedTool = {
16
+ name: string;
17
+ description?: string;
18
+ inputSchema: any;
19
+ zodSchema: z.ZodTypeAny;
20
+ execute: any;
21
+ };
22
+
23
+ export declare function createLogger(server?: Server): Logger;
24
+
25
+ export declare interface Logger {
26
+ info: (message: string, data?: any) => Promise<void>;
27
+ warning: (message: string, data?: any) => Promise<void>;
28
+ error: (message: string, error?: any) => Promise<void>;
29
+ debug: (message: string, data?: any) => Promise<void>;
30
+ }
31
+
32
+ export declare const logger: Logger;
8
33
 
9
34
  export { LoggingLevel }
10
35
  export { LoggingLevel as LoggingLevel_alias_1 }
@@ -88,6 +113,73 @@ declare interface MCPConfigurationOptions {
88
113
  export { MCPConfigurationOptions }
89
114
  export { MCPConfigurationOptions as MCPConfigurationOptions_alias_1 }
90
115
 
116
+ declare class MCPServer {
117
+ private server;
118
+ private convertedTools;
119
+ private stdioTransport?;
120
+ private sseTransport?;
121
+ /**
122
+ * Get the current stdio transport.
123
+ */
124
+ getStdioTransport(): StdioServerTransport | undefined;
125
+ /**
126
+ * Get the current SSE transport.
127
+ */
128
+ getSseTransport(): SSEServerTransport | undefined;
129
+ /**
130
+ * Get a read-only view of the registered tools (for testing/introspection).
131
+ */
132
+ tools(): Readonly<Record<string, ConvertedTool>>;
133
+ /**
134
+ * Construct a new MCPServer instance.
135
+ * @param opts.name - Server name
136
+ * @param opts.version - Server version
137
+ * @param opts.tools - Tool definitions to register
138
+ */
139
+ constructor({ name, version, tools }: {
140
+ name: string;
141
+ version: string;
142
+ tools: ToolsInput;
143
+ });
144
+ /**
145
+ * Convert and validate all provided tools, logging registration status.
146
+ * @param tools Tool definitions
147
+ * @returns Converted tools registry
148
+ */
149
+ private convertTools;
150
+ /**
151
+ * Register the ListTools handler for listing all available tools.
152
+ */
153
+ private registerListToolsHandler;
154
+ /**
155
+ * Register the CallTool handler for executing a tool by name.
156
+ */
157
+ private registerCallToolHandler;
158
+ /**
159
+ * Start the MCP server using stdio transport (for Windsurf integration).
160
+ */
161
+ startStdio(): Promise<void>;
162
+ /**
163
+ * Handles MCP-over-SSE protocol for user-provided HTTP servers.
164
+ * Call this from your HTTP server for both the SSE and message endpoints.
165
+ *
166
+ * @param url Parsed URL of the incoming request
167
+ * @param ssePath Path for establishing the SSE connection (e.g. '/sse')
168
+ * @param messagePath Path for POSTing client messages (e.g. '/message')
169
+ * @param req Incoming HTTP request
170
+ * @param res HTTP response (must support .write/.end)
171
+ */
172
+ startSSE({ url, ssePath, messagePath, req, res, }: {
173
+ url: URL;
174
+ ssePath: string;
175
+ messagePath: string;
176
+ req: any;
177
+ res: any;
178
+ }): Promise<void>;
179
+ }
180
+ export { MCPServer }
181
+ export { MCPServer as MCPServer_alias_1 }
182
+
91
183
  export declare const server: Server<{
92
184
  method: string;
93
185
  params?: {
@@ -140,4 +232,44 @@ declare type SSEClientParameters = {
140
232
  url: URL;
141
233
  } & SSEClientTransportOptions;
142
234
 
235
+ export declare const weatherTool: Tool<z.ZodObject<{
236
+ location: z.ZodString;
237
+ }, "strip", z.ZodTypeAny, {
238
+ location: string;
239
+ }, {
240
+ location: string;
241
+ }>, z.ZodObject<{
242
+ temperature: z.ZodNumber;
243
+ feelsLike: z.ZodNumber;
244
+ humidity: z.ZodNumber;
245
+ windSpeed: z.ZodNumber;
246
+ windGust: z.ZodNumber;
247
+ conditions: z.ZodString;
248
+ location: z.ZodString;
249
+ }, "strip", z.ZodTypeAny, {
250
+ location: string;
251
+ temperature: number;
252
+ feelsLike: number;
253
+ humidity: number;
254
+ windSpeed: number;
255
+ windGust: number;
256
+ conditions: string;
257
+ }, {
258
+ location: string;
259
+ temperature: number;
260
+ feelsLike: number;
261
+ humidity: number;
262
+ windSpeed: number;
263
+ windGust: number;
264
+ conditions: string;
265
+ }>, ToolExecutionContext<z.ZodObject<{
266
+ location: z.ZodString;
267
+ }, "strip", z.ZodTypeAny, {
268
+ location: string;
269
+ }, {
270
+ location: string;
271
+ }>>>;
272
+
273
+ export declare const writeErrorLog: (message: string, data?: any) => void;
274
+
143
275
  export { }