@mastra/mcp 1.18.1-alpha.2 → 2.0.0-alpha.4

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 (90) hide show
  1. package/dist/client/actions/resource.d.ts +9 -59
  2. package/dist/client/actions/resource.d.ts.map +1 -1
  3. package/dist/client/client.d.ts +71 -124
  4. package/dist/client/client.d.ts.map +1 -1
  5. package/dist/client/configuration.d.ts +30 -120
  6. package/dist/client/configuration.d.ts.map +1 -1
  7. package/dist/client/error-utils.d.ts +9 -0
  8. package/dist/client/error-utils.d.ts.map +1 -1
  9. package/dist/client/index.d.ts +2 -1
  10. package/dist/client/index.d.ts.map +1 -1
  11. package/dist/client/oauth-callback-server.d.ts +8 -4
  12. package/dist/client/oauth-callback-server.d.ts.map +1 -1
  13. package/dist/client/oauth-provider.d.ts +91 -45
  14. package/dist/client/oauth-provider.d.ts.map +1 -1
  15. package/dist/client/server-proxy.d.ts +26 -46
  16. package/dist/client/server-proxy.d.ts.map +1 -1
  17. package/dist/client/types.d.ts +106 -143
  18. package/dist/client/types.d.ts.map +1 -1
  19. package/dist/conformance/fixture.d.ts +3 -0
  20. package/dist/conformance/fixture.d.ts.map +1 -0
  21. package/dist/conformance/run.d.ts +2 -0
  22. package/dist/conformance/run.d.ts.map +1 -0
  23. package/dist/conformance/stdio-server.d.ts +2 -0
  24. package/dist/conformance/stdio-server.d.ts.map +1 -0
  25. package/dist/docs/SKILL.md +2 -1
  26. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  27. package/dist/docs/references/reference-migrations-mcp-v2.md +268 -0
  28. package/dist/docs/references/reference-tools-mcp-client.md +36 -14
  29. package/dist/docs/references/reference-tools-mcp-server.md +24 -83
  30. package/dist/index.cjs +1532 -3284
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +1535 -3288
  33. package/dist/index.js.map +1 -1
  34. package/dist/server/actions.d.ts +34 -0
  35. package/dist/server/actions.d.ts.map +1 -0
  36. package/dist/server/oauth-middleware.d.ts +1 -1
  37. package/dist/server/request.d.ts +54 -0
  38. package/dist/server/request.d.ts.map +1 -0
  39. package/dist/server/server.d.ts +112 -808
  40. package/dist/server/server.d.ts.map +1 -1
  41. package/dist/server/types.d.ts +82 -138
  42. package/dist/server/types.d.ts.map +1 -1
  43. package/dist/shared/index.d.ts +1 -0
  44. package/dist/shared/index.d.ts.map +1 -1
  45. package/dist/shared/oauth-types.d.ts +3 -3
  46. package/dist/shared/oauth-types.d.ts.map +1 -1
  47. package/dist/shared/trace-context.d.ts +20 -0
  48. package/dist/shared/trace-context.d.ts.map +1 -0
  49. package/package.json +12 -17
  50. package/dist/_types/hono/dist/types/client/client.d.ts +0 -4
  51. package/dist/_types/hono/dist/types/client/fetch-result-please.d.ts +0 -35
  52. package/dist/_types/hono/dist/types/client/index.d.ts +0 -7
  53. package/dist/_types/hono/dist/types/client/types.d.ts +0 -229
  54. package/dist/_types/hono/dist/types/client/utils.d.ts +0 -18
  55. package/dist/_types/hono/dist/types/context.d.ts +0 -455
  56. package/dist/_types/hono/dist/types/helper/streaming/index.d.ts +0 -8
  57. package/dist/_types/hono/dist/types/helper/streaming/sse.d.ts +0 -13
  58. package/dist/_types/hono/dist/types/helper/streaming/stream.d.ts +0 -3
  59. package/dist/_types/hono/dist/types/helper/streaming/text.d.ts +0 -3
  60. package/dist/_types/hono/dist/types/hono-base.d.ts +0 -220
  61. package/dist/_types/hono/dist/types/hono.d.ts +0 -19
  62. package/dist/_types/hono/dist/types/index.d.ts +0 -37
  63. package/dist/_types/hono/dist/types/request/constants.d.ts +0 -1
  64. package/dist/_types/hono/dist/types/request.d.ts +0 -324
  65. package/dist/_types/hono/dist/types/router.d.ts +0 -97
  66. package/dist/_types/hono/dist/types/types.d.ts +0 -573
  67. package/dist/_types/hono/dist/types/utils/body.d.ts +0 -79
  68. package/dist/_types/hono/dist/types/utils/headers.d.ts +0 -8
  69. package/dist/_types/hono/dist/types/utils/http-status.d.ts +0 -32
  70. package/dist/_types/hono/dist/types/utils/mime.d.ts +0 -70
  71. package/dist/_types/hono/dist/types/utils/stream.d.ts +0 -31
  72. package/dist/_types/hono/dist/types/utils/types.d.ts +0 -74
  73. package/dist/_types/hono/package.json +0 -1
  74. package/dist/_types/hono-mcp-server-sse-transport/build/index.d.ts +0 -1
  75. package/dist/_types/hono-mcp-server-sse-transport/build/sse.d.ts +0 -25
  76. package/dist/_types/hono-mcp-server-sse-transport/package.json +0 -1
  77. package/dist/client/actions/elicitation.d.ts +0 -63
  78. package/dist/client/actions/elicitation.d.ts.map +0 -1
  79. package/dist/server/__tests__/mock-extra.d.ts +0 -15
  80. package/dist/server/__tests__/mock-extra.d.ts.map +0 -1
  81. package/dist/server/mrtrElicitation.d.ts +0 -39
  82. package/dist/server/mrtrElicitation.d.ts.map +0 -1
  83. package/dist/server/notificationBroadcast.d.ts +0 -24
  84. package/dist/server/notificationBroadcast.d.ts.map +0 -1
  85. package/dist/server/promptActions.d.ts +0 -49
  86. package/dist/server/promptActions.d.ts.map +0 -1
  87. package/dist/server/resourceActions.d.ts +0 -72
  88. package/dist/server/resourceActions.d.ts.map +0 -1
  89. package/dist/server/toolActions.d.ts +0 -84
  90. package/dist/server/toolActions.d.ts.map +0 -1
