@frontmcp/sdk 1.5.7 → 1.6.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.
Files changed (88) hide show
  1. package/README.md +12 -5
  2. package/auth/flows/oauth.authorize.flow.d.ts +8 -0
  3. package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
  4. package/auth/flows/oauth.callback.flow.d.ts +8 -0
  5. package/auth/flows/oauth.callback.flow.d.ts.map +1 -1
  6. package/auth/flows/oauth.provider-callback.flow.d.ts +1 -0
  7. package/auth/flows/oauth.provider-callback.flow.d.ts.map +1 -1
  8. package/auth/flows/oauth.register.flow.d.ts +4 -0
  9. package/auth/flows/oauth.register.flow.d.ts.map +1 -1
  10. package/auth/flows/well-known.oauth-authorization-server.flow.d.ts.map +1 -1
  11. package/auth/instances/instance.local-primary-auth.d.ts +38 -0
  12. package/auth/instances/instance.local-primary-auth.d.ts.map +1 -1
  13. package/common/interfaces/tool.interface.d.ts +33 -1
  14. package/common/interfaces/tool.interface.d.ts.map +1 -1
  15. package/common/metadata/front-mcp.metadata.d.ts +34 -0
  16. package/common/metadata/front-mcp.metadata.d.ts.map +1 -1
  17. package/common/types/options/transport/interfaces.d.ts +14 -0
  18. package/common/types/options/transport/interfaces.d.ts.map +1 -1
  19. package/common/types/options/transport/schema.d.ts +4 -0
  20. package/common/types/options/transport/schema.d.ts.map +1 -1
  21. package/common/utils/decide-request-intent.utils.d.ts +3 -3
  22. package/common/utils/decide-request-intent.utils.d.ts.map +1 -1
  23. package/context/frontmcp-context.d.ts +46 -1
  24. package/context/frontmcp-context.d.ts.map +1 -1
  25. package/elicitation/helpers/elicit.helper.d.ts.map +1 -1
  26. package/elicitation/helpers/index.d.ts +1 -0
  27. package/elicitation/helpers/index.d.ts.map +1 -1
  28. package/elicitation/helpers/mrtr-request.helper.d.ts +83 -0
  29. package/elicitation/helpers/mrtr-request.helper.d.ts.map +1 -0
  30. package/errors/index.d.ts +1 -0
  31. package/errors/index.d.ts.map +1 -1
  32. package/errors/mrtr.error.d.ts +55 -0
  33. package/errors/mrtr.error.d.ts.map +1 -0
  34. package/esm/index.mjs +2862 -470
  35. package/front-mcp/front-mcp.providers.d.ts +4 -0
  36. package/front-mcp/front-mcp.providers.d.ts.map +1 -1
  37. package/index.d.ts +10 -4
  38. package/index.d.ts.map +1 -1
  39. package/index.js +3134 -731
  40. package/package.json +11 -11
  41. package/remote-mcp/mcp-client.service.d.ts +7 -0
  42. package/remote-mcp/mcp-client.service.d.ts.map +1 -1
  43. package/remote-mcp/mcp-client.types.d.ts +19 -6
  44. package/remote-mcp/mcp-client.types.d.ts.map +1 -1
  45. package/remote-mcp/mcp-stateless-client.adapter.d.ts +85 -0
  46. package/remote-mcp/mcp-stateless-client.adapter.d.ts.map +1 -0
  47. package/scope/flows/http.request.flow.d.ts +9 -3
  48. package/scope/flows/http.request.flow.d.ts.map +1 -1
  49. package/task/helpers/task-runner.d.ts.map +1 -1
  50. package/task/task.types.d.ts +16 -0
  51. package/task/task.types.d.ts.map +1 -1
  52. package/tool/flows/call-tool.flow.d.ts.map +1 -1
  53. package/transport/flows/handle.mcp-20260728.flow.d.ts +77 -0
  54. package/transport/flows/handle.mcp-20260728.flow.d.ts.map +1 -0
  55. package/transport/mcp-20260728/client/header-params.d.ts +22 -0
  56. package/transport/mcp-20260728/client/header-params.d.ts.map +1 -0
  57. package/transport/mcp-20260728/client/index.d.ts +8 -0
  58. package/transport/mcp-20260728/client/index.d.ts.map +1 -0
  59. package/transport/mcp-20260728/client/mcp-stateless.client.d.ts +157 -0
  60. package/transport/mcp-20260728/client/mcp-stateless.client.d.ts.map +1 -0
  61. package/transport/mcp-20260728/discover.d.ts +28 -0
  62. package/transport/mcp-20260728/discover.d.ts.map +1 -0
  63. package/transport/mcp-20260728/dispatcher.d.ts +77 -0
  64. package/transport/mcp-20260728/dispatcher.d.ts.map +1 -0
  65. package/transport/mcp-20260728/header-codec.d.ts +32 -0
  66. package/transport/mcp-20260728/header-codec.d.ts.map +1 -0
  67. package/transport/mcp-20260728/index.d.ts +22 -0
  68. package/transport/mcp-20260728/index.d.ts.map +1 -0
  69. package/transport/mcp-20260728/mrtr.d.ts +143 -0
  70. package/transport/mcp-20260728/mrtr.d.ts.map +1 -0
  71. package/transport/mcp-20260728/protocol-20260728.constants.d.ts +46 -0
  72. package/transport/mcp-20260728/protocol-20260728.constants.d.ts.map +1 -0
  73. package/transport/mcp-20260728/request-notifications.d.ts +70 -0
  74. package/transport/mcp-20260728/request-notifications.d.ts.map +1 -0
  75. package/transport/mcp-20260728/request-state.d.ts +76 -0
  76. package/transport/mcp-20260728/request-state.d.ts.map +1 -0
  77. package/transport/mcp-20260728/request-validation.d.ts +83 -0
  78. package/transport/mcp-20260728/request-validation.d.ts.map +1 -0
  79. package/transport/mcp-20260728/result-decorator.d.ts +62 -0
  80. package/transport/mcp-20260728/result-decorator.d.ts.map +1 -0
  81. package/transport/mcp-20260728/subscriptions.d.ts +47 -0
  82. package/transport/mcp-20260728/subscriptions.d.ts.map +1 -0
  83. package/transport/mcp-20260728/tasks-extension.d.ts +90 -0
  84. package/transport/mcp-20260728/tasks-extension.d.ts.map +1 -0
  85. package/transport/mcp-handlers/call-tool-request.handler.d.ts.map +1 -1
  86. package/transport/mcp-handlers/index.d.ts +556 -556
  87. package/transport/mcp-handlers/index.d.ts.map +1 -1
  88. package/transport/transport.registry.d.ts.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-stateless.client.d.ts","sourceRoot":"","sources":["../../../../src/transport/mcp-20260728/client/mcp-stateless.client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAA0C,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIjG,OAAO,EAAsB,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGhF,yEAAyE;AACzE,MAAM,WAAW,yBAAyB;IACxC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,CAA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E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIlG;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA6BrG,uEAAuE;YACzD,YAAY;IAkC1B;;;;;OAKG;YACW,SAAS;IAoCvB,6BAA6B;IACvB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;;;;;OAMG;IACG,MAAM,CACV,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,cAAc,EAAE,CAAC,YAAY,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,KAAK,IAAI,GAC3F,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAsDxE,kEAAkE;YACpD,IAAI;IAgClB,gEAAgE;IAChE,OAAO,CAAC,YAAY;IAmCpB,OAAO,CAAC,UAAU;IAMlB;;;;;;OAMG;YACW,YAAY;IAsB1B,2EAA2E;YAC7D,OAAO;IAmCrB,OAAO,CAAC,IAAI;CAGb;AAED,uFAAuF;AACvF,eAAO,MAAM,uBAAuB;;;;CAA+C,CAAC;AAEpF,gGAAgG;AAChG,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `server/discover` — protocol 2026-07-28, SEP-2575.
