@hop-top/kit 0.5.0-alpha.0 → 0.5.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. package/CHANGELOG.md +262 -0
  2. package/LICENSE +1 -1
  3. package/LICENSE-cobra.txt +174 -0
  4. package/NOTICE +15 -0
  5. package/README.md +55 -259
  6. package/dist/aim-DZHwwiIc.d.ts +139 -0
  7. package/dist/aim.d.ts +1 -116
  8. package/dist/aim.js +13 -414
  9. package/dist/alias-D9_qFlyP.d.ts +174 -0
  10. package/dist/alias.d.ts +2 -73
  11. package/dist/alias.js +27 -207
  12. package/dist/api-DAexsu2H.d.ts +77 -0
  13. package/dist/api.d.ts +1 -62
  14. package/dist/api.js +10 -164
  15. package/dist/auth-2-jfgiHn.d.ts +34 -0
  16. package/dist/auth.d.ts +1 -26
  17. package/dist/auth.js +6 -40
  18. package/dist/chunk-2JV3A7OP.js +1894 -0
  19. package/dist/chunk-3FIKGFKI.js +54 -0
  20. package/dist/chunk-4UE5TCMQ.js +104 -0
  21. package/dist/chunk-6HFAEZ52.js +29 -0
  22. package/dist/chunk-6SVOHNIC.js +17 -0
  23. package/dist/chunk-72XZWQX7.js +504 -0
  24. package/dist/chunk-ABQSE7AI.js +513 -0
  25. package/dist/chunk-BDNNPRX6.js +41 -0
  26. package/dist/chunk-BLS2OBIQ.js +263 -0
  27. package/dist/chunk-BRNEKPWX.js +37 -0
  28. package/dist/chunk-CSJWB6D3.js +151 -0
  29. package/dist/chunk-GGWJRWWA.js +309 -0
  30. package/dist/chunk-GHPJJV5L.js +613 -0
  31. package/dist/chunk-IXVQ62NZ.js +334 -0
  32. package/dist/chunk-JKMQSAJP.js +174 -0
  33. package/dist/chunk-JZ22ZUFA.js +1131 -0
  34. package/dist/chunk-K7VCKJ27.js +814 -0
  35. package/dist/chunk-KVG7YCTS.js +115 -0
  36. package/dist/chunk-L23O2FFE.js +51 -0
  37. package/dist/chunk-MQXYDYRD.js +968 -0
  38. package/dist/chunk-MUIQVU6E.js +251 -0
  39. package/dist/chunk-NLMS7HGP.js +178 -0
  40. package/dist/chunk-POR5L2DG.js +247 -0
  41. package/dist/chunk-PSFYJGDG.js +1445 -0
  42. package/dist/chunk-QJVSKKRQ.js +369 -0
  43. package/dist/chunk-QPUCXQXT.js +67 -0
  44. package/dist/chunk-QQQYCWSC.js +240 -0
  45. package/dist/chunk-R5U7XKVJ.js +16 -0
  46. package/dist/chunk-SNVGDYX7.js +187 -0
  47. package/dist/chunk-T46YPHKN.js +669 -0
  48. package/dist/chunk-UKZIAQA7.js +26 -0
  49. package/dist/chunk-WBVO43HU.js +355 -0
  50. package/dist/chunk-WUOAQVOA.js +86 -0
  51. package/dist/chunk-WWUKGJB5.js +90 -0
  52. package/dist/chunk-XJTRY453.js +868 -0
  53. package/dist/chunk-YGYQUFGY.js +219 -0
  54. package/dist/chunk-YOBAUCVN.js +583 -0
  55. package/dist/cli-C5B5tnpA.d.ts +400 -0
  56. package/dist/cli.d.ts +7 -309
  57. package/dist/cli.js +70 -885
  58. package/dist/completion-csVun6SP.d.ts +112 -0
  59. package/dist/completion-values-By-mnjNt.d.ts +142 -0
  60. package/dist/completion-values.d.ts +1 -0
  61. package/dist/completion-values.js +29 -0
  62. package/dist/completion.d.ts +3 -0
  63. package/dist/completion.js +34 -0
  64. package/dist/compliance-AxFf-uMy.d.ts +60 -0
  65. package/dist/compliance.d.ts +1 -0
  66. package/dist/compliance.js +17 -0
  67. package/dist/config-CaK60ByQ.d.ts +241 -0
  68. package/dist/config.d.ts +1 -97
  69. package/dist/config.js +8 -78
  70. package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
  71. package/dist/errcorrect.d.ts +1 -37
  72. package/dist/errcorrect.js +8 -68
  73. package/dist/error-Do8Qji43.d.ts +231 -0
  74. package/dist/id/index.d.ts +2 -83
  75. package/dist/id/index.js +14 -65
  76. package/dist/index-BKJZClJx.d.ts +1486 -0
  77. package/dist/index-C3Zw4wDJ.d.ts +359 -0
  78. package/dist/index-DCe1boBz.d.ts +328 -0
  79. package/dist/index-VLDcI5NF.d.ts +95 -0
  80. package/dist/index.d.ts +37 -0
  81. package/dist/index.js +132 -0
  82. package/dist/llm-DYuR7_uX.d.ts +1069 -0
  83. package/dist/llm-anthropic-Cd_I2xXB.d.ts +67 -0
  84. package/dist/llm-anthropic.d.ts +2 -0
  85. package/dist/llm-anthropic.js +13 -0
  86. package/dist/llm-openai-DyFrucmV.d.ts +87 -0
  87. package/dist/llm-openai.d.ts +2 -0
  88. package/dist/llm-openai.js +19 -0
  89. package/dist/llm.d.ts +1 -188
  90. package/dist/llm.js +101 -356
  91. package/dist/log-CkaxMX3U.d.ts +115 -0
  92. package/dist/log.d.ts +2 -0
  93. package/dist/log.js +14 -0
  94. package/dist/mcp/index.d.ts +4 -0
  95. package/dist/mcp/index.js +184 -0
  96. package/dist/netpolicy-Brx5XZUB.d.ts +151 -0
  97. package/dist/netpolicy.d.ts +1 -0
  98. package/dist/netpolicy.js +25 -0
  99. package/dist/output-CjZWmL8s.d.ts +420 -0
  100. package/dist/output.d.ts +3 -213
  101. package/dist/output.js +137 -447
  102. package/dist/parity-CvMuYcVI.d.ts +61 -0
  103. package/dist/progress-CAzyxeWl.d.ts +38 -0
  104. package/dist/progress.d.ts +1 -30
  105. package/dist/progress.js +6 -55
  106. package/dist/provenance-SMFHm5gx.d.ts +30 -0
  107. package/dist/provenance.d.ts +1 -24
  108. package/dist/provenance.js +6 -31
  109. package/dist/routellm-B0nv59mH.d.ts +111 -0
  110. package/dist/routellm.d.ts +2 -64
  111. package/dist/routellm.js +13 -255
  112. package/dist/rpc-D31Lg0Kc.d.ts +32 -0
  113. package/dist/rpc.d.ts +2 -25
  114. package/dist/rpc.js +4 -98
  115. package/dist/safety-CUaYEjZc.d.ts +30 -0
  116. package/dist/safety.d.ts +1 -24
  117. package/dist/safety.js +6 -43
  118. package/dist/scope-BrhYB4ij.d.ts +141 -0
  119. package/dist/scope.d.ts +1 -121
  120. package/dist/scope.js +20 -377
  121. package/dist/serve-D8yWMrTc.d.ts +646 -0
  122. package/dist/serve.d.ts +3 -0
  123. package/dist/serve.js +75 -0
  124. package/dist/sqlstore.js +6 -39
  125. package/dist/stream-CrjeCp0M.d.ts +44 -0
  126. package/dist/stream.d.ts +1 -35
  127. package/dist/stream.js +8 -51
  128. package/dist/telemetry/index.d.ts +1 -315
  129. package/dist/telemetry/index.js +26 -599
  130. package/dist/toolspec-DcPwwoAZ.d.ts +368 -0
  131. package/dist/toolspec.d.ts +2 -0
  132. package/dist/toolspec.js +37 -0
  133. package/dist/tui/index.d.ts +6 -298
  134. package/dist/tui/index.js +18 -322
  135. package/dist/upgrade-p_zh3pvV.d.ts +102 -0
  136. package/dist/upgrade.d.ts +1 -95
  137. package/dist/upgrade.js +6 -114
  138. package/dist/xdg-DB7Shoib.d.ts +179 -0
  139. package/dist/xdg.d.ts +1 -169
  140. package/dist/xdg.js +14 -128
  141. package/package.json +236 -46
  142. package/src/README.md +15 -0
  143. package/src/alias.conformance.test.ts +250 -0
  144. package/src/alias.test.ts +206 -2
  145. package/src/alias.ts +196 -21
  146. package/src/cli.help-command.test.ts +105 -0
  147. package/src/cli.offline.test.ts +93 -0
  148. package/src/cli.parity.test.ts +192 -0
  149. package/src/cli.test.ts +95 -1
  150. package/src/cli.ts +195 -25
  151. package/src/completion-scripts.ts +16 -0
  152. package/src/completion-values.test.ts +76 -16
  153. package/src/completion-values.ts +170 -66
  154. package/src/completion.conformance.test.ts +297 -0
  155. package/src/completion.test.ts +256 -145
  156. package/src/completion.ts +767 -121
  157. package/src/compliance.test.ts +196 -2
  158. package/src/compliance.ts +440 -20
  159. package/src/config-merge.test.ts +425 -0
  160. package/src/config.test.ts +228 -1
  161. package/src/config.ts +429 -16
  162. package/src/gen/crud_pb.ts +7 -7
  163. package/src/id/README.md +38 -0
  164. package/src/id/contract.test.ts +1 -1
  165. package/src/id/index.test.ts +1 -1
  166. package/src/id/index.ts +3 -2
  167. package/src/index.test.ts +71 -0
  168. package/src/index.ts +46 -0
  169. package/src/llm-anthropic.conformance.test.ts +1135 -0
  170. package/src/llm-anthropic.test.ts +152 -0
  171. package/src/llm-anthropic.ts +940 -0
  172. package/src/llm-choice-hermetic.test.ts +335 -0
  173. package/src/llm-config.test.ts +232 -0
  174. package/src/llm-config.ts +106 -0
  175. package/src/llm-endpoint.ts +254 -0
  176. package/src/llm-error.ts +17 -0
  177. package/src/llm-errors.ts +152 -0
  178. package/src/llm-file.ts +126 -0
  179. package/src/llm-http.ts +317 -0
  180. package/src/llm-keys.ts +167 -0
  181. package/src/llm-media.conformance.test.ts +87 -0
  182. package/src/llm-media.test.ts +279 -0
  183. package/src/llm-media.ts +322 -0
  184. package/src/llm-openai.conformance.test.ts +407 -0
  185. package/src/llm-openai.test.ts +510 -0
  186. package/src/llm-openai.ts +708 -0
  187. package/src/llm-payload.ts +155 -0
  188. package/src/llm-quote.ts +46 -0
  189. package/src/llm-routellm.conformance.test.ts +44 -0
  190. package/src/llm-toolnames.conformance.test.ts +112 -0
  191. package/src/llm-toolnames.test.ts +132 -0
  192. package/src/llm-toolnames.ts +298 -0
  193. package/src/llm-uri.ts +99 -0
  194. package/src/llm.test.ts +43 -15
  195. package/src/llm.toolcall.test.ts +175 -0
  196. package/src/llm.ts +602 -190
  197. package/src/log.parity.test.ts +105 -0
  198. package/src/log.test.ts +270 -1
  199. package/src/log.ts +228 -49
  200. package/src/mcp/README.md +63 -0
  201. package/src/mcp/args-separator.test.ts +164 -0
  202. package/src/mcp/args.test.ts +223 -0
  203. package/src/mcp/args.ts +160 -0
  204. package/src/mcp/audit.test.ts +520 -0
  205. package/src/mcp/audit.ts +70 -0
  206. package/src/mcp/bridge.test.ts +222 -0
  207. package/src/mcp/bridge.ts +291 -0
  208. package/src/mcp/conformance.test.ts +357 -0
  209. package/src/mcp/dispatch.ts +359 -0
  210. package/src/mcp/identity.test.ts +166 -0
  211. package/src/mcp/identity.ts +72 -0
  212. package/src/mcp/index.ts +176 -0
  213. package/src/mcp/legacy-notify.test.ts +59 -0
  214. package/src/mcp/legacy.ts +367 -0
  215. package/src/mcp/mcp.test.ts +707 -0
  216. package/src/mcp/modern-confirm.test.ts +520 -0
  217. package/src/mcp/modern-confirm.ts +484 -0
  218. package/src/mcp/modern.ts +788 -0
  219. package/src/mcp/stdio.test.ts +313 -0
  220. package/src/mcp/stdio.ts +254 -0
  221. package/src/mcp/tasks.ts +82 -0
  222. package/src/mcp/testtree.ts +250 -0
  223. package/src/mcp/toolname.test.ts +147 -0
  224. package/src/mcp/types.ts +689 -0
  225. package/src/netpolicy.test.ts +280 -0
  226. package/src/netpolicy.ts +256 -0
  227. package/src/output/README.md +46 -0
  228. package/src/output/builtins.ts +5 -5
  229. package/src/output/dispatch.ts +10 -2
  230. package/src/output/error.ts +459 -0
  231. package/src/output/formatter.ts +29 -5
  232. package/src/output/formatters/README.md +50 -0
  233. package/src/output/formatters/csv.ts +48 -12
  234. package/src/output/formatters/json.ts +4 -25
  235. package/src/output/formatters/project.ts +34 -0
  236. package/src/output/formatters/table.ts +8 -6
  237. package/src/output/formatters/text.ts +7 -3
  238. package/src/output/formatters/yaml.ts +5 -22
  239. package/src/output/projection.test.ts +298 -0
  240. package/src/output/projection.ts +33 -59
  241. package/src/output/template.ts +11 -21
  242. package/src/output.surface.test.ts +41 -0
  243. package/src/output.ts +64 -3
  244. package/src/published-types.test.ts +133 -0
  245. package/src/routellm.test.ts +209 -28
  246. package/src/routellm.toolcall.test.ts +521 -0
  247. package/src/routellm.ts +213 -177
  248. package/src/router/README.md +44 -0
  249. package/src/router/server.test.ts +41 -0
  250. package/src/router/server.ts +11 -0
  251. package/src/safety.test.ts +19 -9
  252. package/src/scope-defaults.json +29 -29
  253. package/src/serve.test.ts +1257 -0
  254. package/src/serve.ts +1665 -0
  255. package/src/telemetry/README.md +48 -0
  256. package/src/telemetry/client.test.ts +31 -0
  257. package/src/telemetry/client.ts +12 -6
  258. package/src/telemetry/offline.test.ts +64 -0
  259. package/src/toolspec-internal.ts +279 -0
  260. package/src/toolspec-manifest.test.ts +167 -0
  261. package/src/toolspec-manifest.ts +410 -0
  262. package/src/toolspec-spec-schemas.ts +12 -0
  263. package/src/toolspec-spec.test.ts +273 -0
  264. package/src/toolspec-spec.ts +458 -0
  265. package/src/toolspec.from-command.test.ts +350 -0
  266. package/src/toolspec.test.ts +2 -2
  267. package/src/toolspec.ts +222 -0
  268. package/src/triton/README.md +34 -0
  269. package/src/tui/README.md +42 -0
  270. package/src/tui/parity.test.ts +142 -0
  271. package/src/tui/parity.ts +59 -13
  272. package/src/wizard.test.ts +7 -7
  273. package/test/llm/conformance-helpers.ts +100 -0
  274. package/test/output/csv.test.ts +164 -0
  275. package/test/output/dispatch.test.ts +1 -2
  276. package/test/output/error.test.ts +277 -0
  277. package/test/output/smoke-capture.ts +2 -2
  278. package/test/output/smoke.test.ts +2 -2
  279. package/test/output/taxonomy-contract.test.ts +148 -0
  280. package/test/setup-env.ts +16 -0
  281. package/test/toolspec/fixture.ts +79 -0
  282. package/tsconfig.json +3 -1
  283. package/tsconfig.test.json +10 -0
  284. package/vitest.config.ts +9 -0
