@mastra/mcp 0.10.9 → 0.10.10-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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +21 -0
- package/README.md +38 -1
- package/dist/__fixtures__/weather.d.ts +1 -1
- package/dist/client/client.d.ts +5 -3
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/elicitationActions.d.ts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/promptActions.d.ts +3 -3
- package/dist/client/resourceActions.d.ts +3 -3
- package/dist/index.cjs +8 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/server.d.ts +3 -3
- package/integration-tests/package.json +1 -1
- package/package.json +8 -7
- package/src/client/client.test.ts +66 -0
- package/src/client/client.ts +5 -2
- package/tsup.config.ts +2 -7
- package/integration-tests/node_modules/.bin/mastra +0 -21
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 0.10.10-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e792ef: Expose authProvider option for HTTP-based MCP servers to enable OAuth authentication with automatic token refresh. The authProvider is automatically passed to both Streamable HTTP and SSE transports.
|
|
8
|
+
- Updated dependencies [d0496e6]
|
|
9
|
+
- @mastra/core@0.13.0-alpha.3
|
|
10
|
+
|
|
11
|
+
## 0.10.10-alpha.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
|
|
16
|
+
- Updated dependencies [cb36de0]
|
|
17
|
+
- Updated dependencies [a82b851]
|
|
18
|
+
- Updated dependencies [41a0a0e]
|
|
19
|
+
- Updated dependencies [2871020]
|
|
20
|
+
- Updated dependencies [4a406ec]
|
|
21
|
+
- Updated dependencies [5d377e5]
|
|
22
|
+
- @mastra/core@0.13.0-alpha.2
|
|
23
|
+
|
|
3
24
|
## 0.10.9
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -378,7 +378,41 @@ mcp.prompts.onListChanged({
|
|
|
378
378
|
|
|
379
379
|
Prompt notifications are delivered via SSE or compatible transports. Register handlers before expecting notifications.
|
|
380
380
|
|
|
381
|
-
##
|
|
381
|
+
## Authentication
|
|
382
|
+
|
|
383
|
+
### OAuth Token Refresh with AuthProvider
|
|
384
|
+
|
|
385
|
+
For HTTP-based MCP servers that require OAuth authentication with automatic token refresh, you can use the `authProvider` option:
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
const httpClient = new MCPClient({
|
|
389
|
+
servers: {
|
|
390
|
+
myOAuthClient: {
|
|
391
|
+
url: new URL('https://your-mcp-server.com/mcp'),
|
|
392
|
+
authProvider: {
|
|
393
|
+
tokens: async () => {
|
|
394
|
+
// Your token refresh logic here
|
|
395
|
+
const refreshedToken = await refreshAccessToken();
|
|
396
|
+
return {
|
|
397
|
+
token: refreshedToken,
|
|
398
|
+
type: 'Bearer',
|
|
399
|
+
};
|
|
400
|
+
},
|
|
401
|
+
// Additional OAuth provider methods as needed
|
|
402
|
+
redirectUrl: 'https://your-app.com/oauth/callback',
|
|
403
|
+
clientMetadata: {
|
|
404
|
+
/* ... */
|
|
405
|
+
},
|
|
406
|
+
// ... other OAuth provider properties
|
|
407
|
+
},
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
The `authProvider` is automatically passed to both Streamable HTTP and SSE transports.
|
|
414
|
+
|
|
415
|
+
### SSE Authentication and Headers (Legacy Fallback)
|
|
382
416
|
|
|
383
417
|
When the client falls back to using the legacy SSE (Server-Sent Events) transport and you need to include authentication or custom headers, you need to configure headers in a specific way. The standard `requestInit` headers won't work alone because SSE connections using the browser's `EventSource` API don't support custom headers directly.
|
|
384
418
|
|
|
@@ -456,6 +490,7 @@ Here are the available options within `MastraMCPServerDefinition`:
|
|
|
456
490
|
- **`url`**: (Optional, URL) For HTTP servers (Streamable HTTP or SSE): The URL of the server.
|
|
457
491
|
- **`requestInit`**: (Optional, RequestInit) For HTTP servers: Request configuration for the fetch API. Used for the initial Streamable HTTP connection attempt and subsequent POST requests. Also used for the initial SSE connection attempt.
|
|
458
492
|
- **`eventSourceInit`**: (Optional, EventSourceInit) **Only** for the legacy SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE.
|
|
493
|
+
- **`authProvider`**: (Optional, OAuthClientProvider) For HTTP servers: OAuth authentication provider for automatic token refresh. Automatically passed to both Streamable HTTP and SSE transports.
|
|
459
494
|
- **`logger`**: (Optional, LogHandler) Optional additional handler for logging.
|
|
460
495
|
- **`timeout`**: (Optional, number) Server-specific timeout in milliseconds, overriding the global client/configuration timeout.
|
|
461
496
|
- **`capabilities`**: (Optional, ClientCapabilities) Server-specific capabilities configuration.
|
|
@@ -469,6 +504,8 @@ Here are the available options within `MastraMCPServerDefinition`:
|
|
|
469
504
|
- Multiple transport layers with automatic detection:
|
|
470
505
|
- Stdio-based for local servers (`command`)
|
|
471
506
|
- HTTP-based for remote servers (`url`): Tries Streamable HTTP first, falls back to legacy SSE.
|
|
507
|
+
- OAuth authentication with automatic token refresh (`authProvider`)
|
|
508
|
+
- Manual authentication headers for static tokens (`requestInit`, `eventSourceInit`)
|
|
472
509
|
- Per-server logging capability using all standard MCP log levels
|
|
473
510
|
- Automatic error handling and logging
|
|
474
511
|
- Tool execution with context
|
package/dist/client/client.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol
|
|
|
5
5
|
import type { ClientCapabilities, ElicitRequest, ElicitResult, GetPromptResult, ListPromptsResult, LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { ResourceUpdatedNotificationSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import { ElicitationClientActions } from './elicitationActions';
|
|
9
|
-
import { PromptClientActions } from './promptActions';
|
|
10
|
-
import { ResourceClientActions } from './resourceActions';
|
|
8
|
+
import { ElicitationClientActions } from './elicitationActions.js';
|
|
9
|
+
import { PromptClientActions } from './promptActions.js';
|
|
10
|
+
import { ResourceClientActions } from './resourceActions.js';
|
|
11
11
|
export type { LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
|
|
12
12
|
export interface LogMessage {
|
|
13
13
|
level: LoggingLevel;
|
|
@@ -32,6 +32,7 @@ type StdioServerDefinition = BaseServerOptions & {
|
|
|
32
32
|
url?: never;
|
|
33
33
|
requestInit?: never;
|
|
34
34
|
eventSourceInit?: never;
|
|
35
|
+
authProvider?: never;
|
|
35
36
|
reconnectionOptions?: never;
|
|
36
37
|
sessionId?: never;
|
|
37
38
|
};
|
|
@@ -42,6 +43,7 @@ type HttpServerDefinition = BaseServerOptions & {
|
|
|
42
43
|
env?: never;
|
|
43
44
|
requestInit?: StreamableHTTPClientTransportOptions['requestInit'];
|
|
44
45
|
eventSourceInit?: SSEClientTransportOptions['eventSourceInit'];
|
|
46
|
+
authProvider?: StreamableHTTPClientTransportOptions['authProvider'];
|
|
45
47
|
reconnectionOptions?: StreamableHTTPClientTransportOptions['reconnectionOptions'];
|
|
46
48
|
sessionId?: StreamableHTTPClientTransportOptions['sessionId'];
|
|
47
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMt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AI,MAAM,GAAG,SAAS,CAKlC;IAEK,UAAU;IAoBV,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOb,YAAY,CAAC,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOxB,iBAAiB,CAAC,GAAG,EAAE,MAAM;IAO7B,mBAAmB,CAAC,GAAG,EAAE,MAAM;IAO/B,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO3B;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAO/C;;;;;OAKG;IACG,SAAS,CAAC,EACd,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;IAS5B;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE,qCAAqC,CACnC,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC,QAAQ,CAAC,KAAK,IAAI,GACrF,IAAI;IAOP,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;YAQjD,kBAAkB;YAoClB,mBAAmB;IAqC3B,KAAK;CAwDZ;AAED;;GAEG;AAEH,qBAAa,eAAgB,SAAQ,uBAAuB;gBAC9C,IAAI,EAAE,8BAA8B;CAMjD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MastraBase } from '@mastra/core/base';
|
|
2
2
|
import type { ElicitRequest, ElicitResult, Prompt, Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import type { MastraMCPServerDefinition } from './client';
|
|
3
|
+
import type { MastraMCPServerDefinition } from './client.js';
|
|
4
4
|
export interface MCPClientOptions {
|
|
5
5
|
id?: string;
|
|
6
6
|
servers: Record<string, MastraMCPServerDefinition>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IMastraLogger } from
|
|
2
|
-
import type { ElicitRequest, ElicitResult } from
|
|
3
|
-
import type { InternalMastraMCPClient } from
|
|
1
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
+
import type { ElicitRequest, ElicitResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { InternalMastraMCPClient } from './client.js';
|
|
4
4
|
interface ElicitationClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler } from './client';
|
|
2
|
-
export { MastraMCPClient } from './client';
|
|
3
|
-
export * from './configuration';
|
|
1
|
+
export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, ElicitationHandler } from './client.js';
|
|
2
|
+
export { MastraMCPClient } from './client.js';
|
|
3
|
+
export * from './configuration.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IMastraLogger } from
|
|
2
|
-
import type { GetPromptResult, Prompt } from
|
|
3
|
-
import type { InternalMastraMCPClient } from
|
|
1
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
+
import type { GetPromptResult, Prompt } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { InternalMastraMCPClient } from './client.js';
|
|
4
4
|
interface PromptClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IMastraLogger } from
|
|
2
|
-
import type { Resource, ResourceTemplate } from
|
|
3
|
-
import type { InternalMastraMCPClient } from
|
|
1
|
+
import type { IMastraLogger } from '@mastra/core/logger';
|
|
2
|
+
import type { Resource, ResourceTemplate } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { InternalMastraMCPClient } from './client.js';
|
|
4
4
|
interface ResourceClientActionsConfig {
|
|
5
5
|
client: InternalMastraMCPClient;
|
|
6
6
|
logger: IMastraLogger;
|
package/dist/index.cjs
CHANGED
|
@@ -312,7 +312,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
314
|
async connectHttp(url) {
|
|
315
|
-
const { requestInit, eventSourceInit } = this.serverConfig;
|
|
315
|
+
const { requestInit, eventSourceInit, authProvider } = this.serverConfig;
|
|
316
316
|
this.log("debug", `Attempting to connect to URL: ${url}`);
|
|
317
317
|
let shouldTrySSE = url.pathname.endsWith(`/sse`);
|
|
318
318
|
if (!shouldTrySSE) {
|
|
@@ -320,7 +320,8 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
320
320
|
this.log("debug", "Trying Streamable HTTP transport...");
|
|
321
321
|
const streamableTransport = new streamableHttp_js$1.StreamableHTTPClientTransport(url, {
|
|
322
322
|
requestInit,
|
|
323
|
-
reconnectionOptions: this.serverConfig.reconnectionOptions
|
|
323
|
+
reconnectionOptions: this.serverConfig.reconnectionOptions,
|
|
324
|
+
authProvider
|
|
324
325
|
});
|
|
325
326
|
await this.client.connect(streamableTransport, {
|
|
326
327
|
timeout: (
|
|
@@ -338,7 +339,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
338
339
|
if (shouldTrySSE) {
|
|
339
340
|
this.log("debug", "Falling back to deprecated HTTP+SSE transport...");
|
|
340
341
|
try {
|
|
341
|
-
const sseTransport = new sse_js$1.SSEClientTransport(url, { requestInit, eventSourceInit });
|
|
342
|
+
const sseTransport = new sse_js$1.SSEClientTransport(url, { requestInit, eventSourceInit, authProvider });
|
|
342
343
|
await this.client.connect(sseTransport, { timeout: this.serverConfig.timeout ?? this.timeout });
|
|
343
344
|
this.transport = sseTransport;
|
|
344
345
|
this.log("debug", "Successfully connected using deprecated HTTP+SSE transport.");
|
|
@@ -1022,7 +1023,7 @@ var MCPConfiguration = class extends MCPClient {
|
|
|
1022
1023
|
}
|
|
1023
1024
|
};
|
|
1024
1025
|
|
|
1025
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1026
|
+
// ../../node_modules/.pnpm/hono@4.8.12/node_modules/hono/dist/utils/stream.js
|
|
1026
1027
|
var StreamingApi = class {
|
|
1027
1028
|
writer;
|
|
1028
1029
|
encoder;
|
|
@@ -1089,7 +1090,7 @@ var StreamingApi = class {
|
|
|
1089
1090
|
}
|
|
1090
1091
|
};
|
|
1091
1092
|
|
|
1092
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1093
|
+
// ../../node_modules/.pnpm/hono@4.8.12/node_modules/hono/dist/helper/streaming/utils.js
|
|
1093
1094
|
var isOldBunVersion = () => {
|
|
1094
1095
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
1095
1096
|
if (version === void 0) {
|
|
@@ -1100,7 +1101,7 @@ var isOldBunVersion = () => {
|
|
|
1100
1101
|
return result;
|
|
1101
1102
|
};
|
|
1102
1103
|
|
|
1103
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1104
|
+
// ../../node_modules/.pnpm/hono@4.8.12/node_modules/hono/dist/utils/html.js
|
|
1104
1105
|
var HtmlEscapedCallbackPhase = {
|
|
1105
1106
|
Stringify: 1};
|
|
1106
1107
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -1131,7 +1132,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
1131
1132
|
}
|
|
1132
1133
|
};
|
|
1133
1134
|
|
|
1134
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1135
|
+
// ../../node_modules/.pnpm/hono@4.8.12/node_modules/hono/dist/helper/streaming/sse.js
|
|
1135
1136
|
var SSEStreamingApi = class extends StreamingApi {
|
|
1136
1137
|
constructor(writable, readable) {
|
|
1137
1138
|
super(writable, readable);
|