@@ -0,0 +1,34 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
2
+ import type { IMastraLogger } from '@mastra/core/logger';
3
+ import type { ServerNotifier } from '@modelcontextprotocol/server';
4
+ interface ActionDependencies {
5
+ getLogger: () => IMastraLogger;
6
+ /** Clients receive change events through `subscriptions/listen`; undefined until a transport is serving. */
7
+ getNotifier: () => ServerNotifier | undefined;
8
+ }
9
+ /** Runtime tool catalogue mutations. Every change is published to listening clients. */
10
+ export declare class ServerToolActions {
11
+ private readonly deps;
12
+ constructor(deps: ActionDependencies & {
13
+ addTools: (tools: ToolsInput) => void;
14
+ removeTools: (toolIds: string[]) => string[];
15
+ });
16
+ add(tools: ToolsInput): Promise<void>;
17
+ remove(toolIds: string[]): Promise<void>;
18
+ notifyListChanged(): Promise<void>;
19
+ }
20
+ export declare class ServerResourceActions {
21
+ private readonly deps;
22
+ constructor(deps: ActionDependencies);
23
+ notifyUpdated({ uri }: {
24
+ uri: string;
25
+ }): Promise<void>;
26
+ notifyListChanged(): Promise<void>;
27
+ }
28
+ export declare class ServerPromptActions {
29
+ private readonly deps;
30
+ constructor(deps: ActionDependencies);
31
+ notifyListChanged(): Promise<void>;
32
+ }
33
+ export {};
34
+ //# sourceMappingURL=actions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/server/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,aAAa,CAAC;IAC/B,4GAA4G;IAC5G,WAAW,EAAE,MAAM,cAAc,GAAG,SAAS,CAAC;CAC/C;AAED,wFAAwF;AACxF,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IADvB,YACmB,IAAI,EAAE,kBAAkB,GAAG;QAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;QACtC,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;KAC9C,EACC;IAEE,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1C;IAEK,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAG7C;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvC;CACF;AAED,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,kBAAkB,EAAI;IAEnD,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3D;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvC;CACF;AAED,qBAAa,mBAAmB;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAAjC,YAA6B,IAAI,EAAE,kBAAkB,EAAI;IAEnD,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGvC;CACF"}
@@ -4,7 +4,7 @@
4
4
  * Implements OAuth 2.0 Protected Resource support per RFC 9728 for MCP servers.
