@mastra/mcp 2.5.0-alpha.1 → 2.5.0-alpha.3

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.
Files changed (95) hide show
  1. package/dist/client/actions/events.d.ts +66 -0
  2. package/dist/client/actions/events.d.ts.map +1 -0
  3. package/dist/client/client.d.ts +63 -1
  4. package/dist/client/client.d.ts.map +1 -1
  5. package/dist/client/configuration.d.ts +49 -0
  6. package/dist/client/configuration.d.ts.map +1 -1
  7. package/dist/client/events/errors.d.ts +13 -0
  8. package/dist/client/events/errors.d.ts.map +1 -0
  9. package/dist/client/events/index.d.ts +3 -0
  10. package/dist/client/events/index.d.ts.map +1 -0
  11. package/dist/client/events/mode.d.ts +58 -0
  12. package/dist/client/events/mode.d.ts.map +1 -0
  13. package/dist/client/events/poll-driver.d.ts +6 -0
  14. package/dist/client/events/poll-driver.d.ts.map +1 -0
  15. package/dist/client/events/push-driver.d.ts +7 -0
  16. package/dist/client/events/push-driver.d.ts.map +1 -0
  17. package/dist/client/events/stream-router.d.ts +42 -0
  18. package/dist/client/events/stream-router.d.ts.map +1 -0
  19. package/dist/client/events/subscription.d.ts +118 -0
  20. package/dist/client/events/subscription.d.ts.map +1 -0
  21. package/dist/client/events/types.d.ts +181 -0
  22. package/dist/client/events/types.d.ts.map +1 -0
  23. package/dist/client/events/webhook-driver.d.ts +10 -0
  24. package/dist/client/events/webhook-driver.d.ts.map +1 -0
  25. package/dist/client/events/webhook-receiver.d.ts +41 -0
  26. package/dist/client/events/webhook-receiver.d.ts.map +1 -0
  27. package/dist/client/index.d.ts +1 -0
  28. package/dist/client/index.d.ts.map +1 -1
  29. package/dist/client/types.d.ts +3 -0
  30. package/dist/client/types.d.ts.map +1 -1
  31. package/dist/docs/SKILL.md +2 -1
  32. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  33. package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +2 -2
  34. package/dist/docs/references/docs-guides-mcp-events.md +306 -0
  35. package/dist/docs/references/reference-tools-mcp-client.md +236 -0
  36. package/dist/docs/references/reference-tools-mcp-server.md +170 -0
  37. package/dist/index.cjs +5242 -11216
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.ts +1 -0
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +5282 -11267
  42. package/dist/index.js.map +1 -1
  43. package/dist/integrations/events-cursor-store.d.ts +25 -0
  44. package/dist/integrations/events-cursor-store.d.ts.map +1 -0
  45. package/dist/integrations/events-signals.d.ts +99 -0
  46. package/dist/integrations/events-signals.d.ts.map +1 -0
  47. package/dist/integrations/events-tools.d.ts +24 -0
  48. package/dist/integrations/events-tools.d.ts.map +1 -0
  49. package/dist/integrations/events-utils.d.ts +18 -0
  50. package/dist/integrations/events-utils.d.ts.map +1 -0
  51. package/dist/integrations/index.d.ts +5 -0
  52. package/dist/integrations/index.d.ts.map +1 -0
  53. package/dist/server/events/actions.d.ts +35 -0
  54. package/dist/server/events/actions.d.ts.map +1 -0
  55. package/dist/server/events/define-event.d.ts +19 -0
  56. package/dist/server/events/define-event.d.ts.map +1 -0
  57. package/dist/server/events/handlers.d.ts +49 -0
  58. package/dist/server/events/handlers.d.ts.map +1 -0
  59. package/dist/server/events/index.d.ts +7 -0
  60. package/dist/server/events/index.d.ts.map +1 -0
  61. package/dist/server/events/inspector.d.ts +14 -0
  62. package/dist/server/events/inspector.d.ts.map +1 -0
  63. package/dist/server/events/registry.d.ts +59 -0
  64. package/dist/server/events/registry.d.ts.map +1 -0
  65. package/dist/server/events/ring-buffer.d.ts +56 -0
  66. package/dist/server/events/ring-buffer.d.ts.map +1 -0
  67. package/dist/server/events/stream.d.ts +56 -0
  68. package/dist/server/events/stream.d.ts.map +1 -0
  69. package/dist/server/events/types.d.ts +203 -0
  70. package/dist/server/events/types.d.ts.map +1 -0
  71. package/dist/server/events/webhook-dispatcher.d.ts +98 -0
  72. package/dist/server/events/webhook-dispatcher.d.ts.map +1 -0
  73. package/dist/server/events/webhook-store.d.ts +60 -0
  74. package/dist/server/events/webhook-store.d.ts.map +1 -0
  75. package/dist/server/events/webhook-transport.d.ts +44 -0
  76. package/dist/server/events/webhook-transport.d.ts.map +1 -0
  77. package/dist/server/index.d.ts +1 -0
  78. package/dist/server/index.d.ts.map +1 -1
  79. package/dist/server/server.d.ts +53 -1
  80. package/dist/server/server.d.ts.map +1 -1
  81. package/dist/shared/events/capability.d.ts +25 -0
  82. package/dist/shared/events/capability.d.ts.map +1 -0
  83. package/dist/shared/events/constants.d.ts +53 -0
  84. package/dist/shared/events/constants.d.ts.map +1 -0
  85. package/dist/shared/events/index.d.ts +7 -0
  86. package/dist/shared/events/index.d.ts.map +1 -0
  87. package/dist/shared/events/schemas.d.ts +356 -0
  88. package/dist/shared/events/schemas.d.ts.map +1 -0
  89. package/dist/shared/events/types.d.ts +37 -0
  90. package/dist/shared/events/types.d.ts.map +1 -0
  91. package/dist/shared/events/webhook-url.d.ts +59 -0
  92. package/dist/shared/events/webhook-url.d.ts.map +1 -0
  93. package/dist/shared/events/webhook.d.ts +60 -0
  94. package/dist/shared/events/webhook.d.ts.map +1 -0
  95. package/package.json +8 -7