@@ -0,0 +1,1486 @@
1
+ import { ProtocolErrorCode } from '@modelcontextprotocol/server';
2
+ import { Readable, Writable } from 'node:stream';
3
+ import { Command } from 'commander';
4
+
5
+ /**
6
+ * @module mcp/types
7
+ * @package @hop-top/kit
8
+ *
9
+ * Shared vocabulary for the dual-spec MCP surface: the bridge
10
+ * abstraction the surface invokes through, the safety gate, the
11
+ * mount options, and the canonical JSON encoder that makes wire
12
+ * output byte-identical to the Go reference.
13
+ *
14
+ * Protocol constants are taken from the official v2 SDK
15
+ * (@modelcontextprotocol/server) rather than re-declared here, so a
16
+ * reserved key or spec error code can never drift from upstream. The
17
+ * v1 package (@modelcontextprotocol/sdk) is legacy-era only and
18
+ * cannot serve 2026-07-28 — it is deliberately not a dependency.
19
+ */
20
+
21
+ /** Reserved `params._meta` / result `_meta` keys (from the v2 SDK). */
22
+ declare const META_KEY_PROTOCOL_VERSION = "io.modelcontextprotocol/protocolVersion";
23
+ declare const META_KEY_CLIENT_INFO = "io.modelcontextprotocol/clientInfo";
24
+ declare const META_KEY_CLIENT_CAPABILITIES = "io.modelcontextprotocol/clientCapabilities";
25
+ declare const META_KEY_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
26
+ /** Header names carrying the modern routing signals. */
27
+ declare const HEADER_MCP_PROTOCOL_VERSION = "MCP-Protocol-Version";
28
+ declare const HEADER_MCP_METHOD = "Mcp-Method";
29
+ declare const HEADER_MCP_NAME = "Mcp-Name";
30
+ /**
31
+ * JSON-RPC error codes. The base codes and the two spec-reserved
32
+ * 2026-07-28 additions come from the SDK's ProtocolErrorCode;
33
+ * HeaderMismatch (-32020) is spec-reserved but absent from the SDK
34
+ * enum, so it is pinned here.
35
+ *
36
+ * The explicit enum-member annotations keep the declaration output a
37
+ * type reference. Inferred, it is `declare const X = ProtocolErrorCode.Y`,
38
+ * and the declaration bundler drops the `ProtocolErrorCode` import an
39
+ * initializer needs, leaving consumers an unresolved name (TS2304).
40
+ */
41
+ declare const MCP_ERR_PARSE: ProtocolErrorCode.ParseError;
42
+ declare const MCP_ERR_INVALID_REQUEST: ProtocolErrorCode.InvalidRequest;
43
+ declare const MCP_ERR_METHOD_NOT_FOUND: ProtocolErrorCode.MethodNotFound;
44
+ declare const MCP_ERR_INVALID_PARAMS: ProtocolErrorCode.InvalidParams;
45
+ declare const MCP_ERR_INTERNAL: ProtocolErrorCode.InternalError;
46
+ declare const MCP_ERR_HEADER_MISMATCH = -32020;
47
+ declare const MCP_ERR_MISSING_CLIENT_CAPABILITY: ProtocolErrorCode.MissingRequiredClientCapability;
48
+ declare const MCP_ERR_UNSUPPORTED_VERSION: ProtocolErrorCode.UnsupportedProtocolVersion;
49
+ /** The two protocol revisions this surface serves. */
50
+ declare const MCP_SPEC_2024_11_05 = "2024-11-05";
51
+ declare const MCP_SPEC_2026_07_28 = "2026-07-28";
52
+ type McpSpecVersion = typeof MCP_SPEC_2024_11_05 | typeof MCP_SPEC_2026_07_28;
53
+ /** resultType discriminator values on modern result envelopes. */
54
+ declare const RESULT_TYPE_COMPLETE = "complete";
55
+ declare const RESULT_TYPE_INPUT_REQUIRED = "input_required";
56
+ /** cacheScope values on modern cacheable list results. */
57
+ type McpCacheScope = 'public' | 'private';
58
+ /** Default server identity, matching Go's cmdsurface defaults. */
59
+ declare const DEFAULT_MCP_SERVER_NAME = "cmdsurface";
60
+ declare const DEFAULT_MCP_SERVER_VERSION = "0.0.0";
61
+ declare const DEFAULT_MCP_PATH = "/mcp";
62
+ /** Default string joining a leaf path into its MCP tool name. */
63
+ declare const DEFAULT_TOOL_NAME_SEPARATOR = ".";
64
+ /**
65
+ * Surfaces a leaf may be invoked through. Mirrors Go's Surface type;
66
+ * both MCP spec revisions share the single "mcp" surface — one
67
+ * mount, one exposure decision.
68
+ */
69
+ type Surface = 'cli' | 'lib' | 'mcp' | 'rest' | 'rpc' | 'ws' | 'bus';
70
+ declare const SURFACE_CLI: Surface;
71
+ declare const SURFACE_LIB: Surface;
72
+ declare const SURFACE_MCP: Surface;
73
+ /**
74
+ * SafetyClass is the bridge's read of a leaf's safety annotations —
75
+ * the input the policy gate consults. Mirrors Go's SafetyClass.
76
+ */
77
+ interface SafetyClass {
78
+ /** Set for the destructive kit/side-effect tiers. */
79
+ destructive?: boolean;
80
+ /** Set when kit/auth-required is "true". */
81
+ authRequired?: boolean;
82
+ /** Set when kit/requires-confirmation is "true". */
83
+ requiresConfirmation?: boolean;
84
+ permissions?: string[];
85
+ exitCodes?: string[];
86
+ }
87
+ /**
88
+ * Policy gates which Surface may invoke a leaf of a given
89
+ * SafetyClass. Ported from Go's cmdsurface Policy — NOT from
90
+ * src/safety.ts, which implements the unrelated Factor 10 CLI
91
+ * `--force` guard and has no bearing on surface exposure.
92
+ */
93
+ interface Policy {
94
+ /**
95
+ * Surfaces on which destructive leaves MAY be invoked. CLI and Lib
96
+ * are always allowed regardless. Empty = block all remote
97
+ * destructive invocation (the default).
98
+ */
99
+ allowDestructiveOn?: Surface[];
100
+ /** Surfaces a leaf is exposed on when its config omits `enabled`. */
101
+ defaultEnabled?: Surface[];
102
+ }
103
+ /**
104
+ * The conservative default policy: no remote surface may invoke a
105
+ * destructive command; default enablement is CLI + Lib + MCP.
106
+ * `allowDestructiveOn` is deliberately empty — empty means block-all,
107
+ * not allow-all.
108
+ */
109
+ declare function defaultPolicy(): Policy;
110
+ /**
111
+ * Reports whether `cls` may be invoked via surface `s` under `p`.
112
+ *
113
+ * 1. cli and lib are always allowed (local runtime).
114
+ * 2. Non-destructive commands are allowed on every other surface.
115
+ * 3. Destructive commands are allowed only when `s` is listed in
116
+ * `allowDestructiveOn`.
117
+ *
118
+ * Surface enablement (per-leaf opt-in) is gated separately; this
119
+ * enforces only the destructive ceiling.
120
+ */
121
+ declare function policyAllowed(p: Policy, cls: SafetyClass, s: Surface): boolean;
122
+ /** Error a bridge raises when the policy gate blocks a leaf. */
123
+ declare class DestructiveBlockedError extends Error {
124
+ constructor(pathLabel: string, surface: Surface);
125
+ }
126
+ /** Error a bridge raises when a leaf path resolves to nothing. */
127
+ declare class UnknownCommandError extends Error {
128
+ constructor(message?: string);
129
+ }
130
+ /** Error a bridge raises when a leaf is not exposed on the surface. */
131
+ declare class SurfaceNotEnabledError extends Error {
132
+ constructor(message?: string);
133
+ }
134
+ /** A JSON Schema property object describing one flag. */
135
+ interface FlagSchema {
136
+ type: string;
137
+ description: string;
138
+ items?: {
139
+ type: string;
140
+ enum?: string[];
141
+ };
142
+ /** Allowed values, when the flag declares choices. */
143
+ enum?: string[];
144
+ /** The flag's default, when it is a value of `type`. */
145
+ default?: unknown;
146
+ /** Least array length; set on the positional "args" property. */
147
+ minItems?: number;
148
+ }
149
+ /** One declared positional argument of a leaf, in declared order. */
150
+ interface LeafArg {
151
+ name: string;
152
+ /** False/absent for an optional argument. */
153
+ required?: boolean;
154
+ /**
155
+ * True for a `<name...>` / `[name...]` argument: it takes every
156
+ * remaining operand. Informational; the published "args" array
157
+ * carries no maxItems either way.
158
+ */
159
+ variadic?: boolean;
160
+ }
161
+ /**
162
+ * One invocable leaf command exposed as an MCP tool. `path` is the
163
+ * leaf's command path; the MCP tool name is the dotted join.
164
+ */
165
+ interface Leaf {
166
+ /** Command path, e.g. ["widget","add"] → tool "widget.add". */
167
+ path: string[];
168
+ /** Short description, used as the tool description. */
169
+ description: string;
170
+ /** JSON Schema properties derived from the leaf's flags. */
171
+ properties: Record<string, FlagSchema>;
172
+ /** Names of required flags, in declaration order. */
173
+ required?: string[];
174
+ /**
175
+ * Declared positional arguments, in order. Published as one "args"
176
+ * string-array property and split back out of tools/call arguments
177
+ * into `Invocation.args` (see mcp/args).
178
+ */
179
+ args?: LeafArg[];
180
+ /** Safety annotations consulted by the policy gate. */
181
+ class?: SafetyClass;
182
+ /** Surfaces this leaf is exposed on. */
183
+ enabled?: Partial<Record<Surface, boolean>>;
184
+ }
185
+ /**
186
+ * How the surface established a caller, as recorded in
187
+ * `InvocationMeta.established`. Mirrors Go's `cmdsurface.Establishment`:
188
+ * `verified` means the mount's verifier accepted a credential the
189
+ * request presented. Absent means nothing was established; any caller
190
+ * the request claims is a claim, not an identity.
191
+ */
192
+ type McpEstablishment = 'verified';
193
+ /** Metadata attached to one invocation, forwarded to audit sinks. */
194
+ interface InvocationMeta {
195
+ surface: Surface;
196
+ requestedAt: Date;
197
+ /**
198
+ * The principal the mount's verifier established. Never taken from
199
+ * the request body or headers.
200
+ */
201
+ caller?: string;
202
+ /** The tenant the verifier established, when it named one. */
203
+ tenant?: string;
204
+ /** Set only when the verifier established the caller. */
205
+ established?: McpEstablishment;
206
+ /**
207
+ * Free-form audit bag; the modern path records spec + client info.
208
+ * `scopes` (comma-joined) comes only from the verifier.
209
+ */
210
+ extra?: Record<string, string>;
211
+ }
212
+ /** One leaf invocation. */
213
+ interface Invocation {
214
+ path: string[];
215
+ /** Positional arguments in declared order, from the "args" property. */
216
+ args?: string[];
217
+ flags?: Record<string, unknown>;
218
+ meta: InvocationMeta;
219
+ }
220
+ /** The result of invoking a leaf. */
221
+ interface InvokeResult {
222
+ stdout: string;
223
+ stderr?: string;
224
+ exitCode: number;
225
+ /** Structured payload; becomes structuredContent on the modern path. */
226
+ data?: unknown;
227
+ }
228
+ /**
229
+ * The command-tree abstraction the MCP surface serves. Adopters
230
+ * implement this over their own command framework (see
231
+ * `commanderBridge` for a commander adapter); the surface itself
232
+ * never touches commander, so it stays framework-free.
233
+ */
234
+ interface McpBridge {
235
+ /** Every leaf known to the bridge, in stable enumeration order. */
236
+ leaves(): Leaf[];
237
+ /**
238
+ * Invokes one leaf. MUST apply the policy gate and throw
239
+ * DestructiveBlockedError when it blocks, so both eras inherit the
240
+ * identical destructive ceiling from one code path.
241
+ */
242
+ invoke(inv: Invocation): Promise<InvokeResult> | InvokeResult;
243
+ }
244
+ /**
245
+ * The caller a verifier established for one request. Mirrors the Go
246
+ * surfaces' `Meta` identity: `caller` is the stable principal (a user
247
+ * id, a service account, a client id), `tenant` the account it acts
248
+ * in, `scopes` what it was granted. All optional: a verifier may
249
+ * accept a credential that names no principal.
250
+ */
251
+ interface McpIdentity {
252
+ caller?: string;
253
+ tenant?: string;
254
+ scopes?: string[];
255
+ }
256
+ /**
257
+ * Establishes who is calling. The mount calls it once per `tools/call`
258
+ * with the request as received; it checks a credential the request
259
+ * presents (a bearer token, a signed header) and returns the caller,
260
+ * or `null`/`undefined` to refuse. Throwing refuses too.
261
+ *
262
+ * Only an identity a verifier returns authenticates a call: a
263
+ * `kit/auth-required` leaf is refused with 401 unless it does. An
264
+ * `Authorization` header is presence, not verification, and a caller
265
+ * or scopes the request claims in its body never become identity.
266
+ */
267
+ type McpVerifier = (req: McpHttpRequest) => McpIdentity | null | undefined | Promise<McpIdentity | null | undefined>;
268
+ /** The challenge a 401 carries in WWW-Authenticate, as Go's api.DefaultAuthChallenge. */
269
+ declare const MCP_AUTH_CHALLENGE = "Bearer";
270
+ /**
271
+ * One refusal the surface decided before adopter code ran: the record
272
+ * Go's bridge sinks receive from the MCP surface, reduced to the
273
+ * fields the surface has (a `cmdsurface.Invocation` subset plus the
274
+ * error). No caller, arguments or flags travel on it, so there is
275
+ * nothing to redact.
276
+ */
277
+ interface McpAuditRecord {
278
+ /** The resolved leaf path, e.g. `["widget","delete"]`. */
279
+ path: string[];
280
+ surface: 'mcp';
281
+ /** When the refusal was decided. */
282
+ requestedAt: Date;
283
+ /** The protocol revision serving the request. */
284
+ specVersion: string;
285
+ /**
286
+ * Go's sentinel error message for the event, verbatim (see the
287
+ * `MCP_AUDIT_*` constants in `mcp/audit`).
288
+ */
289
+ error: string;
290
+ /**
291
+ * Always `mcp_spec_version`; `mcp_confirm_rejection` on a rejected
292
+ * `requestState`. Keys are the Go snake_case strings so the records
293
+ * forward to the same audit backends.
294
+ */
295
+ extra: Record<string, string>;
296
+ }
297
+ /**
298
+ * The mount-level audit hook. Called synchronously once per refusal,
299
+ * after the refusal is decided and before the response is returned.
300
+ * Best-effort: a throwing hook never changes the wire response.
301
+ */
302
+ type McpAuditHook = (record: McpAuditRecord) => void;
303
+ /**
304
+ * Mount options, mirroring Go's MountMCP option set. Defaults match
305
+ * Go exactly: both eras, path "/mcp", empty origin allowlist, cache
306
+ * hints ttlMs=0 / cacheScope="private".
307
+ */
308
+ interface McpMountOptions {
309
+ /** Mount path. Default "/mcp". */
310
+ path?: string;
311
+ /** Server identity in serverInfo. */
312
+ serverInfo?: {
313
+ name: string;
314
+ version: string;
315
+ };
316
+ /**
317
+ * Which eras this mount serves. Absent = both. An explicit empty
318
+ * array, or an unrecognized version, is a mount-time error.
319
+ */
320
+ specVersions?: McpSpecVersion[];
321
+ /** ttlMs + cacheScope on modern cacheable list results. */
322
+ cacheHints?: {
323
+ ttlMs?: number;
324
+ cacheScope?: McpCacheScope;
325
+ };
326
+ /** Exact-match Origin allowlist; absent = no Origin check. */
327
+ originAllowlist?: string[];
328
+ /** HMAC key enabling the MRTR confirmation flow. Must be non-empty. */
329
+ confirmationKey?: Uint8Array | string;
330
+ /** Policy gate. Default: defaultPolicy(). */
331
+ policy?: Policy;
332
+ /**
333
+ * Establishes the caller of each `tools/call`. Without one no call
334
+ * is established, so every `kit/auth-required` leaf is refused.
335
+ */
336
+ verifier?: McpVerifier;
337
+ /**
338
+ * Joins a leaf path into its tool name, and splits a called name
339
+ * back. Default ".". `"_"` names the leaf `widget add` `widget_add`,
340
+ * for hosts that admit only `^[A-Za-z0-9_-]{1,64}$`. Empty is a
341
+ * mount-time error, and so is any separator but the default that a
342
+ * command name contains: the name would not map back to one leaf.
343
+ */
344
+ toolNameSeparator?: string;
345
+ /**
346
+ * Receives one {@link McpAuditRecord} per refusal the surface
347
+ * decides: auth refused, confirmation required / declined / state
348
+ * rejected, destructive ceiling. The counterpart of Go's bridge
349
+ * sinks for the MCP surface. Best-effort: it runs after the refusal
350
+ * is decided, before the response is returned, and a throw is
351
+ * swallowed.
352
+ */
353
+ audit?: McpAuditHook;
354
+ }
355
+ /** Resolved, validated mount configuration. */
356
+ interface ResolvedMcpConfig {
357
+ path: string;
358
+ serverName: string;
359
+ serverVersion: string;
360
+ legacyEnabled: boolean;
361
+ modernEnabled: boolean;
362
+ cacheTtlMs: number;
363
+ cacheScope: McpCacheScope;
364
+ originAllowlist: string[];
365
+ confirmationKey?: Uint8Array;
366
+ policy: Policy;
367
+ verifier?: McpVerifier;
368
+ toolNameSeparator: string;
369
+ audit?: McpAuditHook;
370
+ }
371
+ /**
372
+ * Validates and resolves mount options. Reproduces Go's two
373
+ * mount-time errors rather than silently absorbing them: an explicit
374
+ * empty spec-version set, and a negative ttl or unrecognized scope.
375
+ */
376
+ declare function resolveMcpConfig(opts?: McpMountOptions): ResolvedMcpConfig;
377
+ /** Renders a leaf path as an MCP tool name, joined with `separator`. */
378
+ declare function toolName(path: string[], separator?: string): string;
379
+ /** Splits an MCP tool name back into a leaf path on `separator`. */
380
+ declare function pathFromToolName(name: string, separator?: string): string[];
381
+ /** Renders one leaf as an MCP tool descriptor (shared by both eras). */
382
+ declare function buildToolEnvelope(leaf: Leaf, separator?: string): Record<string, unknown>;
383
+ /**
384
+ * Renders a bridge result as the tools/call content block list.
385
+ * Shared verbatim by both eras so content layout cannot drift:
386
+ * stdout text block, "[stderr] " block when present, JSON text block
387
+ * when `data` is present.
388
+ */
389
+ declare function renderCallResult(res: InvokeResult): Record<string, unknown>;
390
+ /** A tools/call result envelope flagged isError with one text block. */
391
+ declare function errorResultBlock(msg: string): Record<string, unknown>;
392
+ /**
393
+ * A pre-serialized JSON fragment emitted verbatim. Used to echo a
394
+ * request `id` back exactly as received (including `null`, which Go
395
+ * round-trips byte-for-byte through json.RawMessage).
396
+ */
397
+ declare class RawJSON {
398
+ readonly raw: string;
399
+ constructor(raw: string);
400
+ }
401
+ /**
402
+ * Serializes a value the way Go's encoding/json does for the shapes
403
+ * this surface emits, so wire output is byte-identical to the Go
404
+ * reference rather than merely structurally equal — the fixtures
405
+ * compare bytes, with no decode/re-encode step.
406
+ *
407
+ * Go's rule is not "sort everything": `encoding/json` emits STRUCT
408
+ * fields in declaration order and MAP keys in sorted order. This
409
+ * surface builds result bodies as map[string]any (sorted) inside a
410
+ * jsonRPCResponse struct (declaration order), so the encoder mirrors
411
+ * exactly that split: plain objects are sorted, and the response
412
+ * envelope is emitted through `encodeEnvelope` below, which pins
413
+ * field order. Sorting is by UTF-16 code unit (the JS default),
414
+ * which agrees with Go's byte-wise sort over the ASCII keys emitted
415
+ * here.
416
+ */
417
+ declare function canonicalJSONStringify(value: unknown): string;
418
+ /** A JSON-RPC error object, emitted in Go struct-field order. */
419
+ interface JsonRpcErrorObject {
420
+ code: number;
421
+ message: string;
422
+ data?: unknown;
423
+ }
424
+ /**
425
+ * Encodes one JSON-RPC response envelope with Go's struct field
426
+ * order — `jsonrpc`, `id`, then `result` or `error` — and a trailing
427
+ * newline, matching json.Encoder.Encode. `id` is omitted entirely
428
+ * when absent (Go's `omitempty` on a nil json.RawMessage) but
429
+ * emitted as `null` when the request carried an explicit null id.
430
+ */
431
+ declare function encodeEnvelope(env: {
432
+ id?: RawJSON;
433
+ result?: unknown;
434
+ error?: JsonRpcErrorObject;
435
+ }): string;
436
+
437
+ /**
438
+ * @module mcp/dispatch
439
+ * @package @hop-top/kit
440
+ *
441
+ * Era detection + dispatch for the dual-spec MCP surface, plus the
442
+ * framework-free handler export.
443
+ *
444
+ * Hosting model (serve-mcp-from-any-sdk.md): this module exports a
445
+ * transport-agnostic request handler, not a server. Binding it to
446
+ * node:http, hono, express, fastify, or a Worker is the adopter's
447
+ * job — kit does not own the adopter's HTTP stack, and a pure
448
+ * request→response function is directly testable against the wire
449
+ * fixtures with no socket.
450
+ *
451
+ * Detection implements expose-cli-over-mcp.md's normative rules literally: the
452
+ * marker set M1-M4, the two deliberate non-markers, and the
453
+ * precedence chain D1-D4. It deliberately does NOT delegate to the
454
+ * v2 SDK's own `classifyInboundRequest`: that classifier treats a
455
+ * modern `MCP-Protocol-Version` header as a routing signal and
456
+ * routes `initialize`-plus-modern-envelope to the modern era, both
457
+ * of which contradict those rules (and the wire fixtures, which are the
458
+ * parity contract). The SDK is still the source of the protocol
459
+ * constants and error codes — see types.ts.
460
+ */
461
+
462
+ /**
463
+ * A normalized inbound request: method, headers, and body bytes. A
464
+ * header may repeat, which the modern header checks treat as
465
+ * significant, so values may be an array.
466
+ */
467
+ interface McpHttpRequest {
468
+ /** HTTP method, e.g. "POST". */
469
+ method: string;
470
+ /** Header names are matched case-insensitively. */
471
+ headers?: Record<string, string | string[] | undefined>;
472
+ /** Raw body bytes, exactly as received — never re-encoded. */
473
+ body?: string;
474
+ }
475
+ /** A normalized response: status, headers, and body bytes. */
476
+ interface McpHttpResponse {
477
+ status: number;
478
+ headers: Record<string, string>;
479
+ body: string;
480
+ }
481
+ /**
482
+ * A decoded JSON-RPC request envelope. `id` is kept as a raw JSON
483
+ * fragment so it round-trips byte-for-byte (Go uses json.RawMessage
484
+ * for exactly this reason), and its absence is distinguishable from
485
+ * an explicit null.
486
+ */
487
+ interface JsonRpcRequest {
488
+ jsonrpc?: string;
489
+ id?: RawJSON;
490
+ method: string;
491
+ params?: unknown;
492
+ }
493
+ /** Which handler a request routes to. */
494
+ type McpEra = 'legacy' | 'modern';
495
+ /**
496
+ * The binding a dispatcher serves. `http` (Streamable HTTP) validates
497
+ * the 2026-07-28 routing headers against the body; `stdio` has no
498
+ * header layer, so the body is the only source of truth.
499
+ */
500
+ type McpTransport = 'http' | 'stdio';
501
+ /**
502
+ * Implements per-request era detection, precedence D1-D4.
503
+ * Never fails — it only classifies an already-parsed request; D1
504
+ * (parse) is the caller's responsibility.
505
+ *
506
+ * Markers:
507
+ * M1 — Mcp-Method header present
508
+ * M2 — Mcp-Name header present
509
+ * M3 — params._meta contains the reserved protocolVersion key
510
+ * (key presence only; the value is not inspected here)
511
+ * M4 — method == "server/discover"
512
+ *
513
+ * Deliberate non-markers, both of which are the subtle part and the
514
+ * most likely source of silent divergence:
515
+ * - Bare params._meta. 2024-11-05 clients legitimately send
516
+ * _meta.progressToken and OTel traceparent; only the reserved
517
+ * protocolVersion key signals modern.
518
+ * - The MCP-Protocol-Version header, at any value. It predates
519
+ * 2026-07-28, so clients that negotiated down to legacy send it
520
+ * on every subsequent request; treating it as a modern signal
521
+ * would serve their handshake and then brick the session.
522
+ */
523
+ declare function detectMcpEra(req: McpHttpRequest, rpc: JsonRpcRequest): McpEra;
524
+ /**
525
+ * M3: whether params._meta carries the reserved protocolVersion key.
526
+ * Only key presence is tested; the value is never inspected at
527
+ * detection time. Malformed or non-object params/_meta are treated as
528
+ * "no marker" — detection never fails, and shape errors are the
529
+ * handlers' business.
530
+ */
531
+ declare function hasModernMetaMarker(params: unknown): boolean;
532
+ /** A framework-free MCP request handler. */
533
+ type McpHandler = (req: McpHttpRequest) => Promise<McpHttpResponse>;
534
+ /**
535
+ * Builds the MCP handler for a bridge. Mirrors Go's
536
+ * `MountMCP(bridge, router, opts...)`, minus the router: the caller
537
+ * binds the returned function to whatever HTTP stack it uses.
538
+ *
539
+ * Defaults match Go exactly: both eras enabled, path "/mcp", empty
540
+ * origin allowlist, cache hints ttlMs=0 / cacheScope="private".
541
+ * The two mount-time errors are reproduced rather than absorbed —
542
+ * an explicit empty spec-version set, and a negative ttl or
543
+ * unrecognized cache scope, both throw here.
544
+ */
545
+ declare function createMcpHandler(bridge: McpBridge, opts?: McpMountOptions): McpHandler;
546
+ /** The resolved mount config for a handler, for adopters that need it. */
547
+ declare function mcpMountConfig(opts?: McpMountOptions): ResolvedMcpConfig;
548
+ /**
549
+ * Routes each request to exactly one era's handler. Holds no mutable
550
+ * per-request state; both handlers are safe to share concurrently.
551
+ */
552
+ declare class McpDispatcher {
553
+ private readonly cfg;
554
+ private readonly legacy;
555
+ private readonly modern;
556
+ constructor(bridge: McpBridge, cfg: ResolvedMcpConfig, transport?: McpTransport);
557
+ handle(req: McpHttpRequest): Promise<McpHttpResponse>;
558
+ /**
559
+ * Routes one already-parsed request to its era's handler (D2-D4).
560
+ * The transport-neutral core behind `handle`; stdio calls it directly
561
+ * after doing its own framing and parsing.
562
+ */
563
+ dispatch(req: McpHttpRequest, rpc: JsonRpcRequest): Promise<McpHttpResponse>;
564
+ }
565
+ /** The 405 GET/DELETE answer at the mount path. */
566
+ declare function methodNotAllowedResponse(): McpHttpResponse;
567
+ /**
568
+ * Parses one JSON-RPC request, preserving the `id` as raw bytes.
569
+ * Throws on unparseable JSON so the caller can render D1's -32700.
570
+ */
571
+ declare function parseJsonRpcRequest(body: string): JsonRpcRequest;
572
+
573
+ /**
574
+ * @module mcp/legacy
575
+ * @package @hop-top/kit
576
+ *
577
+ * The 2024-11-05 MCP handler: `initialize`, `ping`, `tools/list`,
578
+ * `tools/call`, plain JSON-RPC over one POST path, no sessions, no
579
+ * SSE.
580
+ *
581
+ * This module's wire output is byte-for-byte frozen. The dual-spec hard
582
+ * invariant is "2024-11-05 behavior is preserved byte-for-byte;
583
+ * additive only; no deprecation", and the three-way module split
584
+ * (legacy / modern / dispatch) exists precisely so a reviewer can
585
+ * confirm a modern-era change did not touch this file. Modern-era
586
+ * behavior belongs in modern.ts — never here. The refusal audit hook
587
+ * (mcp/audit) is the one deliberate addition: it observes the
588
+ * refusals this handler already makes and changes no byte of them.
589
+ */
590
+
591
+ /**
592
+ * The 2024-11-05 handler. Stateless across requests; holds only
593
+ * immutable mount configuration and the bridge.
594
+ */
595
+ declare class LegacyMcpHandler {
596
+ private readonly bridge;
597
+ private readonly cfg;
598
+ constructor(bridge: McpBridge, cfg: ResolvedMcpConfig);
599
+ /**
600
+ * Routes one already-parsed JSON-RPC request by method. An unknown
601
+ * method returns -32601 at HTTP 200 — today's behavior, preserved
602
+ * deliberately (the modern handler uses 404 instead; the asymmetry
603
+ * is required by byte-for-byte preservation).
604
+ */
605
+ serve(req: McpHttpRequest, rpc: JsonRpcRequest): Promise<McpHttpResponse>;
606
+ /** The minimal initialize response: version, capabilities, identity. */
607
+ private handleInitialize;
608
+ /** One tool envelope per leaf exposed on the MCP surface. */
609
+ private handleToolsList;
610
+ private exposedTools;
611
+ /**
612
+ * Resolves the leaf, applies the pre-flight auth + confirmation
613
+ * gates, and dispatches through the bridge. Unknown / not-enabled
614
+ * tools are JSON-RPC errors; every other failure (bridge errors,
615
+ * destructive blocks, non-zero exit codes) is an isError result.
616
+ */
617
+ private handleToolsCall;
618
+ /** Emits one 2024-11-05 refusal record to the mount's audit hook. */
619
+ private audit;
620
+ }
621
+
622
+ /**
623
+ * @module mcp/audit
624
+ * @package @hop-top/kit
625
+ *
626
+ * The refusal audit hook: the counterpart, for the MCP surface, of the
627
+ * bridge sinks Go's `cmdsurface` fans every refusal out to. Go audits
628
+ * each refusal the surface makes before adopter code runs (`Bridge.Audit`
629
+ * from `mcpsdk`'s gates and the bridge's own `refuse`); this port has no
630
+ * sink registry, so one mount-level hook receives the same record.
631
+ *
632
+ * Contract, shared by every kit SDK: the hook is called synchronously
633
+ * after the refusal is decided and before the response is returned (Go's
634
+ * order: audit, then respond); it is best-effort, so a throw is swallowed
635
+ * and the wire response is never affected; and the `error` field carries
636
+ * Go's sentinel message verbatim, so adopters forwarding to a backend
637
+ * that already receives Go's sinks see one vocabulary.
638
+ */
639
+
640
+ /** `cmdsurface.ErrAuthRefused`: a `kit/auth-required` leaf, no established caller. */
641
+ declare const MCP_AUDIT_AUTH_REFUSED = "cmdsurface: authentication refused";
642
+ /** `mcpsdk.ErrConfirmationRequired`: nothing satisfied the confirmation gate. */
643
+ declare const MCP_AUDIT_CONFIRMATION_REQUIRED = "mcpsdk: confirmation required";
644
+ /** `mcpsdk.ErrConfirmationDeclined`: the client's user declined or dismissed the question. */
645
+ declare const MCP_AUDIT_CONFIRMATION_DECLINED = "mcpsdk: confirmation declined";
646
+ /** `mcpsdk.ErrConfirmationStateRejected`: a presented `requestState` failed verification. */
647
+ declare const MCP_AUDIT_CONFIRMATION_STATE_REJECTED = "mcpsdk: confirmation requestState failed verification";
648
+ /** `cmdsurface.ErrDestructiveBlocked`: the leaf's destructiveness exceeds the policy ceiling. */
649
+ declare const MCP_AUDIT_DESTRUCTIVE_BLOCKED = "cmdsurface: destructive command blocked on this surface";
650
+ /** The `mcp_confirm_rejection` value a rejected `requestState` carries, as in Go. */
651
+ declare const MCP_CONFIRM_REJECTION_STATE = "request_state_verification_failed";
652
+ /**
653
+ * Emits one refusal record to `hook`, when there is one. Builds the
654
+ * record here so every call site carries the same shape: the surface
655
+ * pinned to `mcp`, the time the refusal was decided, and `extra`
656
+ * always carrying `mcp_spec_version` ahead of any event-specific key.
657
+ * A throwing hook is swallowed: audit must never turn a refusal into
658
+ * a different refusal.
659
+ */
660
+ declare function auditRefusal(hook: McpAuditHook | undefined, path: string[], specVersion: string, error: string, extra?: Record<string, string>): void;
661
+
662
+ /**
663
+ * @module mcp/stdio
664
+ * @package @hop-top/kit
665
+ *
666
+ * The stdio binding for the dual-spec MCP surface: newline-delimited
667
+ * JSON-RPC over a pair of byte streams (by default the process's
668
+ * stdin/stdout), driving the same era dispatch the HTTP handler uses.
669
+ *
670
+ * Wire rules (stdio binding, 2024-11-05 and 2026-07-28):
671
+ * - one JSON-RPC message per line; output lines carry no embedded
672
+ * newline, and the output stream carries nothing but protocol
673
+ * messages — diagnostics go to the log stream (stderr);
674
+ * - a notification (no `id` member) is never answered;
675
+ * - each message is a single request: a JSON array (a batch) is
676
+ * refused with -32600 and `id: null`;
677
+ * - a line that is not JSON is answered -32700 with `id: null`;
678
+ * - requests run concurrently, so replies may arrive out of order —
679
+ * each carries its request's id.
680
+ *
681
+ * stdio has no header layer: era detection uses the body markers only
682
+ * (`params._meta` protocolVersion, `server/discover`), and the
683
+ * 2026-07-28 header checks (V4, V6, V7) do not apply. Gates that read
684
+ * headers see none — see the MCP guide for what that means for
685
+ * auth-required and confirmation-gated tools.
686
+ */
687
+
688
+ /** Options for {@link serveStdio}. */
689
+ interface McpStdioOptions {
690
+ /** Where requests are read from. Default: `process.stdin`. */
691
+ input?: Readable;
692
+ /** Where replies are written. Default: `process.stdout`. */
693
+ output?: Writable;
694
+ /** Where diagnostics are written. Default: `process.stderr`. */
695
+ log?: Writable;
696
+ /**
697
+ * Mount options, when serving a bridge. A handler from
698
+ * createMcpHandler already carries its own; passing both throws.
699
+ */
700
+ mount?: McpMountOptions;
701
+ }
702
+ /** A running stdio session. */
703
+ interface McpStdioServer {
704
+ /**
705
+ * Resolves once input has ended (or {@link close} was called) and
706
+ * every in-flight request has been answered.
707
+ */
708
+ readonly done: Promise<void>;
709
+ /** Stops reading input; resolves like {@link done}. */
710
+ close(): Promise<void>;
711
+ }
712
+ /**
713
+ * Serves MCP over stdio for a bridge, or for a handler built by
714
+ * createMcpHandler (its bridge and mount options are reused).
715
+ *
716
+ * A handler built some other way is called with an HTTP-shaped POST
717
+ * per message; that serves the 2024-11-05 era, but such a handler
718
+ * cannot know the request came over stdio, so 2026-07-28 requests fail
719
+ * its header checks. Pass the bridge or a createMcpHandler handler to
720
+ * serve both eras.
721
+ *
722
+ * ```ts
723
+ * import { serveStdio } from '@hop-top/kit/mcp';
724
+ *
725
+ * const server = serveStdio(bridge);
726
+ * await server.done; // the host closed stdin
727
+ * ```
728
+ */
729
+ declare function serveStdio(target: McpBridge | McpHandler, opts?: McpStdioOptions): McpStdioServer;
730
+
731
+ /**
732
+ * @module mcp/modern-confirm
733
+ * @package @hop-top/kit
734
+ *
735
+ * MRTR (multi round-trip requests) confirmation for the modern
736
+ * (2026-07-28) `tools/call` path: the elicitation-based strategy that
737
+ * fills the confirmation-gate slot when a mount is given key material
738
+ * via `confirmationKey`.
739
+ *
740
+ * Flow (spec: basic/patterns/mrtr + client/elicitation): the first
741
+ * call on a `kit/requires-confirmation` leaf returns `resultType`
742
+ * "input_required" carrying a single `elicitation/create` form request
743
+ * under the reserved `inputRequests` key "confirm" plus an
744
+ * integrity-protected `requestState`. The client gathers the user's
745
+ * decision and retries the original call (new JSON-RPC id) with
746
+ * `params.inputResponses` and the echoed `params.requestState`; the
747
+ * gate verifies the state and lets the invocation proceed only when the
748
+ * confirm response's action is "accept". Decline/cancel refuse the call
749
+ * with an isError complete result.
750
+ *
751
+ * Statelessness: everything a retry needs lives inside `requestState`.
752
+ * There is no server-side pending-request storage of any kind, so any
753
+ * instance holding the same key verifies state minted by any other —
754
+ * which is exactly why the key must be adopter-supplied and shared, and
755
+ * why there is deliberately no generated-at-mount default. The
756
+ * corollary (spec: replay warning) is that an accepted state remains
757
+ * honorable for identical (leaf, arguments, principal) until its TTL
758
+ * lapses; single-use redemption would require the server-side state
759
+ * this surface deliberately does not keep, so the short TTL bounds the
760
+ * window instead.
761
+ *
762
+ * Two verification failures are deliberately distinct: an
763
+ * expired-but-authentic state is a routine re-prompt; a state failing
764
+ * HMAC verification is never honored — the rejection is recorded as a
765
+ * security-relevant audit event first, and only then is a fresh prompt
766
+ * (with newly minted state) issued. Tampering can therefore cost a
767
+ * request, but is never silently treated as a re-prompt.
768
+ *
769
+ * MRTR confirmation is an alternative way to SATISFY confirmation,
770
+ * never a way to bypass the destructive ceiling: the policy gate runs
771
+ * inside `bridge.invoke` after this gate, exactly as on every other
772
+ * path.
773
+ */
774
+
775
+ /**
776
+ * The single reserved `inputRequests` key the confirmation flow uses;
777
+ * the retry's answer is read from the same key in
778
+ * `params.inputResponses`.
779
+ */
780
+ declare const MCP_CONFIRM_KEY = "confirm";
781
+ /**
782
+ * Lifetime of a minted `requestState`, in seconds. Long enough for a
783
+ * human to read and answer the prompt; short enough to bound the replay
784
+ * window the stateless design cannot otherwise close (see the module
785
+ * comment).
786
+ */
787
+ declare const MCP_CONFIRM_STATE_TTL_SECONDS: number;
788
+ /**
789
+ * Tags the `requestState` wire format so a future format change
790
+ * invalidates (rather than misparses) old state.
791
+ */
792
+ declare const MCP_CONFIRM_STATE_VERSION = "v1";
793
+ /**
794
+ * The request context a `requestState` is bound to. The HMAC covers
795
+ * every field plus the expiry, so state presented for a different leaf,
796
+ * different arguments, or by a different principal fails verification
797
+ * outright (spec: reject state presented on a request that does not
798
+ * match / by a different principal).
799
+ */
800
+ interface McpConfirmBinding {
801
+ /** The leaf path key, space-joined, e.g. "widget purge". */
802
+ tool: string;
803
+ /** Hex SHA-256 of the canonically serialized `params.arguments`. */
804
+ argsDigest: string;
805
+ /**
806
+ * Hex SHA-256 of the `Authorization` header value, or "" when the
807
+ * request carried none. Hashed so the MAC input never embeds
808
+ * credential material.
809
+ */
810
+ principal: string;
811
+ }
812
+ /** The outcome of verifying a presented `requestState`. */
813
+ type McpConfirmStateStatus = 'valid' | 'expired' | 'invalid';
814
+ /** One recorded rejection of a state that failed integrity verification. */
815
+ interface McpConfirmRejection {
816
+ path: string;
817
+ mcpConfirmRejection: string;
818
+ }
819
+ /** A gate decision: the result body to write plus its HTTP status. */
820
+ type McpConfirmDecision = {
821
+ result: Record<string, unknown>;
822
+ status: number;
823
+ };
824
+ /**
825
+ * The MRTR confirmation gate for mounts configured with a
826
+ * `confirmationKey`.
827
+ *
828
+ * Clients that did not declare form-mode elicitation keep the
829
+ * `X-Confirm-Token` header gate: the spec forbids sending
830
+ * `inputRequests` for a capability the client never declared, and the
831
+ * capability stays optional precisely because this fallback exists — so
832
+ * a missing elicitation capability is never -32021 here.
833
+ */
834
+ declare class ElicitationConfirmGate {
835
+ private readonly toolNameSeparator?;
836
+ private readonly audit?;
837
+ private readonly key;
838
+ /**
839
+ * In-memory records of rejected states, kept beside the mount's
840
+ * `audit` hook for callers holding the gate directly.
841
+ */
842
+ readonly rejections: McpConfirmRejection[];
843
+ /**
844
+ * `toolNameSeparator` names the tool in the confirmation prompt, as
845
+ * the mount's `toolNameSeparator` option does in tools/list. `audit`
846
+ * is the mount's refusal hook: it receives the gate's three refusals
847
+ * (confirmation required, declined, state rejected).
848
+ */
849
+ constructor(key: Uint8Array, toolNameSeparator?: string | undefined, audit?: McpAuditHook | undefined);
850
+ /**
851
+ * Runs the gate for one `tools/call`. Returns `undefined` to proceed
852
+ * with the invocation, or the refusal / interim result plus its HTTP
853
+ * status. The caller stamps the modern envelope onto whatever is
854
+ * returned.
855
+ */
856
+ evaluate(req: McpHttpRequest, leaf: Leaf, params: unknown): McpConfirmDecision | undefined;
857
+ /**
858
+ * Builds the `input_required` result envelope for one confirmation
859
+ * prompt: the reserved "confirm" `elicitation/create` form request
860
+ * plus freshly minted `requestState` (satisfying the spec MUST of
861
+ * carrying at least one of `inputRequests` / `requestState` — this
862
+ * flow always carries both). The caller stamps the envelope (_meta
863
+ * serverInfo; `resultType` stays "input_required") and writes it at
864
+ * HTTP 200. Interim `input_required` results are never cacheable: no
865
+ * `ttlMs` / `cacheScope` members, ever.
866
+ */
867
+ inputRequired(leaf: Leaf, binding: McpConfirmBinding): Record<string, unknown>;
868
+ /**
869
+ * Records a failed `requestState` verification as a
870
+ * security-relevant audit event: in memory on `rejections`, and on
871
+ * the mount's audit hook with the `mcp_confirm_rejection` extra Go's
872
+ * surfaces attach. Best-effort by the same contract: recording never
873
+ * affects the response.
874
+ */
875
+ private auditRejection;
876
+ /** Emits one 2026-07-28 refusal record to the mount's audit hook. */
877
+ private emit;
878
+ }
879
+ /**
880
+ * The default gate: a `requiresConfirmation` leaf needs the
881
+ * `X-Confirm-Token` header, exactly as on the legacy path. This is the
882
+ * fallback for clients without form elicitation and the whole gate for
883
+ * mounts without a confirmation key.
884
+ */
885
+ declare function headerConfirmationGate(req: McpHttpRequest): McpConfirmDecision | undefined;
886
+ /**
887
+ * Reports whether the request's
888
+ * `io.modelcontextprotocol/clientCapabilities` declares form-mode
889
+ * elicitation. Per spec, an empty `elicitation` object (`{}`) declares
890
+ * form-only support; a non-empty object must name "form" among its
891
+ * modes (a url-only client cannot receive this flow's form request).
892
+ * Anything that is not a conforming object declaration — key absent,
893
+ * value null or non-object — counts as undeclared, failing toward the
894
+ * header fallback rather than toward sending a request the client never
895
+ * said it could handle.
896
+ */
897
+ declare function clientSupportsFormElicitation(params: unknown): boolean;
898
+ /**
899
+ * The tolerant read of the MRTR retry members of a `tools/call`
900
+ * request. Members that are absent or of the wrong JSON type simply
901
+ * stay empty — the gate treats a missing state as "prompt" and a
902
+ * missing/unusable action as "re-prompt", so malformed retries converge
903
+ * on a fresh `input_required` rather than a decode error.
904
+ */
905
+ declare function parseMcpConfirmRetry(params: unknown): {
906
+ state: string;
907
+ action: string;
908
+ };
909
+ /**
910
+ * Derives the principal component of the state binding: hex SHA-256 of
911
+ * the `Authorization` value, "" when the header is absent.
912
+ * Presence-only bearer checking is all this surface does for auth
913
+ * (`class.authRequired`), so the raw header value is the closest stable
914
+ * principal identifier available; hashing keeps credential material out
915
+ * of the MAC input.
916
+ */
917
+ declare function mcpConfirmPrincipal(req: McpHttpRequest): string;
918
+ /**
919
+ * Returns the hex SHA-256 of the canonically serialized
920
+ * `params.arguments`. Canonical form sorts object keys at every nesting
921
+ * level, so equal argument sets digest identically regardless of the
922
+ * client's key order; absent arguments canonicalize to "null". Only the
923
+ * arguments participate: `_meta`, `inputResponses`, and `requestState`
924
+ * all legitimately differ between the first call and its retry, and the
925
+ * tool name is bound separately via the leaf path key.
926
+ */
927
+ declare function mcpConfirmArgsDigest(params: unknown): string;
928
+ /**
929
+ * Renders an opaque-to-clients `requestState`:
930
+ * `v1.<expiry-unix>.<base64url(mac)>`. Only the version and expiry
931
+ * travel in the clear; the full binding is reconstructed from the retry
932
+ * request itself at verification time, which is what keeps the state
933
+ * small and the flow stateless.
934
+ */
935
+ declare function mintMcpConfirmState(key: Uint8Array, binding: McpConfirmBinding, expiry: number): string;
936
+ /**
937
+ * Checks a presented state against the current request's binding.
938
+ * Authenticity is decided BEFORE expiry, so "expired" is only ever
939
+ * reported for a state that verifiably came from this key and this
940
+ * exact binding — a tampered expiry fails the MAC and lands in
941
+ * "invalid", never in "expired". Any structural defect (wrong part
942
+ * count, unknown version, non-decimal expiry, undecodable tag) is a
943
+ * verification failure too: a state that cannot be verified is never
944
+ * honored.
945
+ */
946
+ declare function verifyMcpConfirmState(key: Uint8Array, state: string, binding: McpConfirmBinding, now: number): McpConfirmStateStatus;
947
+
948
+ /**
949
+ * @module mcp/modern
950
+ * @package @hop-top/kit
951
+ *
952
+ * The 2026-07-28 MCP handler: the stateless request core behind the
953
+ * era dispatcher. Implements expose-cli-over-mcp.md's validation order V1-V9,
954
+ * `server/discover`, the modern error writers (-32020 / -32021 /
955
+ * -32022 with their status mapping), result-envelope stamping
956
+ * (`resultType` + serverInfo `_meta`), and cache-hint application.
957
+ *
958
+ * Statelessness is the revision's core contract: every request
959
+ * carries protocol version, client identity, and capabilities in
960
+ * `params._meta` under reserved io.modelcontextprotocol/* keys;
961
+ * there is no initialize/initialized handshake and no session id.
962
+ * The handler holds only immutable mount configuration, so any
963
+ * instance can serve any request.
964
+ */
965
+
966
+ /** One validation-chain failure: code, message, status, optional data. */
967
+ interface CheckError {
968
+ code: number;
969
+ msg: string;
970
+ status: number;
971
+ data?: unknown;
972
+ }
973
+ /** The decoded view of the reserved params._meta keys (V3). */
974
+ interface ModernRequestMeta {
975
+ version: string;
976
+ versionIsText: boolean;
977
+ versionRaw: unknown;
978
+ clientName?: string;
979
+ clientVersion?: string;
980
+ hasClientInfo: boolean;
981
+ }
982
+ /** The 2026-07-28 handler. */
983
+ declare class ModernMcpHandler {
984
+ private readonly bridge;
985
+ private readonly cfg;
986
+ private readonly transport;
987
+ /**
988
+ * The MRTR confirmation strategy, installed only when the mount was
989
+ * given key material. Without a key there is nothing to MAC state
990
+ * with, so every client — elicitation-capable or not — keeps the
991
+ * `X-Confirm-Token` header gate.
992
+ */
993
+ readonly confirmGate?: ElicitationConfirmGate;
994
+ /**
995
+ * `transport` selects the binding. Streamable HTTP mirrors the method,
996
+ * tool name and protocol version into headers and requires them to
997
+ * agree with the body (V4, V6, V7). stdio has no header layer — the
998
+ * body is the only source of truth — so those three checks do not
999
+ * apply there; every other check runs unchanged.
1000
+ */
1001
+ constructor(bridge: McpBridge, cfg: ResolvedMcpConfig, transport?: McpTransport);
1002
+ /**
1003
+ * The modern entry point. The validation chain runs in the guide's
1004
+ * order V1-V9; the first failure responds and stops. HTTP status is
1005
+ * 400/404 only where the spec mandates it — application-level
1006
+ * JSON-RPC errors ride HTTP 200, matching legacy's convention.
1007
+ */
1008
+ serve(req: McpHttpRequest, rpc: JsonRpcRequest): Promise<McpHttpResponse>;
1009
+ /** V4: MCP-Protocol-Version header present and equal to _meta's. */
1010
+ private validateVersionHeader;
1011
+ /**
1012
+ * server/discover — the mandatory modern discovery method. Carries
1013
+ * no listChanged flag (notifications unimplemented), no extensions
1014
+ * map (none supported, which is what makes tasks/* method-not-found),
1015
+ * and no instructions.
1016
+ */
1017
+ private handleDiscover;
1018
+ /**
1019
+ * Modern tools/list: the same tool envelopes the legacy handler
1020
+ * emits (so schema drift between eras cannot happen), wrapped in
1021
+ * the modern complete-result envelope with cache hints. Pagination
1022
+ * is not implemented — a cursor param is ignored, no nextCursor.
1023
+ */
1024
+ private handleToolsList;
1025
+ /**
1026
+ * Modern tools/call: V7, V9, the legacy pre-flight gates, invoke,
1027
+ * render. The shared bridge invoke path keeps the policy gate
1028
+ * identical across eras — there is no way to reach a leaf here that
1029
+ * the legacy path would have blocked. Results carry no cache hints.
1030
+ */
1031
+ private handleToolsCall;
1032
+ /** Emits one 2026-07-28 refusal record to the mount's audit hook. */
1033
+ private audit;
1034
+ /**
1035
+ * Selects and runs the confirmation strategy for one `tools/call`.
1036
+ * Returns `undefined` to proceed with the invocation.
1037
+ *
1038
+ * A leaf that does not require confirmation is never gated. A mount
1039
+ * without a `confirmationKey` has no state to MAC, so the header gate
1040
+ * applies to every client — this is the byte-for-byte preservation
1041
+ * path, identical to what the legacy handler does.
1042
+ */
1043
+ private confirmationGate;
1044
+ /** V6: Mcp-Method header presence + agreement with the body method. */
1045
+ private validateMethodHeader;
1046
+ /**
1047
+ * V7: on tools/call the Mcp-Name header MUST be present, non-empty
1048
+ * after Base64-sentinel decoding, and byte-equal to params.name,
1049
+ * which MUST itself be present. Any violation is a header failure
1050
+ * (-32020 @ 400), decided ahead of any body-shape check: headers
1051
+ * are the routing signal gateways trust without parsing the body,
1052
+ * so an empty or contradicted signal is malformed at the header
1053
+ * layer.
1054
+ */
1055
+ private validateNameHeader;
1056
+ /**
1057
+ * Adds the members every modern result envelope carries: resultType
1058
+ * and a result-level _meta with serverInfo built from the mount's
1059
+ * configured identity. A producer that already chose a resultType
1060
+ * keeps it (the MRTR confirmation gate stamps "input_required").
1061
+ */
1062
+ stampResultEnvelope(m: Record<string, unknown>): Record<string, unknown>;
1063
+ /**
1064
+ * Adds ttlMs and cacheScope to a cacheable complete-result —
1065
+ * server/discover and tools/list only; tools/call carries none.
1066
+ * Defaults are ttlMs 0 (immediately stale: the leaf set can mutate
1067
+ * at runtime and no list_changed notification exists) and
1068
+ * cacheScope "private".
1069
+ */
1070
+ applyCacheHints(m: Record<string, unknown>): Record<string, unknown>;
1071
+ /** Opt-in Origin allowlist; a request without Origin is never refused. */
1072
+ private originAllowed;
1073
+ /**
1074
+ * Writes a modern JSON-RPC error. When the rejected request's
1075
+ * method is "initialize" the message additionally names the
1076
+ * supported versions: a legacy client has no fall-forward
1077
+ * mechanism, so the version list in the error text is its only
1078
+ * recovery hint.
1079
+ */
1080
+ private writeModernError;
1081
+ /** An isError tools/call result with the modern envelope stamped on. */
1082
+ private writeCallError;
1083
+ }
1084
+ /**
1085
+ * Reduces all occurrences of a header to one value for comparison
1086
+ * against the body. Sent once, or several times with byte-identical
1087
+ * values (benign proxy duplication), resolves to that value. Sent
1088
+ * several times with differing values is a validation failure in its
1089
+ * own right — conflicting duplicates are exactly the
1090
+ * multiple-sources-of-truth hazard header/body validation closes — so
1091
+ * ok=false and the caller rejects without comparing anything.
1092
+ */
1093
+ declare function singleHeaderValue(req: McpHttpRequest, name: string): {
1094
+ value: string;
1095
+ ok: boolean;
1096
+ };
1097
+ /**
1098
+ * V2's id rule: a JSON string, or a JSON number with no fractional
1099
+ * part. Base JSON-RPC also allows null, but this revision forbids it;
1100
+ * boolean, object, and array ids are rejected the same way.
1101
+ */
1102
+ declare function validModernRequestId(id: RawJSON): boolean;
1103
+ /**
1104
+ * V3: decodes the reserved params._meta keys. protocolVersion and
1105
+ * clientCapabilities are required; clientInfo is optional. A missing
1106
+ * or non-object params/_meta fails the same way as missing keys.
1107
+ */
1108
+ declare function parseModernMeta(params: unknown): {
1109
+ meta: ModernRequestMeta;
1110
+ } | {
1111
+ error: CheckError;
1112
+ };
1113
+ /**
1114
+ * Peeks params.name out of a tools/call body without requiring the
1115
+ * rest of params to decode, so V7 can run independently of whatever
1116
+ * else is wrong with the body. `present` reports whether params is an
1117
+ * object carrying a "name" key at all; `isString` distinguishes a
1118
+ * non-string value, which V7 defers to V9 rather than treating as
1119
+ * absent.
1120
+ */
1121
+ declare function rawToolCallName(params: unknown): {
1122
+ name: string;
1123
+ present: boolean;
1124
+ isString: boolean;
1125
+ };
1126
+ /**
1127
+ * Decodes a header value that may carry the Base64 sentinel encoding.
1128
+ * A value that is not sentinel-wrapped is returned unchanged.
1129
+ * A wrapped value that fails to decode returns undefined so the
1130
+ * caller fails closed: the spec requires decoding before comparing,
1131
+ * and a malformed encoding can never legitimately match the body.
1132
+ * A value that merely looks like the sentinel is always treated as
1133
+ * encoded, per spec.
1134
+ */
1135
+ declare function decodeMcpSentinel(v: string): string | undefined;
1136
+ /**
1137
+ * The Meta.extra audit bag for a modern invocation: the spec version
1138
+ * always, and the client identity when the request carried clientInfo.
1139
+ */
1140
+ declare function modernInvocationExtra(meta: ModernRequestMeta): Record<string, string>;
1141
+
1142
+ /**
1143
+ * @module mcp/tasks
1144
+ * @package @hop-top/kit
1145
+ *
1146
+ * The `io.modelcontextprotocol/tasks` extension slot.
1147
+ *
1148
+ * kit does not implement the tasks extension (design gap matrix:
1149
+ * "Not implemented. capabilities.extensions omitted from
1150
+ * server/discover (= unsupported); tasks/* → -32601 @ 404"). This
1151
+ * module makes that decision explicit and testable rather than
1152
+ * implicit in a `default:` branch, and marks the designated slot if
1153
+ * the extension is ever added.
1154
+ *
1155
+ * The negotiation contract matters for parity: because
1156
+ * server/discover omits `capabilities.extensions` entirely, a
1157
+ * conforming client never negotiates the extension and never sends
1158
+ * `tasks/*`. A client that sends it anyway gets the same
1159
+ * method-not-found response any other unknown modern method gets —
1160
+ * NOT a distinct "extension unsupported" error, which would be a wire
1161
+ * behavior the Go reference does not produce.
1162
+ */
1163
+ /** The reserved extension identifier, as named by the spec. */
1164
+ declare const TASKS_EXTENSION = "io.modelcontextprotocol/tasks";
1165
+ /**
1166
+ * The task-extension methods. Listed so the surface can recognize
1167
+ * them for documentation and testing purposes; recognizing one does
1168
+ * NOT change its response.
1169
+ */
1170
+ declare const TASK_METHODS: readonly ["tasks/get", "tasks/update", "tasks/list", "tasks/result", "tasks/cancel"];
1171
+ type TaskMethod = (typeof TASK_METHODS)[number];
1172
+ /** Reports whether a method name belongs to the tasks extension. */
1173
+ declare function isTaskMethod(method: string): method is TaskMethod;
1174
+ /**
1175
+ * Whether this mount supports the tasks extension. Always false: the
1176
+ * extension is a non-goal, and `server/discover` therefore omits the
1177
+ * `capabilities.extensions` map entirely (an empty map would
1178
+ * advertise the *ability* to carry extensions, which is a different
1179
+ * claim than making none).
1180
+ */
1181
+ declare const TASKS_SUPPORTED: false;
1182
+ /**
1183
+ * The `capabilities` object `server/discover` reports. The extensions
1184
+ * map is omitted rather than emitted empty — see TASKS_SUPPORTED.
1185
+ */
1186
+ declare function discoverCapabilities(): Record<string, unknown>;
1187
+
1188
+ /**
1189
+ * @module mcp/identity
1190
+ * @package @hop-top/kit
1191
+ *
1192
+ * Who is calling, as both eras' `tools/call` gate reads it. The only
1193
+ * source of identity is the mount's verifier: an `Authorization`
1194
+ * header is presence, not verification, and a caller or scopes the
1195
+ * request claims never become identity. Mirrors the Go surfaces,
1196
+ * where only an established `Meta` admits a `kit/auth-required` leaf.
1197
+ */
1198
+
1199
+ /** The key the verifier's scopes are recorded under in `InvocationMeta.extra`. */
1200
+ declare const SCOPES_EXTRA_KEY = "scopes";
1201
+ /**
1202
+ * Runs the mount's verifier over `req`. Returns the identity it
1203
+ * established, or `undefined` when there is no verifier, it refused
1204
+ * (`null`/`undefined`), returned something that is not an object, or
1205
+ * threw: every failure fails closed.
1206
+ */
1207
+ declare function establishCaller(verifier: McpVerifier | undefined, req: McpHttpRequest): Promise<McpIdentity | undefined>;
1208
+ /**
1209
+ * Builds one `tools/call` invocation's meta: the MCP surface, the
1210
+ * request time, the audit `extra` the era supplies, and the identity
1211
+ * the verifier established — caller, tenant, `established`, and the
1212
+ * comma-joined `scopes` extra entry. Nothing from `ident` is set when
1213
+ * it is `undefined`, and nothing here reads the request.
1214
+ */
1215
+ declare function invocationMeta(ident: McpIdentity | undefined, extra?: Record<string, string>): InvocationMeta;
1216
+
1217
+ /**
1218
+ * @module mcp/bridge
1219
+ * @package @hop-top/kit
1220
+ *
1221
+ * A commander adapter for the MCP surface's `McpBridge` interface.
1222
+ *
1223
+ * The surface itself never imports commander — that is what keeps
1224
+ * the handler framework-free and lets adopters on another command
1225
+ * framework implement `McpBridge` directly. This adapter is the
1226
+ * convenience path for the commander trees the TS SDK's own `cli`
1227
+ * module builds.
1228
+ *
1229
+ * The safety gate lives here, on the invoke path, so BOTH eras
1230
+ * inherit one destructive ceiling from one place: there is no way to
1231
+ * reach a leaf through the modern handler that the legacy handler
1232
+ * would have blocked.
1233
+ */
1234
+
1235
+ interface CommanderBridgeOptions {
1236
+ /** Policy gate. Defaults to defaultPolicy() (block remote destructive). */
1237
+ policy?: Policy;
1238
+ /**
1239
+ * Runs one leaf and returns its result. Adopters supply this
1240
+ * because kit does not dictate how a command's output is captured.
1241
+ */
1242
+ run: (inv: Invocation, cmd: Command) => Promise<InvokeResult> | InvokeResult;
1243
+ /** Per-leaf surface enablement override. */
1244
+ enabled?: (leaf: Leaf) => Partial<Record<Surface, boolean>> | undefined;
1245
+ }
1246
+ /**
1247
+ * Builds an `McpBridge` over a commander tree. Leaves are the
1248
+ * commands with no subcommands, enumerated depth-first in
1249
+ * declaration order, with the root's own name excluded from the path
1250
+ * (so `root widget add` is the tool `widget.add`).
1251
+ */
1252
+ declare function commanderBridge(root: Command, opts: CommanderBridgeOptions): McpBridge;
1253
+
1254
+ /**
1255
+ * @module mcp/args
1256
+ * @package @hop-top/kit
1257
+ *
1258
+ * Positional arguments over MCP, ported from Go's
1259
+ * go/transport/cmdsurface/surface_mcp_args.go.
1260
+ *
1261
+ * An MCP tool takes one JSON object of named arguments; a leaf takes
1262
+ * flags by name and positional arguments by position. A leaf that
1263
+ * declares its positionals (`Leaf.args`) publishes them as ONE extra
1264
+ * property, "args": an array of strings in declared order — the key
1265
+ * and shape every kit surface uses for positionals. One property per
1266
+ * argument would share a namespace with the leaf's flags, so a flag
1267
+ * added later could silently take an argument's name; the array
1268
+ * reserves exactly one name, and a trailing variadic argument needs
1269
+ * no extra syntax.
1270
+ *
1271
+ * The property is required, with minItems set to the number of
1272
+ * required arguments, when any argument is; optional arguments only
1273
+ * lengthen what the array may hold. No maxItems is published, as in
1274
+ * Go: the command's own parser refuses a count it does not accept.
1275
+ *
1276
+ * A leaf whose "args" name is taken by a flag publishes no such
1277
+ * property and says so in its description: the flag was part of the
1278
+ * tool's schema first, and taking the name would change what an
1279
+ * existing caller's "args" means.
1280
+ */
1281
+
1282
+ /** The inputSchema property carrying a leaf's declared positionals. */
1283
+ declare const MCP_ARGS_PROPERTY = "args";
1284
+ /**
1285
+ * Reports whether leaf's inputSchema carries the "args" property: it
1286
+ * declares positional arguments and no flag already holds the name.
1287
+ */
1288
+ declare function mcpArgsPublished(leaf: Leaf): boolean;
1289
+ /**
1290
+ * The description leaf's MCP tool publishes: its own description,
1291
+ * followed by a note when it takes positionals the tool cannot pass.
1292
+ */
1293
+ declare function mcpToolDescription(leaf: Leaf): string;
1294
+ /**
1295
+ * leaf's MCP tool inputSchema: one property per flag, the leaf's
1296
+ * required flags listed as required, plus the "args" property when
1297
+ * {@link mcpArgsPublished}.
1298
+ */
1299
+ declare function mcpInputSchema(leaf: Leaf): Record<string, unknown>;
1300
+ /** The outcome of {@link mcpSplitArguments}. */
1301
+ type McpSplitResult = {
1302
+ flags?: Record<string, unknown>;
1303
+ args?: string[];
1304
+ error?: undefined;
1305
+ } | {
1306
+ error: string;
1307
+ };
1308
+ /**
1309
+ * Splits a tools/call arguments object into an invocation's flags
1310
+ * and positional args. When leaf publishes "args" that key is taken
1311
+ * out of the flags: it must hold an array of strings, at least as
1312
+ * many as the leaf declares required, and becomes `args` in order.
1313
+ * Every other key is a flag, forwarded as-is. A leaf that publishes
1314
+ * no "args" property gets every key as a flag.
1315
+ *
1316
+ * `error` names the problem for the caller to correct; the handlers
1317
+ * return it as an isError tool result, before the confirmation gate.
1318
+ */
1319
+ declare function mcpSplitArguments(leaf: Leaf, args: Record<string, unknown> | undefined): McpSplitResult;
1320
+
1321
+ /**
1322
+ * @module mcp
1323
+ * @package @hop-top/kit
1324
+ *
1325
+ * Dual-spec MCP surface: one mount serving both 2024-11-05 (legacy
1326
+ * handshake) and 2026-07-28 (stateless per-request envelope), with
1327
+ * per-request era detection.
1328
+ *
1329
+ * The protocol layer comes from the official v2 SDK packages
1330
+ * (`@modelcontextprotocol/core` + `@modelcontextprotocol/server`).
1331
+ * The v1 package `@modelcontextprotocol/sdk` is legacy-era only and
1332
+ * cannot serve 2026-07-28 — it is deliberately not a dependency.
1333
+ *
1334
+ * Usage:
1335
+ *
1336
+ * ```ts
1337
+ * import { createMcpHandler } from '@hop-top/kit/mcp';
1338
+ *
1339
+ * const handler = createMcpHandler(bridge);
1340
+ * const res = await handler({ method: 'POST', headers, body });
1341
+ * ```
1342
+ *
1343
+ * The handler is framework-free: binding it to node:http, hono,
1344
+ * express, fastify, or a Worker is the adopter's job. For a host that
1345
+ * spawns the tool, `serveStdio(bridge)` (or `serveStdio(handler)`)
1346
+ * serves the same surface over newline-delimited stdin/stdout.
1347
+ */
1348
+
1349
+ type index_CommanderBridgeOptions = CommanderBridgeOptions;
1350
+ declare const index_DEFAULT_MCP_PATH: typeof DEFAULT_MCP_PATH;
1351
+ declare const index_DEFAULT_MCP_SERVER_NAME: typeof DEFAULT_MCP_SERVER_NAME;
1352
+ declare const index_DEFAULT_MCP_SERVER_VERSION: typeof DEFAULT_MCP_SERVER_VERSION;
1353
+ declare const index_DEFAULT_TOOL_NAME_SEPARATOR: typeof DEFAULT_TOOL_NAME_SEPARATOR;
1354
+ type index_DestructiveBlockedError = DestructiveBlockedError;
1355
+ declare const index_DestructiveBlockedError: typeof DestructiveBlockedError;
1356
+ type index_ElicitationConfirmGate = ElicitationConfirmGate;
1357
+ declare const index_ElicitationConfirmGate: typeof ElicitationConfirmGate;
1358
+ type index_FlagSchema = FlagSchema;
1359
+ declare const index_HEADER_MCP_METHOD: typeof HEADER_MCP_METHOD;
1360
+ declare const index_HEADER_MCP_NAME: typeof HEADER_MCP_NAME;
1361
+ declare const index_HEADER_MCP_PROTOCOL_VERSION: typeof HEADER_MCP_PROTOCOL_VERSION;
1362
+ type index_Invocation = Invocation;
1363
+ type index_InvocationMeta = InvocationMeta;
1364
+ type index_InvokeResult = InvokeResult;
1365
+ type index_JsonRpcErrorObject = JsonRpcErrorObject;
1366
+ type index_JsonRpcRequest = JsonRpcRequest;
1367
+ type index_Leaf = Leaf;
1368
+ type index_LeafArg = LeafArg;
1369
+ type index_LegacyMcpHandler = LegacyMcpHandler;
1370
+ declare const index_LegacyMcpHandler: typeof LegacyMcpHandler;
1371
+ declare const index_MCP_ARGS_PROPERTY: typeof MCP_ARGS_PROPERTY;
1372
+ declare const index_MCP_AUDIT_AUTH_REFUSED: typeof MCP_AUDIT_AUTH_REFUSED;
1373
+ declare const index_MCP_AUDIT_CONFIRMATION_DECLINED: typeof MCP_AUDIT_CONFIRMATION_DECLINED;
1374
+ declare const index_MCP_AUDIT_CONFIRMATION_REQUIRED: typeof MCP_AUDIT_CONFIRMATION_REQUIRED;
1375
+ declare const index_MCP_AUDIT_CONFIRMATION_STATE_REJECTED: typeof MCP_AUDIT_CONFIRMATION_STATE_REJECTED;
1376
+ declare const index_MCP_AUDIT_DESTRUCTIVE_BLOCKED: typeof MCP_AUDIT_DESTRUCTIVE_BLOCKED;
1377
+ declare const index_MCP_AUTH_CHALLENGE: typeof MCP_AUTH_CHALLENGE;
1378
+ declare const index_MCP_CONFIRM_KEY: typeof MCP_CONFIRM_KEY;
1379
+ declare const index_MCP_CONFIRM_REJECTION_STATE: typeof MCP_CONFIRM_REJECTION_STATE;
1380
+ declare const index_MCP_CONFIRM_STATE_TTL_SECONDS: typeof MCP_CONFIRM_STATE_TTL_SECONDS;
1381
+ declare const index_MCP_CONFIRM_STATE_VERSION: typeof MCP_CONFIRM_STATE_VERSION;
1382
+ declare const index_MCP_ERR_HEADER_MISMATCH: typeof MCP_ERR_HEADER_MISMATCH;
1383
+ declare const index_MCP_ERR_INTERNAL: typeof MCP_ERR_INTERNAL;
1384
+ declare const index_MCP_ERR_INVALID_PARAMS: typeof MCP_ERR_INVALID_PARAMS;
1385
+ declare const index_MCP_ERR_INVALID_REQUEST: typeof MCP_ERR_INVALID_REQUEST;
1386
+ declare const index_MCP_ERR_METHOD_NOT_FOUND: typeof MCP_ERR_METHOD_NOT_FOUND;
1387
+ declare const index_MCP_ERR_MISSING_CLIENT_CAPABILITY: typeof MCP_ERR_MISSING_CLIENT_CAPABILITY;
1388
+ declare const index_MCP_ERR_PARSE: typeof MCP_ERR_PARSE;
1389
+ declare const index_MCP_ERR_UNSUPPORTED_VERSION: typeof MCP_ERR_UNSUPPORTED_VERSION;
1390
+ declare const index_MCP_SPEC_2024_11_05: typeof MCP_SPEC_2024_11_05;
1391
+ declare const index_MCP_SPEC_2026_07_28: typeof MCP_SPEC_2026_07_28;
1392
+ declare const index_META_KEY_CLIENT_CAPABILITIES: typeof META_KEY_CLIENT_CAPABILITIES;
1393
+ declare const index_META_KEY_CLIENT_INFO: typeof META_KEY_CLIENT_INFO;
1394
+ declare const index_META_KEY_PROTOCOL_VERSION: typeof META_KEY_PROTOCOL_VERSION;
1395
+ declare const index_META_KEY_SERVER_INFO: typeof META_KEY_SERVER_INFO;
1396
+ type index_McpAuditHook = McpAuditHook;
1397
+ type index_McpAuditRecord = McpAuditRecord;
1398
+ type index_McpBridge = McpBridge;
1399
+ type index_McpCacheScope = McpCacheScope;
1400
+ type index_McpConfirmBinding = McpConfirmBinding;
1401
+ type index_McpConfirmDecision = McpConfirmDecision;
1402
+ type index_McpConfirmRejection = McpConfirmRejection;
1403
+ type index_McpConfirmStateStatus = McpConfirmStateStatus;
1404
+ type index_McpDispatcher = McpDispatcher;
1405
+ declare const index_McpDispatcher: typeof McpDispatcher;
1406
+ type index_McpEra = McpEra;
1407
+ type index_McpEstablishment = McpEstablishment;
1408
+ type index_McpHandler = McpHandler;
1409
+ type index_McpHttpRequest = McpHttpRequest;
1410
+ type index_McpHttpResponse = McpHttpResponse;
1411
+ type index_McpIdentity = McpIdentity;
1412
+ type index_McpMountOptions = McpMountOptions;
1413
+ type index_McpSpecVersion = McpSpecVersion;
1414
+ type index_McpSplitResult = McpSplitResult;
1415
+ type index_McpStdioOptions = McpStdioOptions;
1416
+ type index_McpStdioServer = McpStdioServer;
1417
+ type index_McpTransport = McpTransport;
1418
+ type index_McpVerifier = McpVerifier;
1419
+ type index_ModernMcpHandler = ModernMcpHandler;
1420
+ declare const index_ModernMcpHandler: typeof ModernMcpHandler;
1421
+ type index_ModernRequestMeta = ModernRequestMeta;
1422
+ type index_Policy = Policy;
1423
+ declare const index_RESULT_TYPE_COMPLETE: typeof RESULT_TYPE_COMPLETE;
1424
+ declare const index_RESULT_TYPE_INPUT_REQUIRED: typeof RESULT_TYPE_INPUT_REQUIRED;
1425
+ type index_RawJSON = RawJSON;
1426
+ declare const index_RawJSON: typeof RawJSON;
1427
+ type index_ResolvedMcpConfig = ResolvedMcpConfig;
1428
+ declare const index_SCOPES_EXTRA_KEY: typeof SCOPES_EXTRA_KEY;
1429
+ declare const index_SURFACE_CLI: typeof SURFACE_CLI;
1430
+ declare const index_SURFACE_LIB: typeof SURFACE_LIB;
1431
+ declare const index_SURFACE_MCP: typeof SURFACE_MCP;
1432
+ type index_SafetyClass = SafetyClass;
1433
+ type index_Surface = Surface;
1434
+ type index_SurfaceNotEnabledError = SurfaceNotEnabledError;
1435
+ declare const index_SurfaceNotEnabledError: typeof SurfaceNotEnabledError;
1436
+ declare const index_TASKS_EXTENSION: typeof TASKS_EXTENSION;
1437
+ declare const index_TASKS_SUPPORTED: typeof TASKS_SUPPORTED;
1438
+ declare const index_TASK_METHODS: typeof TASK_METHODS;
1439
+ type index_TaskMethod = TaskMethod;
1440
+ type index_UnknownCommandError = UnknownCommandError;
1441
+ declare const index_UnknownCommandError: typeof UnknownCommandError;
1442
+ declare const index_auditRefusal: typeof auditRefusal;
1443
+ declare const index_buildToolEnvelope: typeof buildToolEnvelope;
1444
+ declare const index_canonicalJSONStringify: typeof canonicalJSONStringify;
1445
+ declare const index_clientSupportsFormElicitation: typeof clientSupportsFormElicitation;
1446
+ declare const index_commanderBridge: typeof commanderBridge;
1447
+ declare const index_createMcpHandler: typeof createMcpHandler;
1448
+ declare const index_decodeMcpSentinel: typeof decodeMcpSentinel;
1449
+ declare const index_defaultPolicy: typeof defaultPolicy;
1450
+ declare const index_detectMcpEra: typeof detectMcpEra;
1451
+ declare const index_discoverCapabilities: typeof discoverCapabilities;
1452
+ declare const index_encodeEnvelope: typeof encodeEnvelope;
1453
+ declare const index_errorResultBlock: typeof errorResultBlock;
1454
+ declare const index_establishCaller: typeof establishCaller;
1455
+ declare const index_hasModernMetaMarker: typeof hasModernMetaMarker;
1456
+ declare const index_headerConfirmationGate: typeof headerConfirmationGate;
1457
+ declare const index_invocationMeta: typeof invocationMeta;
1458
+ declare const index_isTaskMethod: typeof isTaskMethod;
1459
+ declare const index_mcpArgsPublished: typeof mcpArgsPublished;
1460
+ declare const index_mcpConfirmArgsDigest: typeof mcpConfirmArgsDigest;
1461
+ declare const index_mcpConfirmPrincipal: typeof mcpConfirmPrincipal;
1462
+ declare const index_mcpInputSchema: typeof mcpInputSchema;
1463
+ declare const index_mcpMountConfig: typeof mcpMountConfig;
1464
+ declare const index_mcpSplitArguments: typeof mcpSplitArguments;
1465
+ declare const index_mcpToolDescription: typeof mcpToolDescription;
1466
+ declare const index_methodNotAllowedResponse: typeof methodNotAllowedResponse;
1467
+ declare const index_mintMcpConfirmState: typeof mintMcpConfirmState;
1468
+ declare const index_modernInvocationExtra: typeof modernInvocationExtra;
1469
+ declare const index_parseJsonRpcRequest: typeof parseJsonRpcRequest;
1470
+ declare const index_parseMcpConfirmRetry: typeof parseMcpConfirmRetry;
1471
+ declare const index_parseModernMeta: typeof parseModernMeta;
1472
+ declare const index_pathFromToolName: typeof pathFromToolName;
1473
+ declare const index_policyAllowed: typeof policyAllowed;
1474
+ declare const index_rawToolCallName: typeof rawToolCallName;
1475
+ declare const index_renderCallResult: typeof renderCallResult;
1476
+ declare const index_resolveMcpConfig: typeof resolveMcpConfig;
1477
+ declare const index_serveStdio: typeof serveStdio;
1478
+ declare const index_singleHeaderValue: typeof singleHeaderValue;
1479
+ declare const index_toolName: typeof toolName;
1480
+ declare const index_validModernRequestId: typeof validModernRequestId;
1481
+ declare const index_verifyMcpConfirmState: typeof verifyMcpConfirmState;
1482
+ declare namespace index {
1483
+ export { type index_CommanderBridgeOptions as CommanderBridgeOptions, index_DEFAULT_MCP_PATH as DEFAULT_MCP_PATH, index_DEFAULT_MCP_SERVER_NAME as DEFAULT_MCP_SERVER_NAME, index_DEFAULT_MCP_SERVER_VERSION as DEFAULT_MCP_SERVER_VERSION, index_DEFAULT_TOOL_NAME_SEPARATOR as DEFAULT_TOOL_NAME_SEPARATOR, index_DestructiveBlockedError as DestructiveBlockedError, index_ElicitationConfirmGate as ElicitationConfirmGate, type index_FlagSchema as FlagSchema, index_HEADER_MCP_METHOD as HEADER_MCP_METHOD, index_HEADER_MCP_NAME as HEADER_MCP_NAME, index_HEADER_MCP_PROTOCOL_VERSION as HEADER_MCP_PROTOCOL_VERSION, type index_Invocation as Invocation, type index_InvocationMeta as InvocationMeta, type index_InvokeResult as InvokeResult, type index_JsonRpcErrorObject as JsonRpcErrorObject, type index_JsonRpcRequest as JsonRpcRequest, type index_Leaf as Leaf, type index_LeafArg as LeafArg, index_LegacyMcpHandler as LegacyMcpHandler, index_MCP_ARGS_PROPERTY as MCP_ARGS_PROPERTY, index_MCP_AUDIT_AUTH_REFUSED as MCP_AUDIT_AUTH_REFUSED, index_MCP_AUDIT_CONFIRMATION_DECLINED as MCP_AUDIT_CONFIRMATION_DECLINED, index_MCP_AUDIT_CONFIRMATION_REQUIRED as MCP_AUDIT_CONFIRMATION_REQUIRED, index_MCP_AUDIT_CONFIRMATION_STATE_REJECTED as MCP_AUDIT_CONFIRMATION_STATE_REJECTED, index_MCP_AUDIT_DESTRUCTIVE_BLOCKED as MCP_AUDIT_DESTRUCTIVE_BLOCKED, index_MCP_AUTH_CHALLENGE as MCP_AUTH_CHALLENGE, index_MCP_CONFIRM_KEY as MCP_CONFIRM_KEY, index_MCP_CONFIRM_REJECTION_STATE as MCP_CONFIRM_REJECTION_STATE, index_MCP_CONFIRM_STATE_TTL_SECONDS as MCP_CONFIRM_STATE_TTL_SECONDS, index_MCP_CONFIRM_STATE_VERSION as MCP_CONFIRM_STATE_VERSION, index_MCP_ERR_HEADER_MISMATCH as MCP_ERR_HEADER_MISMATCH, index_MCP_ERR_INTERNAL as MCP_ERR_INTERNAL, index_MCP_ERR_INVALID_PARAMS as MCP_ERR_INVALID_PARAMS, index_MCP_ERR_INVALID_REQUEST as MCP_ERR_INVALID_REQUEST, index_MCP_ERR_METHOD_NOT_FOUND as MCP_ERR_METHOD_NOT_FOUND, index_MCP_ERR_MISSING_CLIENT_CAPABILITY as MCP_ERR_MISSING_CLIENT_CAPABILITY, index_MCP_ERR_PARSE as MCP_ERR_PARSE, index_MCP_ERR_UNSUPPORTED_VERSION as MCP_ERR_UNSUPPORTED_VERSION, index_MCP_SPEC_2024_11_05 as MCP_SPEC_2024_11_05, index_MCP_SPEC_2026_07_28 as MCP_SPEC_2026_07_28, index_META_KEY_CLIENT_CAPABILITIES as META_KEY_CLIENT_CAPABILITIES, index_META_KEY_CLIENT_INFO as META_KEY_CLIENT_INFO, index_META_KEY_PROTOCOL_VERSION as META_KEY_PROTOCOL_VERSION, index_META_KEY_SERVER_INFO as META_KEY_SERVER_INFO, type index_McpAuditHook as McpAuditHook, type index_McpAuditRecord as McpAuditRecord, type index_McpBridge as McpBridge, type index_McpCacheScope as McpCacheScope, type index_McpConfirmBinding as McpConfirmBinding, type index_McpConfirmDecision as McpConfirmDecision, type index_McpConfirmRejection as McpConfirmRejection, type index_McpConfirmStateStatus as McpConfirmStateStatus, index_McpDispatcher as McpDispatcher, type index_McpEra as McpEra, type index_McpEstablishment as McpEstablishment, type index_McpHandler as McpHandler, type index_McpHttpRequest as McpHttpRequest, type index_McpHttpResponse as McpHttpResponse, type index_McpIdentity as McpIdentity, type index_McpMountOptions as McpMountOptions, type index_McpSpecVersion as McpSpecVersion, type index_McpSplitResult as McpSplitResult, type index_McpStdioOptions as McpStdioOptions, type index_McpStdioServer as McpStdioServer, type index_McpTransport as McpTransport, type index_McpVerifier as McpVerifier, index_ModernMcpHandler as ModernMcpHandler, type index_ModernRequestMeta as ModernRequestMeta, type index_Policy as Policy, index_RESULT_TYPE_COMPLETE as RESULT_TYPE_COMPLETE, index_RESULT_TYPE_INPUT_REQUIRED as RESULT_TYPE_INPUT_REQUIRED, index_RawJSON as RawJSON, type index_ResolvedMcpConfig as ResolvedMcpConfig, index_SCOPES_EXTRA_KEY as SCOPES_EXTRA_KEY, index_SURFACE_CLI as SURFACE_CLI, index_SURFACE_LIB as SURFACE_LIB, index_SURFACE_MCP as SURFACE_MCP, type index_SafetyClass as SafetyClass, type index_Surface as Surface, index_SurfaceNotEnabledError as SurfaceNotEnabledError, index_TASKS_EXTENSION as TASKS_EXTENSION, index_TASKS_SUPPORTED as TASKS_SUPPORTED, index_TASK_METHODS as TASK_METHODS, type index_TaskMethod as TaskMethod, index_UnknownCommandError as UnknownCommandError, index_auditRefusal as auditRefusal, index_buildToolEnvelope as buildToolEnvelope, index_canonicalJSONStringify as canonicalJSONStringify, index_clientSupportsFormElicitation as clientSupportsFormElicitation, index_commanderBridge as commanderBridge, index_createMcpHandler as createMcpHandler, index_decodeMcpSentinel as decodeMcpSentinel, index_defaultPolicy as defaultPolicy, index_detectMcpEra as detectMcpEra, index_discoverCapabilities as discoverCapabilities, index_encodeEnvelope as encodeEnvelope, index_errorResultBlock as errorResultBlock, index_establishCaller as establishCaller, index_hasModernMetaMarker as hasModernMetaMarker, index_headerConfirmationGate as headerConfirmationGate, index_invocationMeta as invocationMeta, index_isTaskMethod as isTaskMethod, index_mcpArgsPublished as mcpArgsPublished, index_mcpConfirmArgsDigest as mcpConfirmArgsDigest, index_mcpConfirmPrincipal as mcpConfirmPrincipal, index_mcpInputSchema as mcpInputSchema, index_mcpMountConfig as mcpMountConfig, index_mcpSplitArguments as mcpSplitArguments, index_mcpToolDescription as mcpToolDescription, index_methodNotAllowedResponse as methodNotAllowedResponse, index_mintMcpConfirmState as mintMcpConfirmState, index_modernInvocationExtra as modernInvocationExtra, index_parseJsonRpcRequest as parseJsonRpcRequest, index_parseMcpConfirmRetry as parseMcpConfirmRetry, index_parseModernMeta as parseModernMeta, index_pathFromToolName as pathFromToolName, index_policyAllowed as policyAllowed, index_rawToolCallName as rawToolCallName, index_renderCallResult as renderCallResult, index_resolveMcpConfig as resolveMcpConfig, index_serveStdio as serveStdio, index_singleHeaderValue as singleHeaderValue, index_toolName as toolName, index_validModernRequestId as validModernRequestId, index_verifyMcpConfirmState as verifyMcpConfirmState };
1484
+ }
1485
+
1486
+ export { McpDispatcher as $, MCP_ERR_METHOD_NOT_FOUND as A, MCP_ERR_MISSING_CLIENT_CAPABILITY as B, type CommanderBridgeOptions as C, DEFAULT_MCP_PATH as D, ElicitationConfirmGate as E, type FlagSchema as F, MCP_ERR_PARSE as G, HEADER_MCP_METHOD as H, type Invocation as I, type JsonRpcErrorObject as J, MCP_ERR_UNSUPPORTED_VERSION as K, type Leaf as L, MCP_ARGS_PROPERTY as M, MCP_SPEC_2024_11_05 as N, MCP_SPEC_2026_07_28 as O, META_KEY_CLIENT_CAPABILITIES as P, META_KEY_CLIENT_INFO as Q, META_KEY_PROTOCOL_VERSION as R, META_KEY_SERVER_INFO as S, type McpAuditHook as T, type McpAuditRecord as U, type McpBridge as V, type McpCacheScope as W, type McpConfirmBinding as X, type McpConfirmDecision as Y, type McpConfirmRejection as Z, type McpConfirmStateStatus as _, DEFAULT_MCP_SERVER_NAME as a, policyAllowed as a$, type McpEra as a0, type McpEstablishment as a1, type McpHandler as a2, type McpHttpRequest as a3, type McpHttpResponse as a4, type McpIdentity as a5, type McpMountOptions as a6, type McpSpecVersion as a7, type McpSplitResult as a8, type McpStdioOptions as a9, commanderBridge as aA, createMcpHandler as aB, decodeMcpSentinel as aC, defaultPolicy as aD, detectMcpEra as aE, discoverCapabilities as aF, encodeEnvelope as aG, errorResultBlock as aH, establishCaller as aI, hasModernMetaMarker as aJ, headerConfirmationGate as aK, invocationMeta as aL, isTaskMethod as aM, mcpArgsPublished as aN, mcpConfirmArgsDigest as aO, mcpConfirmPrincipal as aP, mcpInputSchema as aQ, mcpMountConfig as aR, mcpSplitArguments as aS, mcpToolDescription as aT, methodNotAllowedResponse as aU, mintMcpConfirmState as aV, modernInvocationExtra as aW, parseJsonRpcRequest as aX, parseMcpConfirmRetry as aY, parseModernMeta as aZ, pathFromToolName as a_, type McpStdioServer as aa, type McpTransport as ab, type McpVerifier as ac, ModernMcpHandler as ad, type ModernRequestMeta as ae, type Policy as af, RESULT_TYPE_COMPLETE as ag, RESULT_TYPE_INPUT_REQUIRED as ah, RawJSON as ai, type ResolvedMcpConfig as aj, SCOPES_EXTRA_KEY as ak, SURFACE_CLI as al, SURFACE_LIB as am, SURFACE_MCP as an, type SafetyClass as ao, type Surface as ap, SurfaceNotEnabledError as aq, TASKS_EXTENSION as ar, TASKS_SUPPORTED as as, TASK_METHODS as at, type TaskMethod as au, UnknownCommandError as av, auditRefusal as aw, buildToolEnvelope as ax, canonicalJSONStringify as ay, clientSupportsFormElicitation as az, DEFAULT_MCP_SERVER_VERSION as b, rawToolCallName as b0, renderCallResult as b1, resolveMcpConfig as b2, serveStdio as b3, singleHeaderValue as b4, toolName as b5, validModernRequestId as b6, verifyMcpConfirmState as b7, DEFAULT_TOOL_NAME_SEPARATOR as c, DestructiveBlockedError as d, HEADER_MCP_NAME as e, HEADER_MCP_PROTOCOL_VERSION as f, type InvocationMeta as g, type InvokeResult as h, index as i, type JsonRpcRequest as j, type LeafArg as k, LegacyMcpHandler as l, MCP_AUDIT_AUTH_REFUSED as m, MCP_AUDIT_CONFIRMATION_DECLINED as n, MCP_AUDIT_CONFIRMATION_REQUIRED as o, MCP_AUDIT_CONFIRMATION_STATE_REJECTED as p, MCP_AUDIT_DESTRUCTIVE_BLOCKED as q, MCP_AUTH_CHALLENGE as r, MCP_CONFIRM_KEY as s, MCP_CONFIRM_REJECTION_STATE as t, MCP_CONFIRM_STATE_TTL_SECONDS as u, MCP_CONFIRM_STATE_VERSION as v, MCP_ERR_HEADER_MISMATCH as w, MCP_ERR_INTERNAL as x, MCP_ERR_INVALID_PARAMS as y, MCP_ERR_INVALID_REQUEST as z };