5
5
  * This allows MCP servers to require OAuth authentication from clients.
6
6
  *
7
- * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization
7
+ * @see https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization
8
8
  * @see https://www.rfc-editor.org/rfc/rfc9728.html
9
9
  */
10
10
  import type * as http from 'node:http';
@@ -0,0 +1,54 @@
1
+ import { RequestContext } from '@mastra/core/request-context';
2
+ import type { MCPToolExecutionContext } from '@mastra/core/tools';
3
+ import type { ServerContext } from '@modelcontextprotocol/server';
4
+ import type { MCPAuthInfoToUserMapper } from './types.js';
5
+ /**
6
+ * The `context.mcp` a 2026-07-28 request hands to tools: the 1.x shape, with the
7
+ * per-request facilities (cancellation, metadata, auth, log, progress) live and the
8
+ * removed server-initiated requests throwing at the call site.
9
+ */
10
+ export declare function toToolExecutionContext(ctx: ServerContext, loggerName: string): MCPToolExecutionContext;
11
+ /**
12
+ * Builds the trusted application context for one request. Auth is re-derived from
13
+ * the transport every time; nothing is carried between continuation rounds. The W3C
14
+ * trace fields sent by the client are exposed under `traceContext` as opaque
15
+ * strings for observability only; they are never consulted for authorization.
16
+ */
17
+ export declare function toRequestContext(ctx: ServerContext, mapAuthInfoToUser: MCPAuthInfoToUserMapper | undefined): Promise<RequestContext>;
18
+ /**
19
+ * The identity a continuation is bound to; a different caller cannot resume it.
20
+ * Prefers the token subject, then the id of the user `mapAuthInfoToUser` produced,
21
+ * and otherwise the bearer token itself, so two users sharing one OAuth client
22
+ * never share a principal. A token refreshed mid-round therefore starts over.
23
+ */
24
+ export declare function principalOf(ctx: ServerContext, requestContext: RequestContext): string;
25
+ export declare function hashArguments(value: unknown): string;
26
+ /**
27
+ * What the server signs into `requestState` when a handler suspends. It names the
28
+ * exact operation and caller so a continuation can only answer the round it was
29
+ * issued for; `suspendPayload` is what the handler asked to be handed back.
30
+ */
31
+ export interface ContinuationEnvelope {
32
+ method: 'tools/call' | 'resources/read' | 'prompts/get';
33
+ name: string;
34
+ argsHash: string;
35
+ principal: string;
36
+ round: number;
37
+ suspendPayload: unknown;
38
+ iat: number;
39
+ }
40
+ /** The key every suspended round asks the client to answer under. */
41
+ export declare const INPUT_KEY = "input";
42
+ export interface ContinuationRound {
43
+ round: number;
44
+ suspendPayload: unknown;
45
+ /** Present when the client accepted; a decline or cancel ends the request instead. */
46
+ resumeData?: unknown;
47
+ outcome: 'accept' | 'decline' | 'cancel';
48
+ }
49
+ /**
50
+ * Reads the continuation the SDK already integrity-checked and pairs it with this
51
+ * round's answer. Returns `undefined` for a fresh request.
52
+ */
53
+ export declare function readContinuation(ctx: ServerContext, requestContext: RequestContext, expected: Pick<ContinuationEnvelope, 'method' | 'name' | 'argsHash'>): ContinuationRound | undefined;
54
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKvD;;;;GA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