@@ -0,0 +1,181 @@
1
+ import type { MastraError } from '@mastra/core/error';
2
+ import type { EventActiveNotificationParams, EventErrorNotificationParams, EventHeartbeatNotificationParams, EventNotificationParams, EventOccurrence, EventTerminatedNotificationParams, PollEventsRequestParams, PollEventsResult, StreamEventsRequestParams, SubscribeEventsRequestParams, SubscribeEventsResult, UnsubscribeEventsRequestParams, WebhookDeliveryStatus } from '../../shared/events/index.js';
3
+ import type { WebhookReceiver } from './webhook-receiver.js';
4
+ /**
5
+ * One event occurrence delivered by an MCP Events subscription.
6
+ *
7
+ * @experimental SEP-3415 is a draft; this API may change.
8
+ */
9
+ export type MCPEventOccurrence = EventOccurrence;
10
+ /**
11
+ * How occurrences reach the client: `poll` repeats `events/poll`; `push` holds one long-lived
12
+ * `events/stream` request open per subscription; `webhook` has the server POST each occurrence to
13
+ * the client's `webhook.url` (registered with `events/subscribe`).
14
+ *
15
+ * @experimental SEP-3415 is a draft; this API may change.
16
+ */
17
+ export type MCPEventDeliveryMode = 'poll' | 'push' | 'webhook';
18
+ /**
19
+ * Webhook delivery settings for `MCPClient`. With these set, event types whose servers offer
20
+ * webhook delivery use it in preference to push and poll.
21
+ *
22
+ * @experimental SEP-3415 is a draft; this API may change.
23
+ */
24
+ export interface MCPClientWebhookOptions {
25
+ /** Public `https` URL that reaches `mcp.events.handleWebhook()`. */
26
+ url: string;
27
+ /**
28
+ * `whsec_` signing secret shared by every subscription. Default: a fresh random secret per
29
+ * subscription, so one server cannot sign deliveries for another server's subscriptions.
30
+ */
31
+ secret?: string;
32
+ /** Suggested subscription lifetime. `null` asks for no expiry. Default: the server's default. */
33
+ ttlMs?: number | null;
34
+ /** How long before `refreshBefore` to refresh. Default: the smaller of 60 seconds and 20% of the grant. */
35
+ refreshMarginMs?: number;
36
+ }
37
+ /** Webhook settings and receiver shared by the subscriptions of one `MCPClient`. */
38
+ export interface EventsWebhookSetup {
39
+ options: MCPClientWebhookOptions;
40
+ receiver: WebhookReceiver;
41
+ }
42
+ /**
43
+ * Error passed to {@link MCPEventSubscription.onError} for recoverable problems, and thrown by
44
+ * the subscription iterator when the subscription ends. Ids:
45
+ *
46
+ * - `MCP_EVENTS_STREAM_ERROR` – the server reported a recoverable error on a push stream (`details.code`).
47
+ * - `MCP_EVENTS_HEARTBEAT_TIMEOUT` – a push stream went silent; the client reopens it.
48
+ * - `MCP_EVENTS_DELIVERY_INTERRUPTED` – a transient failure; the client retries with backoff.
49
+ * - `MCP_EVENTS_SUBSCRIPTION_FAILED` – a non-retryable JSON-RPC error (`details.code`). Ends the subscription.
50
+ * - `MCP_EVENTS_SUBSCRIPTION_TERMINATED` – the server terminated the subscription (`details.code`). Ends it.
51
+ * - `MCP_EVENTS_RETRIES_EXHAUSTED` – `retry.maxAttempts` was reached. Ends the subscription.
52
+ * - `MCP_EVENTS_BUFFER_OVERFLOW` – the consumer fell `maxBufferedEvents` behind and the oldest unread occurrences were dropped; the next one is flagged `truncated`.
53
+ * - `MCP_EVENTS_WEBHOOK_DELIVERY_FAILING` – the server reports that it cannot deliver to the
54
+ * webhook URL (`details.lastError`, `details.active`). Refreshing resumes a suspended subscription.
55
+ * - `MCP_EVENTS_WEBHOOK_UNAVAILABLE` – the server rejected webhook delivery (`details.code`, e.g. an
56
+ * unauthenticated connection or a full webhook subscription cap), so a subscription that did not force a mode fell back to
57
+ * `details.fallback`. Reported once, to the first `onError` handler.
58
+ *
59
+ * @experimental SEP-3415 is a draft; this API may change.
60
+ */
61
+ export type MCPEventSubscriptionError = MastraError;
62
+ /**
63
+ * Retry policy for transient failures. Delays use full jitter:
64
+ * `random(0, min(maxDelayMs, initialDelayMs * factor ** (attempt - 1)))`.
65
+ *
66
+ * @experimental SEP-3415 is a draft; this API may change.
67
+ */
68
+ export interface MCPEventRetryOptions {
69
+ /** Default 1000. */
70
+ initialDelayMs?: number;
71
+ /** Default 30000. */
72
+ maxDelayMs?: number;
73
+ /** Default 2. */
74
+ factor?: number;
75
+ /** Retries allowed after consecutive failures; the next failure ends the subscription. Default unlimited. */
76
+ maxAttempts?: number;
77
+ }
78
+ /**
79
+ * Options for `events.subscribe()`.
80
+ *
81
+ * @experimental SEP-3415 is a draft; this API may change.
82
+ */
83
+ export interface MCPEventSubscribeOptions {
84
+ /**
85
+ * Force a delivery mode. Rejects when the server does not offer it for this event, or for
86
+ * `webhook` when the client has no `webhook` settings. Default: webhook (when configured), then
87
+ * push, then poll.
88
+ */
89
+ delivery?: MCPEventDeliveryMode;
90
+ /** Resume from a cursor you persisted earlier. Default `null` (start from now). */
91
+ cursor?: string | null;
92
+ /** Do not replay occurrences older than this. */
93
+ maxAgeMs?: number;
94
+ /** Upper bound on occurrences per `events/poll` response (poll only). */
95
+ maxEvents?: number;
96
+ /** Floor applied to the server's `nextPollMs`. Default 1000. */
97
+ minPollIntervalMs?: number;
98
+ /** Silence on a push stream after which it is reopened. Default 60000 (twice the 30s heartbeat). */
99
+ heartbeatTimeoutMs?: number;
100
+ /** How long to wait for `notifications/events/active` after opening a push stream. Default: the server's request timeout. */
101
+ streamOpenTimeoutMs?: number;
102
+ /** Number of recent `eventId`s remembered for de-duplication. Default 1000. */
103
+ dedupWindow?: number;
104
+ /**
105
+ * Most occurrences held for a consumer that is not reading. When full, the oldest is dropped,
106
+ * the next occurrence is flagged `truncated`, and `MCP_EVENTS_BUFFER_OVERFLOW` is reported.
107
+ * Default 1000.
108
+ */
109
+ maxBufferedEvents?: number;
110
+ /** Backoff for transient failures. */
111
+ retry?: MCPEventRetryOptions;
112
+ /** Aborting it is the same as calling `cancel()`. */
113
+ signal?: AbortSignal;
114
+ }
115
+ /**
116
+ * A live MCP Events subscription. Iterate it with `for await`; leaving the loop early cancels it.
117
+ *
118
+ * @experimental SEP-3415 is a draft; this API may change.
119
+ */
120
+ export interface MCPEventSubscription extends AsyncIterable<MCPEventOccurrence> {
121
+ /** Event name. */
122
+ readonly name: string;
123
+ /** Subscription arguments sent with every request. */
124
+ readonly arguments: Record<string, unknown> | undefined;
125
+ /** Delivery mode in use. */
126
+ readonly mode: MCPEventDeliveryMode;
127
+ /**
128
+ * Cursor that is safe to persist and pass back as `cursor` to resume: it never moves past an
129
+ * occurrence that has not been yielded yet. A poll batch's cursor applies once the batch's last
130
+ * occurrence has been yielded; heartbeat and confirmation cursors apply once every occurrence
131
+ * buffered before them has been yielded. Persist it after handling each occurrence for
132
+ * at-least-once processing. `null` means the server offers no replay for this subscription;
133
+ * do not persist it.
134
+ */
135
+ readonly cursor: string | null;
136
+ /**
137
+ * Whether the server reported a gap (occurrences were skipped) right before the occurrence just
138
+ * yielded. It turns true when the gap is reported, stays true while the first occurrence after
139
+ * the gap is being handled, and is false again for the occurrences after it.
140
+ */
141
+ readonly truncated: boolean;
142
+ /** Webhook only: the server's latest report on delivery to the webhook URL, from the last refresh. */
143
+ readonly deliveryStatus?: WebhookDeliveryStatus;
144
+ /** Registers a handler for recoverable errors. Returns a function that removes it. */
145
+ onError(handler: (error: MCPEventSubscriptionError) => void): () => void;
146
+ /** Stops delivery and releases the server-side stream. Pending iteration ends with `done`. */
147
+ cancel(): Promise<void>;
148
+ }
149
+ /** Receives the notifications of one push stream. */
150
+ export interface EventStreamSink {
151
+ active(params: EventActiveNotificationParams): void;
152
+ event(params: EventNotificationParams): void;
153
+ heartbeat(params: EventHeartbeatNotificationParams): void;
154
+ error(params: EventErrorNotificationParams): void;
155
+ terminated(params: EventTerminatedNotificationParams): void;
156
+ }
157
+ /** A push stream that has been confirmed with `notifications/events/active`. */
158
+ export interface EventStreamHandle {
159
+ /** Settles when the `events/stream` request ends: resolves on a graceful close, rejects on failure. */
160
+ readonly done: Promise<void>;
161
+ /** Cancels the request and stops routing its notifications. */
162
+ abort(): void;
163
+ }
164
+ /** The narrow surface of the MCP client that subscriptions drive. */
165
+ export interface EventsPort {
166
+ poll(params: PollEventsRequestParams, signal: AbortSignal): Promise<PollEventsResult>;
167
+ openStream(params: StreamEventsRequestParams, sink: EventStreamSink, options: {
168
+ signal: AbortSignal;
169
+ openTimeoutMs: number;
170
+ }): Promise<EventStreamHandle>;
171
+ /** `events/subscribe` (webhook delivery). */
172
+ subscribe(params: SubscribeEventsRequestParams, signal: AbortSignal): Promise<SubscribeEventsResult>;
173
+ /** `events/unsubscribe` (webhook delivery). */
174
+ unsubscribe(params: UnsubscribeEventsRequestParams): Promise<void>;
175
+ /** The webhook settings and receiver, when the client is configured for webhook delivery. */
176
+ webhook(): EventsWebhookSetup | undefined;
177
+ /** Resolves once the client is connected, reconnecting if needed. */
178
+ ensureConnected(): Promise<void>;
179
+ log(level: 'debug' | 'warning' | 'error', message: string, details?: Record<string, unknown>): void;
180
+ }
181
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/events/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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E,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACrG"}
@@ -0,0 +1,10 @@
1
+ import type { DeliveryDriver } from './mode.js';
2
+ /**
3
+ * Webhook delivery: registers the client's webhook URL with `events/subscribe`, routes verified
4
+ * deliveries from the shared receiver into the subscription, and refreshes before the server's
5
+ * `refreshBefore`. Local subscriptions with the same event name and arguments share one server
6
+ * subscription; cancelling the last one unregisters the route and sends a best-effort
7
+ * `events/unsubscribe`.
8
+ */
9
+ export declare const webhookDriver: DeliveryDriver;
10
+ //# sourceMappingURL=webhook-driver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-driver.d.ts","sourceRoot":"","sources":["../../../src/client/events/webhook-driver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,QAAQ,CAAC;AAmO9D;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,cA2C3B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { EventOccurrence, WebhookControlBody } from '../../shared/events/index.js';
2
+ /** A verified webhook body other than the verification handshake. */
3
+ export type WebhookBody = {
4
+ kind: 'event';
5
+ event: EventOccurrence;
6
+ } | {
7
+ kind: 'control';
8
+ control: Exclude<WebhookControlBody, {
9
+ type: 'verification';
10
+ }>;
11
+ };
12
+ /** Where verified deliveries for one subscription go. */
13
+ export interface WebhookRoute {
14
+ secret: string;
15
+ onBody: (body: WebhookBody) => void;
16
+ }
17
+ /**
18
+ * Receives webhook deliveries for every subscription of one `MCPClient` and routes them by
19
+ * `X-MCP-Subscription-Id`. Every body is signature-checked before it is parsed.
20
+ *
21
+ * @internal
22
+ */
23
+ export declare class WebhookReceiver {
24
+ /** Several routes per id only if two servers derive the same id; the verifying secret picks one. */
25
+ private readonly routes;
26
+ /** Secrets of subscribes still in flight, which have no id yet but must answer the handshake. */
27
+ private readonly pendingSecrets;
28
+ /** Accepts verification handshakes signed with `secret` until the returned function is called. */
29
+ expect(secret: string): () => void;
30
+ /** Routes deliveries for subscription `id` signed with `route.secret`. Returns the unregister function. */
31
+ register(id: string, route: WebhookRoute): () => void;
32
+ /**
33
+ * Handles one webhook request: `405` for non-POST, `413` for a body over 1 MiB, `503` for an id not routed yet (the server
34
+ * retries), `401` for a bad or stale signature, `400` for a malformed body, otherwise `200`.
35
+ * Verification handshakes are answered with the echoed challenge.
36
+ */
37
+ handle(request: Request): Promise<Response>;
38
+ }
39
+ /** Largest webhook body read. The route is public, so the body is capped before any check. */
40
+ export declare const MAX_WEBHOOK_BODY_BYTES: number;
41
+ //# sourceMappingURL=webhook-receiver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-receiver.d.ts","sourceRoot":"","sources":["../../../src/client/events/webhook-receiver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,qEAAqE;AACrE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,eAAe,CAAA;CAAE,GACzC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,kBAAkB,EAAE;QAAE,IAAI,EAAE,cAAc,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAExF,yDAAyD;AACzD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACrC;AAQD;;;;;GAKG;AACH,qBAAa,eAAe;IAC1B,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAC5D,iGAAiG;IACjG,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;IAE5D,kGAAkG;IAClG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAUjC;IAED,2GAA2G;IAC3G,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,GAAG,MAAM,IAAI,CAWpD;IAED;;;;OAIG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgChD;CACF;AAED,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,QAAc,CAAC"}
@@ -1,6 +1,7 @@
1
1
  export type { LoggingLevel, LogMessage, LogHandler, MastraMCPServerDefinition, MCPClientCapabilities, MCPClientInfo, MCPClientProtocolVersion, MCPInputRequest, MCPInputRequestHandler, MCPServerImplementation, ProgressHandler, InternalMastraMCPClientOptions, RequireToolApproval, RequireToolApprovalFn, RequireToolApprovalContext, ToolAnnotations, SerializableMCPToolDefinition, SerializableMCPToolCatalog, } from './types.js';