3
+ *
4
+ * Servers MUST implement this RPC. It advertises the versions the server
5
+ * speaks, its capabilities, and its instructions — the payload `initialize`
6
+ * used to return, minus everything that only made sense for a session.
7
+ *
8
+ * Clients MAY skip it entirely and negotiate inline via per-request `_meta`,
9
+ * which is why it must be cheap and side-effect free.
10
+ */
11
+ import { type DiscoverResult, type ServerCapabilities20260728 } from '@frontmcp/protocol';
12
+ import { type Scope } from '../../scope';
13
+ /**
14
+ * Project the scope's capability set into the 2026-07-28 shape.
15
+ *
16
+ * The only structural change is `extensions`: this revision promotes optional
17
+ * MCP extensions out of `experimental` into a first-class field, so anything
18
+ * the scope already advertises is merged with the server-level extension list.
19
+ */
20
+ export declare function buildDiscoverCapabilities(scope: Scope): ServerCapabilities20260728;
21
+ /**
22
+ * Build the `server/discover` result body.
23
+ *
24
+ * `resultType`, `_meta.serverInfo`, `ttlMs` and `cacheScope` are added by the
25
+ * shared result decorator, so this returns only the method-specific fields.
26
+ */
27
+ export declare function buildDiscoverResult(scope: Scope, instructions?: string): Omit<DiscoverResult, keyof object>;
28
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAE1F,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAIzC;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,GAAG,0BAA0B,CAmBlF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,MAAM,MAAM,CAAC,CAQ3G"}
@@ -0,0 +1,77 @@
1
+ import { type FrontMcpContext } from '../../context';
2
+ import { type Scope } from '../../scope';
3
+ import { type RequestNotificationSink } from './request-notifications';
4
+ import { type JsonRpcErrorPayload } from './request-validation';
5
+ export interface DispatchOptions {
6
+ scope: Scope;
7
+ /** The validated JSON-RPC request body. */
8
+ body: Record<string, unknown>;
9
+ /** Capabilities the client declared in this request's `_meta`. */
10
+ clientCapabilities: Record<string, unknown>;
11
+ /** Ambient request context, used to carry the MRTR exchange to `elicit()`. */
12
+ frontmcpContext?: FrontMcpContext;
13
+ /** Auth info forwarded to the shared handlers. */
14
+ authInfo?: Record<string, unknown>;
15
+ /** True when the caller is unauthenticated, which makes results publicly cacheable. */
16
+ isAnonymous: boolean;
17
+ signal?: AbortSignal;
18
+ /** Lazily composed instructions for `server/discover`. */
19
+ composeInstructions?: () => string | undefined;
20
+ /** Collects `notifications/message` + `notifications/progress` for this request. */
21
+ notificationSink?: RequestNotificationSink;
22
+ /** OpenTelemetry context echoed back on the result (SEP-414). */
23
+ traceContext?: Record<string, string>;
24
+ }
25
+ export type DispatchResult = {
26
+ kind: 'result';
27
+ result: Record<string, unknown>;
28
+ } | {
29
+ kind: 'error';
30
+ status: number;
31
+ error: JsonRpcErrorPayload;
32
+ };
33
+ /**
34
+ * Requests that MAY return an `InputRequiredResult`.
35
+ *
36
+ * The spec enumerates these three and adds "Servers MUST NOT send
37
+ * `InputRequiredResult` responses on any other client requests."
38
+ */
39
+ export declare const MRTR_CAPABLE_METHODS: readonly ["tools/call", "prompts/get", "resources/read"];
40
+ /**
41
+ * Identify the caller for `requestState` binding.
42
+ *
43
+ * Falls back to a fixed anonymous marker rather than a random value: public
44
+ * servers must still be able to redeem their own state on the retry, and there
45
+ * is no principal to separate anonymous callers by.
46
+ */
47
+ export declare function resolvePrincipal(authInfo: Record<string, unknown> | undefined): string;
48
+ /**
49
+ * Identify the caller for TASK ownership.
50
+ *
51
+ * Stricter than {@link resolvePrincipal}: a public-mode server mints an
52
+ * anonymous bootstrap token per request, which is a fine binding for a
53
+ * short-lived `requestState` but must NOT be mistaken for an identity that can
54
+ * own a durable task. Anonymous callers resolve to `'anonymous'` so task
55
+ * creation is refused rather than pooled across unrelated users.
56
+ */
57
+ export declare function resolveTaskPrincipal(authInfo: Record<string, unknown> | undefined, isAnonymous?: boolean): string;
58
+ /**
59
+ * Map a thrown error onto a JSON-RPC error payload.
60
+ *
61
+ * The one substantive change from earlier revisions is resource-not-found:
62
+ * `-32002` was retired in favour of `-32602` to align with JSON-RPC. Because
63
+ * the shared handlers still raise the old code (they serve legacy clients too),
64
+ * the translation happens here rather than at the source.
65
+ */
66
+ export declare function toJsonRpcError(error: unknown): {
67
+ status: number;
68
+ error: JsonRpcErrorPayload;
69
+ };
70
+ /**
71
+ * Dispatch one 2026-07-28 JSON-RPC request.
72
+ *
73
+ * `subscriptions/listen` is NOT handled here — it needs to own the HTTP
74
+ * response as a stream, so the flow handles it before calling in.
75
+ */
76
+ export declare function dispatch20260728(options: DispatchOptions): Promise<DispatchResult>;
77
+ //# sourceMappingURL=dispatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/dispatcher.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAWhE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,8EAA8E;IAC9E,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,uFAAuF;IACvF,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,0DAA0D;IAC1D,mBAAmB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC/C,oFAAoF;IACpF,gBAAgB,CAAC,EAAE,uBAAuB,CAAC;IAC3C,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,0DAA2D,CAAC;AAE7F;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAWtF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,WAAW,UAAQ,GAAG,MAAM,CAS/G;AAqGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,CA2B7F;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAqKxF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Value encoding for the mirrored HTTP headers of protocol 2026-07-28.
3
+ *
4
+ * HTTP field values are limited to visible ASCII, so a tool name, resource URI,
5
+ * or parameter value that falls outside that set travels Base64-wrapped in the
6
+ * `=?base64?…?=` sentinel. Servers MUST decode before comparing to the body —
7
+ * a naive string compare would reject every conforming client that had to
8
+ * encode, and would accept a crafted literal that merely LOOKS encoded.
9
+ */
10
+ /** True when `value` is wrapped in the (case-sensitive, lowercase) sentinel. */
11
+ export declare function isSentinelEncoded(value: string): boolean;
12
+ /**
13
+ * Decode a mirrored header value.
14
+ *
15
+ * Returns `undefined` when the sentinel is present but the payload is not valid
16
+ * Base64/UTF-8 — the caller turns that into a `HeaderMismatch` rather than
17
+ * silently comparing garbage.
18
+ */
19
+ export declare function decodeHeaderValue(value: string): string | undefined;
20
+ /** Encode a value for a mirrored header, wrapping it only when necessary. */
21
+ export declare function encodeHeaderValue(value: string): string;
22
+ /** True when a raw header value contains octets HTTP does not permit. */
23
+ export declare function hasInvalidHeaderChars(value: string): boolean;
24
+ /**
25
+ * Compare a decoded header value against the value found in the request body.
26
+ *
27
+ * Numbers are compared numerically per the spec note (`42` and `42.0` are
28
+ * equal); booleans use their lowercase spelling; everything else is an exact
29
+ * string match.
30
+ */
31
+ export declare function headerMatchesBodyValue(headerValue: string, bodyValue: unknown): boolean;
32
+ //# sourceMappingURL=header-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header-codec.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/header-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAMxD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAanE;AAED,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvD;AAKD,yEAAyE;AACzE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO,CASvF"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * MCP protocol revision 2026-07-28 support.
3
+ *
4
+ * Everything in here is additive: a request is only routed through this module
5
+ * when it explicitly declares the 2026-07-28 revision (or uses a method that
6
+ * exists only in it). Every earlier revision keeps its original code path.
7
+ *
8
+ * @module transport/mcp-20260728
9
+ */
10
+ export * from './protocol-20260728.constants';
11
+ export * from './header-codec';
12
+ export * from './request-validation';
13
+ export * from './request-state';
14
+ export * from './request-notifications';
15
+ export * from './result-decorator';
16
+ export * from './discover';
17
+ export * from './mrtr';
18
+ export * from './subscriptions';
19
+ export * from './tasks-extension';
20
+ export * from './dispatcher';
21
+ export * from './client';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Multi Round-Trip Requests (MRTR) — protocol 2026-07-28, SEP-2322.
3
+ *
4
+ * ## How a round trip works
5
+ *
6
+ * 1. The tool calls `this.elicit(...)` / `this.sample(...)` / `this.listRoots()`.
7
+ * No response is recorded for that call yet, so the exchange records the
8
+ * pending request and throws {@link InputRequiredSignal}.
9
+ * 2. The dispatcher turns the signal into an `InputRequiredResult`
10
+ * (`resultType: "input_required"`) carrying `inputRequests` and an opaque,
11
+ * integrity-protected `requestState`.
12
+ * 3. The client gathers the input and re-issues the SAME request (with a NEW
13
+ * JSON-RPC id) carrying `inputResponses` + the echoed `requestState`.
14
+ * 4. The entry runs again from the top. This time each call finds a recorded
15
+ * answer and returns it inline, so execution proceeds.
16
+ *
17
+ * Entries are therefore replayed, not resumed — which is why keys are derived
18
+ * from the call ORDER (`elicit-1`, `sampling-1`, `roots-1`, …) rather than
19
+ * randomly: the second run must line its calls up with the first run's answers.
20
+ *
21
+ * `requestState` accumulates every answer gathered so far, so a multi-step tool
22
+ * converges even if the client only echoes the most recent `inputResponses`.
23
+ * It is signed and bound to the caller and the originating request — see
24
+ * {@link ./request-state}.
25
+ */
26
+ import type { InputResponses } from '@frontmcp/protocol';
27
+ import { type ElicitStatus } from '../../elicitation';
28
+ import { InputRequiredSignal } from '../../errors';
29
+ import { type RequestStateBinding } from './request-state';
30
+ /** Requests the client may be asked to fulfil, and the capability each needs. */
31
+ declare const CAPABILITY_FOR_KIND: {
32
+ readonly elicitation: {
33
+ readonly capability: "elicitation";
34
+ readonly required: {
35
+ readonly elicitation: {
36
+ readonly form: {};
37
+ };
38
+ };
39
+ };
40
+ readonly sampling: {
41
+ readonly capability: "sampling";
42
+ readonly required: {
43
+ readonly sampling: {};
44
+ };
45
+ };
46
+ readonly roots: {
47
+ readonly capability: "roots";
48
+ readonly required: {
49
+ readonly roots: {};
50
+ };
51
+ };
52
+ };
53
+ export type MrtrRequestKind = keyof typeof CAPABILITY_FOR_KIND;
54
+ /** Shape recorded for a pending elicitation before it becomes an input request. */
55
+ export interface PendingElicitation {
56
+ message: string;
57
+ requestedSchema: Record<string, unknown>;
58
+ mode?: 'form' | 'url';
59
+ url?: string;
60
+ }
61
+ /** Parameters for a `sampling/createMessage` input request. */
62
+ export interface PendingSampling {
63
+ messages: unknown[];
64
+ maxTokens: number;
65
+ systemPrompt?: string;
66
+ modelPreferences?: Record<string, unknown>;
67
+ temperature?: number;
68
+ stopSequences?: string[];
69
+ includeContext?: 'none' | 'thisServer' | 'allServers';
70
+ metadata?: Record<string, unknown>;
71
+ }
72
+ /** The client's answer to a `sampling/createMessage` request. */
73
+ export interface SamplingAnswer {
74
+ role: string;
75
+ content: unknown;
76
+ model?: string;
77
+ stopReason?: string;
78
+ }
79
+ /** The client's answer to a `roots/list` request. */
80
+ export interface RootsAnswer {
81
+ roots: Array<{
82
+ uri: string;
83
+ name?: string;
84
+ }>;
85
+ }
86
+ /**
87
+ * Per-request bookkeeping for one MRTR exchange.
88
+ *
89
+ * Lives on the `FrontMcpContext` for the duration of a single dispatch, so
90
+ * `elicit()` / `sample()` / `listRoots()` deep inside an entry can reach it
91
+ * without threading it through every flow stage.
92
+ */
93
+ export declare class MrtrExchange {
94
+ /** Answers already supplied by the client, keyed by input-request key. */
95
+ private readonly responses;
96
+ /** Requests raised during THIS run that the client still has to answer. */
97
+ private readonly pending;
98
+ /** Per-kind call counters, used to derive stable keys across a replay. */
99
+ private readonly counters;
100
+ readonly clientCapabilities: Record<string, unknown>;
101
+ private readonly binding;
102
+ constructor(params: {
103
+ /** `inputResponses` from the request params. */
104
+ inputResponses?: InputResponses;
105
+ /** Answers carried over from earlier rounds via a verified `requestState`. */
106
+ carriedResponses?: InputResponses;
107
+ /** Capabilities the client declared for this request. */
108
+ clientCapabilities: Record<string, unknown>;
109
+ /** Principal + request digest that new state will be bound to. */
110
+ binding: RequestStateBinding;
111
+ });
112
+ /** True when the client declared the capability a given request kind needs. */
113
+ supports(kind: MrtrRequestKind): boolean;
114
+ /** True when the client declared support for elicitation in this request. */
115
+ supportsElicitation(mode?: 'form' | 'url'): boolean;
116
+ /**
117
+ * Look up a recorded answer for the next call of `kind`, or record the
118
+ * request and unwind.
119
+ *
120
+ * The spec forbids asking for something the client never said it supports, so
121
+ * an undeclared capability fails fast with `-32021` rather than emitting an
122
+ * `inputRequests` entry the client cannot honor.
123
+ */
124
+ private resolve;
125
+ /** Resolve the next `elicit()` call. */
126
+ resolveElicitation(pending: PendingElicitation): {
127
+ status: ElicitStatus;
128
+ content?: unknown;
129
+ };
130
+ /** Resolve the next `sample()` call. */
131
+ resolveSampling(pending: PendingSampling): SamplingAnswer;
132
+ /** Resolve the next `listRoots()` call. */
133
+ resolveRoots(): RootsAnswer;
134
+ }
135
+ /**
136
+ * Build the `InputRequiredResult` body for a raised signal.
137
+ *
138
+ * `resultType` is set here rather than by the generic result decorator because
139
+ * an interim result is precisely the case the decorator must not overwrite.
140
+ */
141
+ export declare function buildInputRequiredResult(signal: InputRequiredSignal): Record<string, unknown>;
142
+ export {};
143
+ //# sourceMappingURL=mrtr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mrtr.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/mrtr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,cAAc,CAAC;AACjF,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE/E,iFAAiF;AACjF,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;CAIf,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE/D,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,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CAAC;KAC9B;IAQD,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO;IAKxC,6EAA6E;IAC7E,mBAAmB,CAAC,IAAI,GAAE,MAAM,GAAG,KAAc,GAAG,OAAO;IAY3D;;;;;;;OAOG;IACH,OAAO,CAAC,OAAO;IA0Bf,wCAAwC;IACxC,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAmB5F,wCAAwC;IACxC,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,cAAc;IAkBzD,2CAA2C;IAC3C,YAAY,IAAI,WAAW;CAK5B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAM7F"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Every revision this server speaks, newest first.
3
+ *
4
+ * Advertised verbatim by `server/discover` and echoed in the `supported` array
5
+ * of an `UnsupportedProtocolVersionError`. The older entries are load-bearing:
6
+ * dropping one would strand every client that negotiated it.
7
+ */
8
+ export declare const FRONTMCP_SUPPORTED_PROTOCOL_VERSIONS: readonly ["2026-07-28", "2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
9
+ /**
10
+ * Revisions handled by the pre-existing session/`initialize` pipeline.
11
+ *
12
+ * A request declaring one of these is NOT claimed by the 2026 path, which is
13
+ * what keeps the old behaviour bit-for-bit identical.
14
+ */
15
+ export declare const LEGACY_PROTOCOL_VERSIONS: string[];
16
+ /** Methods that exist only in 2026-07-28. */
17
+ export declare const PROTOCOL_20260728_ONLY_METHODS: string[];
18
+ /** HTTP header names mirrored from the JSON-RPC body (SEP-2243). */
19
+ export declare const MCP_HEADERS: {
20
+ readonly protocolVersion: "mcp-protocol-version";
21
+ readonly method: "mcp-method";
22
+ readonly name: "mcp-name";
23
+ /** Prefix for `x-mcp-header`-derived parameter headers. */
24
+ readonly paramPrefix: "mcp-param-";
25
+ };
26
+ /** Methods whose `Mcp-Name` header is sourced from `params.name`. */
27
+ export declare const NAME_FROM_PARAMS_NAME: string[];
28
+ /** Methods whose `Mcp-Name` header is sourced from `params.uri`. */
29
+ export declare const NAME_FROM_PARAMS_URI: string[];
30
+ /**
31
+ * Default `ttlMs` per cacheable method.
32
+ *
33
+ * Conservative on purpose: list endpoints change rarely and benefit most from
34
+ * caching, while `resources/read` is content that a server may regenerate, so
35
+ * it defaults to "revalidate every time" rather than risking a stale read.
36
+ */
37
+ export declare const DEFAULT_CACHE_TTL_MS: Record<string, number>;
38
+ /** Methods whose results MUST carry `ttlMs` + `cacheScope` (`CacheableResult`). */
39
+ export declare const CACHEABLE_METHODS: string[];
40
+ /**
41
+ * MCP extensions this server advertises under `capabilities.extensions`.
42
+ *
43
+ * Keys follow the `_meta` naming rules (mandatory reverse-DNS prefix).
44
+ */
45
+ export declare const ADVERTISED_EXTENSIONS: Record<string, Record<string, unknown>>;
46
+ //# sourceMappingURL=protocol-20260728.constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-20260728.constants.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/protocol-20260728.constants.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC,iFAMvC,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,UAAyE,CAAC;AAE/G,6CAA6C;AAC7C,eAAO,MAAM,8BAA8B,UAA8C,CAAC;AAE1F,oEAAoE;AACpE,eAAO,MAAM,WAAW;;;;IAItB,2DAA2D;;CAEnD,CAAC;AAEX,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,UAAgC,CAAC;AAEnE,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,UAAqB,CAAC;AAEvD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOvD,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,UAAoC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Request-scoped notifications for protocol 2026-07-28.
3
+ *
4
+ * Two rules from SEP-2575 shape this:
5
+ *
6
+ * - `notifications/progress` and `notifications/message` flow on the response
7
+ * stream of the request they relate to — never on the `subscriptions/listen`
8
+ * stream, and never on a session channel (there are no sessions).
9
+ * - `logging/setLevel` is gone. The client opts in per request via
10
+ * `_meta["io.modelcontextprotocol/logLevel"]`, and a server **MUST NOT** emit
11
+ * `notifications/message` for a request that omitted it.
12
+ *
13
+ * The sink is attached to the `FrontMcpContext` for the duration of one
14
+ * dispatch, so `this.notify()` / `this.progress()` deep inside an entry reach it
15
+ * without any session lookup.
16
+ */
17
+ import { type LoggingLevel } from '@frontmcp/protocol';
18
+ /** True when `level` is at least as severe as the client's requested minimum. */
19
+ export declare function meetsLogLevel(level: LoggingLevel, minimum: LoggingLevel): boolean;
20
+ export interface QueuedRequestNotification {
21
+ method: string;
22
+ params: Record<string, unknown>;
23
+ }
24
+ /**
25
+ * Collects notifications raised while handling one request and hands them to
26
+ * the transport in arrival order.
27
+ *
28
+ * Deliberately unbounded-but-drained: the transport consumes as it streams, and
29
+ * a request that ends without streaming simply discards what it buffered (a
30
+ * client that asked for neither logs nor progress gets neither).
31
+ */
32
+ export declare class RequestNotificationSink {
33
+ /** Minimum severity the client opted into, or undefined for "no logs". */
34
+ private readonly logLevel;
35
+ /** Progress token from `_meta`, or undefined for "no progress". */
36
+ private readonly progressToken;
37
+ private readonly queue;
38
+ private wake;
39
+ private finished;
40
+ constructor(
41
+ /** Minimum severity the client opted into, or undefined for "no logs". */
42
+ logLevel: LoggingLevel | undefined,
43
+ /** Progress token from `_meta`, or undefined for "no progress". */
44
+ progressToken: string | number | undefined);
45
+ /** True when the client opted into anything at all. */
46
+ get active(): boolean;
47
+ /**
48
+ * Queue a log message.
49
+ *
50
+ * Dropped outright when the client did not set `logLevel` — the spec makes
51
+ * that a MUST NOT, not a preference.
52
+ */
53
+ log(level: LoggingLevel, logger: string | undefined, data: unknown): boolean;
54
+ /** Queue a progress notification, if the client supplied a progress token. */
55
+ progress(progress: number, total?: number, message?: string): boolean;
56
+ private push;
57
+ /** Everything queued so far, cleared from the sink. */
58
+ drain(): QueuedRequestNotification[];
59
+ /** Signal that no further notifications will be raised. */
60
+ close(): void;
61
+ /**
62
+ * Wait until something is queued or the sink closes.
63
+ *
64
+ * Returns immediately when work is already pending, so a fast producer never
65
+ * makes the consumer sleep on a non-empty queue.
66
+ */
67
+ waitForActivity(): Promise<void>;
68
+ get closed(): boolean;
69
+ }
70
+ //# sourceMappingURL=request-notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-notifications.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/request-notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAKjF;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,qBAAa,uBAAuB;IAMhC,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,mEAAmE;IACnE,OAAO,CAAC,QAAQ,CAAC,aAAa;IARhC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAmC;IACzD,OAAO,CAAC,IAAI,CAA2B;IACvC,OAAO,CAAC,QAAQ,CAAS;;IAGvB,0EAA0E;IACzD,QAAQ,EAAE,YAAY,GAAG,SAAS;IACnD,mEAAmE;IAClD,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAG7D,uDAAuD;IACvD,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO;IAY5E,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;IAYrE,OAAO,CAAC,IAAI;IAMZ,uDAAuD;IACvD,KAAK,IAAI,yBAAyB,EAAE;IAIpC,2DAA2D;IAC3D,KAAK,IAAI,IAAI;IAKb;;;;;OAKG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAUtC,IAAI,MAAM,IAAI,OAAO,CAEpB;CACF"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Integrity-protected `requestState` for MRTR — protocol 2026-07-28, SEP-2322.
3
+ *
4
+ * The spec is explicit that `requestState` round-trips through the client and
5
+ * MUST therefore be treated as attacker-controlled input:
6
+ *
7
+ * > If `requestState` influences authorization, resource access, or business
8
+ * > logic, servers **MUST** protect its integrity (e.g. HMAC or AEAD) and
9
+ * > **MUST** reject state that fails verification.
10
+ *
11
+ * It also asks servers to bound replay by binding the state to
12
+ * the authenticated principal, a short expiry, and the originating request.
13
+ * All three are enforced here — a blob minted for user A's `tools/call echo`
14
+ * is rejected if it comes back from user B, after it expires, or on a
15
+ * different call.
16
+ *
17
+ * Format: `<base64url(payload JSON)>.<base64url(HMAC-SHA256)>`.
18
+ */
19
+ import { type InputResponses } from '@frontmcp/protocol';
20
+ /** How long a minted state stays redeemable. */
21
+ export declare const DEFAULT_REQUEST_STATE_TTL_MS: number;
22
+ /**
23
+ * Largest `requestState` this server will even attempt to verify.
24
+ *
25
+ * The blob is attacker-controlled and reaches an HMAC before anything else can
26
+ * reject it, so an unbounded value would let a client burn CPU at will. 256 KiB
27
+ * is far above any legitimate accumulation of `InputResponses` (sampling
28
+ * completions are the biggest realistic contributor) while keeping the work per
29
+ * request bounded.
30
+ */
31
+ export declare const MAX_REQUEST_STATE_BYTES: number;
32
+ export interface RequestStateBinding {
33
+ /** Authenticated principal, or a stable stand-in for anonymous callers. */
34
+ principal: string;
35
+ /** Digest of the originating request (see {@link computeRequestBinding}). */
36
+ binding: string;
37
+ }
38
+ export type RequestStateDecodeResult = {
39
+ ok: true;
40
+ responses: InputResponses;
41
+ } | {
42
+ ok: false;
43
+ reason: 'absent' | 'malformed' | 'bad-signature' | 'expired' | 'principal-mismatch' | 'request-mismatch';
44
+ };
45
+ /**
46
+ * Resolve the HMAC key.
47
+ *
48
+ * Mirrors the credential vault's pepper resolution (`VAULT_SECRET ?? JWT_SECRET`,
49
+ * then a random per-process value) so a multi-node deployment that already
50
+ * configures one of those secrets gets cross-node-verifiable state for free.
51
+ * Without a configured secret the key is per-process, which still blocks
52
+ * tampering but makes state non-portable across nodes — acceptable because a
53
+ * rejected state only costs the client one extra round trip.
54
+ */
55
+ export declare function getRequestStateKey(): Uint8Array;
56
+ /**
57
+ * Bind state to the request that produced it.
58
+ *
59
+ * Uses the method plus the identity-bearing params (tool/prompt name, resource
60
+ * URI, arguments) — deliberately excluding `_meta`, `inputResponses` and
61
+ * `requestState` itself, all of which legitimately differ between the initial
62
+ * request and the retry.
63
+ */
64
+ export declare function computeRequestBinding(method: string, params: Record<string, unknown> | undefined): string;
65
+ /** Mint an integrity-protected `requestState`. */
66
+ export declare function encodeRequestState(responses: InputResponses, binding: RequestStateBinding, ttlMs?: number): string;
67
+ /**
68
+ * Verify and decode a client-echoed `requestState`.
69
+ *
70
+ * Every failure mode is distinguished so callers can log the cause, but they
71
+ * all lead to the same outcome for the client: the exchange restarts. Returning
72
+ * an error instead would strand a caller whose only mistake was letting the
73
+ * state expire.
74
+ */
75
+ export declare function decodeRequestState(state: unknown, expected: RequestStateBinding): RequestStateDecodeResult;
76
+ //# sourceMappingURL=request-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-state.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/request-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,QAAiB,CAAC;AAE3D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAalD,MAAM,WAAW,mBAAmB;IAClC,2EAA2E;IAC3E,SAAS,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GACvC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,eAAe,GAAG,SAAS,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;CAC1G,CAAC;AAIN;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CAK/C;AAOD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAMzG;AAyBD,kDAAkD;AAClD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,cAAc,EACzB,OAAO,EAAE,mBAAmB,EAC5B,KAAK,GAAE,MAAqC,GAC3C,MAAM,CASR;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,GAAG,wBAAwB,CA8B1G"}
@@ -0,0 +1,83 @@
1
+ export interface JsonRpcErrorPayload {
2
+ code: number;
3
+ message: string;
4
+ data?: unknown;
5
+ }
6
+ export type ValidationFailure = {
7
+ ok: false;
8
+ status: number;
9
+ error: JsonRpcErrorPayload;
10
+ };
11
+ export type ValidationSuccess = {
12
+ ok: true;
13
+ version: string;
14
+ };
15
+ export type ValidationResult = ValidationSuccess | ValidationFailure;
16
+ /** Case-insensitive header read across the shapes Node/Express/Web produce. */
17
+ export declare function readHeader(headers: Record<string, unknown> | undefined, name: string): string | undefined;
18
+ /** All `Mcp-Param-*` headers, keyed by the lowercased suffix after the prefix. */
19
+ export declare function readParamHeaders(headers: Record<string, unknown> | undefined): Map<string, string>;
20
+ /**
21
+ * Decide whether this request belongs to the 2026-07-28 pipeline.
22
+ *
23
+ * Claimed when ANY of:
24
+ * - the body declares a version via the 2026-only `_meta` key (present only in
25
+ * this revision, so its presence is unambiguous);
26
+ * - the `MCP-Protocol-Version` header names something that is not a revision the
27
+ * legacy pipeline knows (so an unknown/future version gets a proper
28
+ * `-32022` instead of a confusing session error);
29
+ * - the method exists only in this revision.
30
+ */
31
+ export declare function declaresProtocol20260728(params: {
32
+ headers: Record<string, unknown> | undefined;
33
+ body: unknown;
34
+ }): boolean;
35
+ export declare function isProtocol20260728Request(params: {
36
+ headers: Record<string, unknown> | undefined;
37
+ body: unknown;
38
+ /**
39
+ * Revision to assume for a request that identifies none. Defaults to
40
+ * `'legacy'`, so an unconfigured deployment behaves exactly as before.
41
+ */
42
+ defaultVersion?: '2026-07-28' | 'legacy';
43
+ }): boolean;
44
+ /**
45
+ * Walk a JSON Schema and collect `x-mcp-header` annotations.
46
+ *
47
+ * Only *statically reachable* properties count — the chain must consist purely
48
+ * of `properties` keys. An annotation behind `items`, `$ref`, or a composition
49
+ * keyword is invalid per the spec and is ignored here rather than being
50
+ * enforced against the client.
51
+ */
52
+ export declare function collectHeaderParams(schema: unknown, path?: string[], out?: Map<string, string[]>): Map<string, string[]>;
53
+ export interface Validate20260728Options {
54
+ headers: Record<string, unknown> | undefined;
55
+ body: Record<string, unknown>;
56
+ /** Resolves a tool's input JSON Schema so `x-mcp-header` can be validated. */
57
+ lookupToolSchema?: (toolName: string) => Record<string, unknown> | null | undefined;
58
+ /**
59
+ * Enforce the mirrored-header contract.
60
+ *
61
+ * `true` when the CLIENT declared 2026-07-28 — it opted into SEP-2243, so the
62
+ * headers are required and a mismatch is a hard error.
63
+ *
64
+ * `false` when the SERVER defaulted to this revision for a request that named
65
+ * none (see `transport.defaultProtocolVersion`). Such a client never agreed to
66
+ * send the headers, so requiring them would turn a working call into a `400`.
67
+ * Headers that ARE present are still validated — a disagreement is a genuine
68
+ * routing hazard either way.
69
+ */
70
+ strictHeaders?: boolean;
71
+ }
72
+ /**
73
+ * Validate a claimed 2026-07-28 request.
74
+ *
75
+ * Order matters and mirrors the spec's own precedence: transport-level header
76
+ * presence/agreement first, then version support, then the per-method mirrored
77
+ * values. That way a client sending a wrong version AND a wrong method header
78
+ * learns about the version first, which is the actionable one.
79
+ */
80
+ export declare function validate20260728Request(options: Validate20260728Options): ValidationResult;
81
+ /** The revision this pipeline implements — exported for callers building results. */
82
+ export declare const IMPLEMENTED_PROTOCOL_VERSION: "2026-07-28";
83
+ //# sourceMappingURL=request-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-validation.d.ts","sourceRoot":"","sources":["../../../src/transport/mcp-20260728/request-validation.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG;I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