@mastra/mcp 0.10.10-alpha.0 → 0.10.10
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +30 -0
- package/README.md +38 -1
- package/dist/client/client.d.ts +2 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/integration-tests/node_modules/.bin/mastra +21 -0
- package/package.json +5 -5
- package/src/client/client.test.ts +66 -0
- package/src/client/client.ts +5 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/mastra/mastra/packages/cli/dist/node_modules:/home/runner/work/mastra/mastra/packages/cli/node_modules:/home/runner/work/mastra/mastra/packages/node_modules:/home/runner/work/mastra/mastra/node_modules:/home/runner/work/mastra/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/mastra/mastra/packages/cli/dist/node_modules:/home/runner/work/mastra/mastra/packages/cli/node_modules:/home/runner/work/mastra/mastra/packages/node_modules:/home/runner/work/mastra/mastra/node_modules:/home/runner/work/mastra/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../mastra/dist/index.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../mastra/dist/index.js" "$@"
|
|
21
|
+
fi
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp",
|
|
3
|
-
"version": "0.10.10
|
|
3
|
+
"version": "0.10.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"ai": "4.3.16",
|
|
45
45
|
"eslint": "^9.30.1",
|
|
46
46
|
"hono-mcp-server-sse-transport": "0.0.7",
|
|
47
|
-
"hono": "^4.8.
|
|
47
|
+
"hono": "^4.8.12",
|
|
48
48
|
"tsup": "^8.5.0",
|
|
49
49
|
"tsx": "^4.19.4",
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
52
|
"zod": "^3.25.67",
|
|
53
53
|
"zod-to-json-schema": "^3.24.5",
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@internal/lint": "0.0.
|
|
54
|
+
"@internal/types-builder": "0.0.2",
|
|
55
|
+
"@mastra/core": "0.13.0",
|
|
56
|
+
"@internal/lint": "0.0.27"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup --silent --config tsup.config.ts",
|
|
@@ -517,3 +517,69 @@ describe('MastraMCPClient - Elicitation Tests', () => {
|
|
|
517
517
|
expect(elicitationResultText).toContain('Elicitation response content does not match requested schema');
|
|
518
518
|
});
|
|
519
519
|
});
|
|
520
|
+
|
|
521
|
+
describe('MastraMCPClient - AuthProvider Tests', () => {
|
|
522
|
+
let testServer: {
|
|
523
|
+
httpServer: HttpServer;
|
|
524
|
+
mcpServer: McpServer;
|
|
525
|
+
serverTransport: StreamableHTTPServerTransport;
|
|
526
|
+
baseUrl: URL;
|
|
527
|
+
};
|
|
528
|
+
let client: InternalMastraMCPClient;
|
|
529
|
+
|
|
530
|
+
beforeEach(async () => {
|
|
531
|
+
testServer = await setupTestServer(false);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
afterEach(async () => {
|
|
535
|
+
await client?.disconnect().catch(() => {});
|
|
536
|
+
await testServer?.mcpServer.close().catch(() => {});
|
|
537
|
+
await testServer?.serverTransport.close().catch(() => {});
|
|
538
|
+
testServer?.httpServer.close();
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
it('should accept authProvider field in HTTP server configuration', async () => {
|
|
542
|
+
const mockAuthProvider = { test: 'authProvider' } as any;
|
|
543
|
+
|
|
544
|
+
client = new InternalMastraMCPClient({
|
|
545
|
+
name: 'auth-config-test',
|
|
546
|
+
server: {
|
|
547
|
+
url: testServer.baseUrl,
|
|
548
|
+
authProvider: mockAuthProvider,
|
|
549
|
+
},
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
const serverConfig = (client as any).serverConfig;
|
|
553
|
+
expect(serverConfig.authProvider).toBe(mockAuthProvider);
|
|
554
|
+
expect(client).toBeDefined();
|
|
555
|
+
expect(typeof client).toBe('object');
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
it('should handle undefined authProvider gracefully', async () => {
|
|
559
|
+
client = new InternalMastraMCPClient({
|
|
560
|
+
name: 'auth-undefined-test',
|
|
561
|
+
server: {
|
|
562
|
+
url: testServer.baseUrl,
|
|
563
|
+
authProvider: undefined,
|
|
564
|
+
},
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
await client.connect();
|
|
568
|
+
const tools = await client.tools();
|
|
569
|
+
expect(tools).toHaveProperty('greet');
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
it('should work without authProvider for HTTP transport (backward compatibility)', async () => {
|
|
573
|
+
client = new InternalMastraMCPClient({
|
|
574
|
+
name: 'no-auth-http-client',
|
|
575
|
+
server: {
|
|
576
|
+
url: testServer.baseUrl,
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
await client.connect();
|
|
581
|
+
const tools = await client.tools();
|
|
582
|
+
expect(tools).toHaveProperty('greet');
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
});
|
package/src/client/client.ts
CHANGED
|
@@ -74,6 +74,7 @@ type StdioServerDefinition = BaseServerOptions & {
|
|
|
74
74
|
url?: never; // Exclude 'url' for Stdio
|
|
75
75
|
requestInit?: never; // Exclude HTTP options for Stdio
|
|
76
76
|
eventSourceInit?: never; // Exclude HTTP options for Stdio
|
|
77
|
+
authProvider?: never; // Exclude HTTP options for Stdio
|
|
77
78
|
reconnectionOptions?: never; // Exclude Streamable HTTP specific options
|
|
78
79
|
sessionId?: never; // Exclude Streamable HTTP specific options
|
|
79
80
|
};
|
|
@@ -89,6 +90,7 @@ type HttpServerDefinition = BaseServerOptions & {
|
|
|
89
90
|
// Include relevant options from SDK HTTP transport types
|
|
90
91
|
requestInit?: StreamableHTTPClientTransportOptions['requestInit'];
|
|
91
92
|
eventSourceInit?: SSEClientTransportOptions['eventSourceInit'];
|
|
93
|
+
authProvider?: StreamableHTTPClientTransportOptions['authProvider'];
|
|
92
94
|
reconnectionOptions?: StreamableHTTPClientTransportOptions['reconnectionOptions'];
|
|
93
95
|
sessionId?: StreamableHTTPClientTransportOptions['sessionId'];
|
|
94
96
|
};
|
|
@@ -237,7 +239,7 @@ export class InternalMastraMCPClient extends MastraBase {
|
|
|
237
239
|
}
|
|
238
240
|
|
|
239
241
|
private async connectHttp(url: URL) {
|
|
240
|
-
const { requestInit, eventSourceInit } = this.serverConfig;
|
|
242
|
+
const { requestInit, eventSourceInit, authProvider } = this.serverConfig;
|
|
241
243
|
|
|
242
244
|
this.log('debug', `Attempting to connect to URL: ${url}`);
|
|
243
245
|
|
|
@@ -251,6 +253,7 @@ export class InternalMastraMCPClient extends MastraBase {
|
|
|
251
253
|
const streamableTransport = new StreamableHTTPClientTransport(url, {
|
|
252
254
|
requestInit,
|
|
253
255
|
reconnectionOptions: this.serverConfig.reconnectionOptions,
|
|
256
|
+
authProvider: authProvider,
|
|
254
257
|
});
|
|
255
258
|
await this.client.connect(streamableTransport, {
|
|
256
259
|
timeout:
|
|
@@ -269,7 +272,7 @@ export class InternalMastraMCPClient extends MastraBase {
|
|
|
269
272
|
this.log('debug', 'Falling back to deprecated HTTP+SSE transport...');
|
|
270
273
|
try {
|
|
271
274
|
// Fallback to SSE transport
|
|
272
|
-
const sseTransport = new SSEClientTransport(url, { requestInit, eventSourceInit });
|
|
275
|
+
const sseTransport = new SSEClientTransport(url, { requestInit, eventSourceInit, authProvider });
|
|
273
276
|
await this.client.connect(sseTransport, { timeout: this.serverConfig.timeout ?? this.timeout });
|
|
274
277
|
this.transport = sseTransport;
|
|
275
278
|
this.log('debug', 'Successfully connected using deprecated HTTP+SSE transport.');
|