2
2
  export { MCP_CLIENT_PROTOCOL_VERSION } from './types.js';
3
3
  export * from './client.js';
4
+ export type * from './events/index.js';
4
5
  export * from './configuration.js';
5
6
  export type { MCPDiscoveryErrorDetails } from './error-utils.js';
6
7
  export * from './oauth-provider.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACtD,cAAc,UAAU,CAAC;AACzB,mBAAmB,UAAU,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -2,6 +2,7 @@ import type { IOType } from 'node:child_process';
2
2
  import type { RequestContext } from '@mastra/core/di';
3
3
  import type { StreamableHTTPClientTransportOptions, ClientCapabilities, ElicitRequestParams, ElicitResult, LoggingLevel, ProgressNotification, ToolAnnotations, jsonSchemaValidator } from '@modelcontextprotocol/client';
4
4
  import type { MCPTraceContext } from '../shared/trace-context.js';
5
+ import type { EventsWebhookSetup } from './events/types.js';
5
6
  export type { FetchLike } from '@modelcontextprotocol/client';
6
7
  export type { ToolAnnotations } from '@modelcontextprotocol/client';
7
8
  export type { LoggingLevel } from '@modelcontextprotocol/client';
@@ -482,6 +483,8 @@ export type InternalMastraMCPClientOptions = {
482
483
  clientInfo?: MCPClientInfo;
483
484
  /** Optional timeout in milliseconds */
484
485
  timeout?: number;
486
+ /** Webhook settings and receiver shared by the owning `MCPClient`'s servers. */
487
+ webhook?: EventsWebhookSetup;
485
488
  };
486
489
  /**
487
490
  * A fully serializable description of a single tool advertised by an MCP server.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,oCAAoC,EACpC,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAG9D,YAAY,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,0FAA0F;AAC1F,YAAY,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAE9F,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,EAAG,YAAqB,CAAC;AAEjE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,2BAA2B,GAAG,QAAQ,CAAC;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,IAAI,CAAC,EAAE,WAAW,EAClB,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,KACnC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,KAAK,EAAE,YAAY,CAAC;IACpB,0BAA0B;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,yCAAyC;IACzC,SA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M,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAAC"}
@@ -3,7 +3,7 @@ name: mastra-mcp
3
3
  description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mcp"
6
- version: "2.5.0-alpha.1"
6
+ version: "2.5.0-alpha.3"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -20,6 +20,7 @@ Read the individual reference documents for detailed explanations and code examp
20
20
  - [MCP](references/docs-connections-mcp.md) - Connect Mastra agents to remote MCP servers, expose Mastra tools through MCPServer, manage approvals, and build interactive MCP Apps for Studio.
21
21
  - [Connections](references/docs-connections-overview.md) - Connect Mastra to remote agents, coding agents, SDK runtimes, MCP servers, and external tools by choosing the protocol that fits your application.
22
22
  - [MCP authentication and authorization](references/docs-guides-mcp-authentication-authorization.md) - Choose credentials for MCP connections, protect a Mastra MCP server, and separate delegated access from tool and data permissions.
23
+ - [MCP events](references/docs-guides-mcp-events.md) - Publish events from a Mastra MCP server, subscribe to them with MCPClient, resume from a cursor, and start agent or workflow runs per occurrence.
23
24
 
24
25
  ### Reference
25
26
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.5.0-alpha.1",
2
+ "version": "2.5.0-alpha.3",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -47,7 +47,7 @@ A separate provider per MCP server does one thing and not another:
47
47
 
48
48
  The specification recommends support for **Client ID Metadata Documents (CIMD)**, which identify a client through an HTTPS metadata URL. It also defines pre-registration. Clients that support all registration options should prefer existing pre-registered information when available. Legacy Dynamic Client Registration (DCR) remains optional for compatibility but is deprecated for new implementations. See the versioned [client registration rules](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization/client-registration).
49
49
 
50
- Mastra's provider accepts pre-registered client information and supports a DCR-based flow. Don't infer CIMD support from the presence of OAuth support. Check the registration mechanism supported by your client integration and authorization server before choosing a deployment.
50
+ `MCPOAuthClientProvider` never registers a client at runtime and doesn't support DCR. Configure exactly one client identity: `clientInformation` for a client pre-registered with the authorization server, or `clientMetadataUrl` for CIMD. Check that your authorization server supports the mechanism you choose before deploying. See the [OAuth client reference](https://mastra.ai/reference/tools/mcp-client) for configuration examples.
51
51
 
52
52
  Mastra's interactive `authenticate()` flow uses a local loopback callback server. It isn't a hosted multi-user login endpoint. A hosted application must own its callback endpoint and associate each authorization attempt with the correct user and provider. See [interactive browser authentication](https://mastra.ai/reference/tools/mcp-client).
53
53
 
@@ -97,7 +97,7 @@ Protecting Mastra routes with `server.auth` and providing interoperable OAuth di
97
97
 
98
98
  Alongside the MCP transport, Mastra registers REST routes used by Studio to list servers, inspect tools, execute tools, and read resources. See the [MCP routes reference](https://mastra.ai/reference/server/routes) for the full list. These paths use the default `/api` prefix.
99
99
 
100
- The `POST /api/mcp/:serverId/tools/:toolId/execute` route calls `executeTool()` directly, without a protocol client. With a Mastra FGA provider configured, `MCPServer.executeTool()` enforces tool execution permission using the user in `requestContext`. The REST tool list also filters tools through FGA. These permission checks don't replace route authentication.
100
+ The `POST /api/mcp/:serverId/tools/:toolId/execute` route calls `executeTool()` directly, without a protocol client. With a Mastra FGA provider configured, `MCPServer.executeTool()` enforces tool execution permission using the user in `requestContext`. The REST tool list also filters tools through FGA, but these permission checks don't replace route authentication.
101
101
 
102
102
  Built-in authentication for these routes depends on `server.auth`. Without it, `requiresAuth: true` doesn't enforce authentication. Custom middleware that checks only the `/mcp` or `/sse` transport paths leaves the REST routes open. If you use custom middleware instead of `server.auth`, default-deny `/api/mcp/*` and allow access only after authentication.
103
103