@casys/mcp-server 0.27.0 → 0.27.2

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 (253) hide show
  1. package/CHANGELOG.md +18 -1764
  2. package/README.md +21 -631
  3. package/esm/mod.d.ts +1 -102
  4. package/esm/mod.js +1 -103
  5. package/package.json +17 -25
  6. package/esm/_dnt.polyfills.d.ts +0 -12
  7. package/esm/_dnt.polyfills.d.ts.map +0 -1
  8. package/esm/_dnt.polyfills.js +0 -15
  9. package/esm/_dnt.shims.d.ts +0 -2
  10. package/esm/_dnt.shims.d.ts.map +0 -1
  11. package/esm/_dnt.shims.js +0 -57
  12. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts +0 -33
  13. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.d.ts.map +0 -1
  14. package/esm/deps/jsr.io/@std/yaml/1.2.0/_chars.js +0 -48
  15. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts +0 -106
  16. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.d.ts.map +0 -1
  17. package/esm/deps/jsr.io/@std/yaml/1.2.0/_dumper_state.js +0 -636
  18. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts +0 -67
  19. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.d.ts.map +0 -1
  20. package/esm/deps/jsr.io/@std/yaml/1.2.0/_loader_state.js +0 -1393
  21. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts +0 -44
  22. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.d.ts.map +0 -1
  23. package/esm/deps/jsr.io/@std/yaml/1.2.0/_schema.js +0 -117
  24. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts +0 -3
  25. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.d.ts.map +0 -1
  26. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/binary.js +0 -103
  27. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts +0 -3
  28. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.d.ts.map +0 -1
  29. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/bool.js +0 -32
  30. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts +0 -3
  31. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.d.ts.map +0 -1
  32. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/float.js +0 -96
  33. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts +0 -3
  34. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.d.ts.map +0 -1
  35. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/int.js +0 -159
  36. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts +0 -3
  37. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.d.ts.map +0 -1
  38. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/map.js +0 -14
  39. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts +0 -3
  40. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.d.ts.map +0 -1
  41. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/merge.js +0 -10
  42. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts +0 -3
  43. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.d.ts.map +0 -1
  44. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/nil.js +0 -22
  45. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts +0 -3
  46. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.d.ts.map +0 -1
  47. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/omap.js +0 -29
  48. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts +0 -3
  49. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.d.ts.map +0 -1
  50. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/pairs.js +0 -19
  51. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts +0 -3
  52. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.d.ts.map +0 -1
  53. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/regexp.js +0 -30
  54. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts +0 -3
  55. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.d.ts.map +0 -1
  56. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/seq.js +0 -10
  57. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts +0 -3
  58. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.d.ts.map +0 -1
  59. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/set.js +0 -14
  60. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts +0 -3
  61. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.d.ts.map +0 -1
  62. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/str.js +0 -9
  63. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts +0 -3
  64. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.d.ts.map +0 -1
  65. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/timestamp.js +0 -81
  66. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts +0 -3
  67. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.d.ts.map +0 -1
  68. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type/undefined.js +0 -20
  69. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts +0 -32
  70. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.d.ts.map +0 -1
  71. package/esm/deps/jsr.io/@std/yaml/1.2.0/_type.js +0 -6
  72. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts +0 -4
  73. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.d.ts.map +0 -1
  74. package/esm/deps/jsr.io/@std/yaml/1.2.0/_utils.js +0 -13
  75. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts +0 -51
  76. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.d.ts.map +0 -1
  77. package/esm/deps/jsr.io/@std/yaml/1.2.0/mod.js +0 -53
  78. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts +0 -79
  79. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.d.ts.map +0 -1
  80. package/esm/deps/jsr.io/@std/yaml/1.2.0/parse.js +0 -91
  81. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts +0 -100
  82. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.d.ts.map +0 -1
  83. package/esm/deps/jsr.io/@std/yaml/1.2.0/stringify.js +0 -33
  84. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts +0 -111
  85. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.d.ts.map +0 -1
  86. package/esm/deps/jsr.io/@std/yaml/1.2.0/types.js +0 -104
  87. package/esm/mod.d.ts.map +0 -1
  88. package/esm/package.json +0 -3
  89. package/esm/src/auth/as-metadata-proxy.d.ts +0 -112
  90. package/esm/src/auth/as-metadata-proxy.d.ts.map +0 -1
  91. package/esm/src/auth/as-metadata-proxy.js +0 -171
  92. package/esm/src/auth/config.d.ts +0 -117
  93. package/esm/src/auth/config.d.ts.map +0 -1
  94. package/esm/src/auth/config.js +0 -219
  95. package/esm/src/auth/jwt-provider.d.ts +0 -157
  96. package/esm/src/auth/jwt-provider.d.ts.map +0 -1
  97. package/esm/src/auth/jwt-provider.js +0 -187
  98. package/esm/src/auth/middleware.d.ts +0 -61
  99. package/esm/src/auth/middleware.d.ts.map +0 -1
  100. package/esm/src/auth/middleware.js +0 -209
  101. package/esm/src/auth/mod.d.ts +0 -23
  102. package/esm/src/auth/mod.d.ts.map +0 -1
  103. package/esm/src/auth/mod.js +0 -27
  104. package/esm/src/auth/multi-tenant-middleware.d.ts +0 -131
  105. package/esm/src/auth/multi-tenant-middleware.d.ts.map +0 -1
  106. package/esm/src/auth/multi-tenant-middleware.js +0 -128
  107. package/esm/src/auth/presets.d.ts +0 -231
  108. package/esm/src/auth/presets.d.ts.map +0 -1
  109. package/esm/src/auth/presets.js +0 -223
  110. package/esm/src/auth/provider.d.ts +0 -47
  111. package/esm/src/auth/provider.d.ts.map +0 -1
  112. package/esm/src/auth/provider.js +0 -34
  113. package/esm/src/auth/scope-middleware.d.ts +0 -30
  114. package/esm/src/auth/scope-middleware.d.ts.map +0 -1
  115. package/esm/src/auth/scope-middleware.js +0 -48
  116. package/esm/src/auth/static-token-provider.d.ts +0 -155
  117. package/esm/src/auth/static-token-provider.d.ts.map +0 -1
  118. package/esm/src/auth/static-token-provider.js +0 -256
  119. package/esm/src/auth/types.d.ts +0 -151
  120. package/esm/src/auth/types.d.ts.map +0 -1
  121. package/esm/src/auth/types.js +0 -64
  122. package/esm/src/client-auth/callback-server.d.ts +0 -34
  123. package/esm/src/client-auth/callback-server.d.ts.map +0 -1
  124. package/esm/src/client-auth/callback-server.js +0 -141
  125. package/esm/src/client-auth/client-id-metadata.d.ts +0 -29
  126. package/esm/src/client-auth/client-id-metadata.d.ts.map +0 -1
  127. package/esm/src/client-auth/client-id-metadata.js +0 -149
  128. package/esm/src/client-auth/connect.d.ts +0 -32
  129. package/esm/src/client-auth/connect.d.ts.map +0 -1
  130. package/esm/src/client-auth/connect.js +0 -47
  131. package/esm/src/client-auth/mod.d.ts +0 -19
  132. package/esm/src/client-auth/mod.d.ts.map +0 -1
  133. package/esm/src/client-auth/mod.js +0 -19
  134. package/esm/src/client-auth/provider.d.ts +0 -78
  135. package/esm/src/client-auth/provider.d.ts.map +0 -1
  136. package/esm/src/client-auth/provider.js +0 -246
  137. package/esm/src/client-auth/token-store/file-store.d.ts +0 -20
  138. package/esm/src/client-auth/token-store/file-store.d.ts.map +0 -1
  139. package/esm/src/client-auth/token-store/file-store.js +0 -62
  140. package/esm/src/client-auth/token-store/memory-store.d.ts +0 -14
  141. package/esm/src/client-auth/token-store/memory-store.d.ts.map +0 -1
  142. package/esm/src/client-auth/token-store/memory-store.js +0 -25
  143. package/esm/src/client-auth/types.d.ts +0 -89
  144. package/esm/src/client-auth/types.d.ts.map +0 -1
  145. package/esm/src/client-auth/types.js +0 -10
  146. package/esm/src/concurrency/rate-limiter.d.ts +0 -87
  147. package/esm/src/concurrency/rate-limiter.d.ts.map +0 -1
  148. package/esm/src/concurrency/rate-limiter.js +0 -165
  149. package/esm/src/concurrency/request-queue.d.ts +0 -71
  150. package/esm/src/concurrency/request-queue.d.ts.map +0 -1
  151. package/esm/src/concurrency/request-queue.js +0 -128
  152. package/esm/src/http/body.d.ts +0 -20
  153. package/esm/src/http/body.d.ts.map +0 -1
  154. package/esm/src/http/body.js +0 -63
  155. package/esm/src/http/request-guards.d.ts +0 -54
  156. package/esm/src/http/request-guards.d.ts.map +0 -1
  157. package/esm/src/http/request-guards.js +0 -114
  158. package/esm/src/http/wire.d.ts +0 -26
  159. package/esm/src/http/wire.d.ts.map +0 -1
  160. package/esm/src/http/wire.js +0 -35
  161. package/esm/src/inspector/launcher.d.ts +0 -48
  162. package/esm/src/inspector/launcher.d.ts.map +0 -1
  163. package/esm/src/inspector/launcher.js +0 -100
  164. package/esm/src/mcp-app.d.ts +0 -728
  165. package/esm/src/mcp-app.d.ts.map +0 -1
  166. package/esm/src/mcp-app.js +0 -3530
  167. package/esm/src/middleware/backpressure.d.ts +0 -24
  168. package/esm/src/middleware/backpressure.d.ts.map +0 -1
  169. package/esm/src/middleware/backpressure.js +0 -31
  170. package/esm/src/middleware/mod.d.ts +0 -11
  171. package/esm/src/middleware/mod.d.ts.map +0 -1
  172. package/esm/src/middleware/mod.js +0 -11
  173. package/esm/src/middleware/rate-limit.d.ts +0 -22
  174. package/esm/src/middleware/rate-limit.d.ts.map +0 -1
  175. package/esm/src/middleware/rate-limit.js +0 -33
  176. package/esm/src/middleware/runner.d.ts +0 -32
  177. package/esm/src/middleware/runner.d.ts.map +0 -1
  178. package/esm/src/middleware/runner.js +0 -49
  179. package/esm/src/middleware/types.d.ts +0 -76
  180. package/esm/src/middleware/types.d.ts.map +0 -1
  181. package/esm/src/middleware/types.js +0 -9
  182. package/esm/src/middleware/validation.d.ts +0 -24
  183. package/esm/src/middleware/validation.d.ts.map +0 -1
  184. package/esm/src/middleware/validation.js +0 -30
  185. package/esm/src/mrtr/capability-check.d.ts +0 -75
  186. package/esm/src/mrtr/capability-check.d.ts.map +0 -1
  187. package/esm/src/mrtr/capability-check.js +0 -233
  188. package/esm/src/mrtr/mod.d.ts +0 -18
  189. package/esm/src/mrtr/mod.d.ts.map +0 -1
  190. package/esm/src/mrtr/mod.js +0 -12
  191. package/esm/src/mrtr/replay-store.d.ts +0 -50
  192. package/esm/src/mrtr/replay-store.d.ts.map +0 -1
  193. package/esm/src/mrtr/replay-store.js +0 -61
  194. package/esm/src/mrtr/request-state.d.ts +0 -181
  195. package/esm/src/mrtr/request-state.d.ts.map +0 -1
  196. package/esm/src/mrtr/request-state.js +0 -313
  197. package/esm/src/mrtr/retry-guard.d.ts +0 -61
  198. package/esm/src/mrtr/retry-guard.d.ts.map +0 -1
  199. package/esm/src/mrtr/retry-guard.js +0 -53
  200. package/esm/src/mrtr/types.d.ts +0 -99
  201. package/esm/src/mrtr/types.d.ts.map +0 -1
  202. package/esm/src/mrtr/types.js +0 -14
  203. package/esm/src/observability/metrics.d.ts +0 -104
  204. package/esm/src/observability/metrics.d.ts.map +0 -1
  205. package/esm/src/observability/metrics.js +0 -207
  206. package/esm/src/observability/mod.d.ts +0 -12
  207. package/esm/src/observability/mod.d.ts.map +0 -1
  208. package/esm/src/observability/mod.js +0 -11
  209. package/esm/src/observability/otel.d.ts +0 -73
  210. package/esm/src/observability/otel.d.ts.map +0 -1
  211. package/esm/src/observability/otel.js +0 -260
  212. package/esm/src/runtime/runtime.d.ts +0 -10
  213. package/esm/src/runtime/runtime.d.ts.map +0 -1
  214. package/esm/src/runtime/runtime.deno.d.ts +0 -50
  215. package/esm/src/runtime/runtime.deno.d.ts.map +0 -1
  216. package/esm/src/runtime/runtime.deno.js +0 -120
  217. package/esm/src/runtime/runtime.js +0 -41
  218. package/esm/src/runtime/runtime.node.d.ts +0 -51
  219. package/esm/src/runtime/runtime.node.d.ts.map +0 -1
  220. package/esm/src/runtime/runtime.node.js +0 -268
  221. package/esm/src/runtime/types.d.ts +0 -107
  222. package/esm/src/runtime/types.d.ts.map +0 -1
  223. package/esm/src/runtime/types.js +0 -12
  224. package/esm/src/security/channel-hmac.d.ts +0 -43
  225. package/esm/src/security/channel-hmac.d.ts.map +0 -1
  226. package/esm/src/security/channel-hmac.js +0 -135
  227. package/esm/src/security/csp.d.ts +0 -50
  228. package/esm/src/security/csp.d.ts.map +0 -1
  229. package/esm/src/security/csp.js +0 -63
  230. package/esm/src/security/message-signer.d.ts +0 -88
  231. package/esm/src/security/message-signer.d.ts.map +0 -1
  232. package/esm/src/security/message-signer.js +0 -166
  233. package/esm/src/subscriptions/subscription-registry.d.ts +0 -256
  234. package/esm/src/subscriptions/subscription-registry.d.ts.map +0 -1
  235. package/esm/src/subscriptions/subscription-registry.js +0 -406
  236. package/esm/src/tasks/mod.d.ts +0 -13
  237. package/esm/src/tasks/mod.d.ts.map +0 -1
  238. package/esm/src/tasks/mod.js +0 -11
  239. package/esm/src/tasks/task-store.d.ts +0 -342
  240. package/esm/src/tasks/task-store.d.ts.map +0 -1
  241. package/esm/src/tasks/task-store.js +0 -649
  242. package/esm/src/transport/request-headers.d.ts +0 -145
  243. package/esm/src/transport/request-headers.d.ts.map +0 -1
  244. package/esm/src/transport/request-headers.js +0 -525
  245. package/esm/src/types.d.ts +0 -776
  246. package/esm/src/types.d.ts.map +0 -1
  247. package/esm/src/types.js +0 -92
  248. package/esm/src/ui/viewer-utils.d.ts +0 -45
  249. package/esm/src/ui/viewer-utils.d.ts.map +0 -1
  250. package/esm/src/ui/viewer-utils.js +0 -97
  251. package/esm/src/validation/schema-validator.d.ts +0 -115
  252. package/esm/src/validation/schema-validator.d.ts.map +0 -1
  253. package/esm/src/validation/schema-validator.js +0 -249
@@ -1,776 +0,0 @@
1
- /**
2
- * Type definitions for the MCP Concurrent Server Framework
3
- *
4
- * This module provides TypeScript types for building high-performance
5
- * MCP servers with built-in concurrency control and backpressure.
6
- *
7
- * @module lib/server/types
8
- */
9
- import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/sdk/types.js";
10
- /**
11
- * Rate limit configuration
12
- */
13
- export interface RateLimitOptions {
14
- /** Maximum requests per window */
15
- maxRequests: number;
16
- /** Time window in milliseconds */
17
- windowMs: number;
18
- /**
19
- * Function to extract client identifier from request context
20
- * Default: uses "default" for all requests (global rate limit)
21
- */
22
- keyExtractor?: (context: RateLimitContext) => string;
23
- /**
24
- * Behavior when rate limit is exceeded
25
- * - 'reject': Return error immediately
26
- * - 'wait': Wait for slot with backoff (default)
27
- */
28
- onLimitExceeded?: "reject" | "wait";
29
- }
30
- /**
31
- * Context passed to rate limit key extractor
32
- */
33
- export interface RateLimitContext {
34
- /** Tool being called */
35
- toolName: string;
36
- /** Tool arguments */
37
- args: Record<string, unknown>;
38
- }
39
- /**
40
- * Configuration options for McpApp
41
- */
42
- export interface McpAppOptions {
43
- /** Server name (shown in MCP protocol) */
44
- name: string;
45
- /** Server version */
46
- version: string;
47
- /** Maximum concurrent requests (default: 10) */
48
- maxConcurrent?: number;
49
- /** Backpressure strategy when at capacity (default: 'sleep') */
50
- backpressureStrategy?: "sleep" | "queue" | "reject";
51
- /** Sleep duration in ms for 'sleep' strategy (default: 10) */
52
- backpressureSleepMs?: number;
53
- /**
54
- * Rate limiting configuration
55
- * If provided, requests will be rate limited per client
56
- */
57
- rateLimit?: RateLimitOptions;
58
- /**
59
- * Enable JSON Schema validation for tool arguments (default: false)
60
- * When enabled, validates arguments against tool's inputSchema before execution
61
- */
62
- validateSchema?: boolean;
63
- /**
64
- * @deprecated No-op as of 0.24.0. The SamplingBridge was removed in the
65
- * MCP 2026-07-28 spec drop. Passing this option has zero effect and emits
66
- * a console warning at startup. Will be removed in 0.25.0.
67
- */
68
- enableSampling?: boolean;
69
- /**
70
- * Instructions for the LLM on how to use this server's tools.
71
- * Sent in the MCP initialize response. The LLM sees this before any tool call.
72
- */
73
- instructions?: string;
74
- /**
75
- * @deprecated No-op as of 0.24.0. The SamplingBridge was removed in the
76
- * MCP 2026-07-28 spec drop. Passing this option has zero effect and emits
77
- * a console warning at startup. Will be removed in 0.25.0.
78
- */
79
- samplingClient?: SamplingClient;
80
- /** Custom logger function (default: console.error) */
81
- logger?: (msg: string) => void;
82
- /**
83
- * Custom error handler for tool execution errors.
84
- *
85
- * When set, errors thrown by tool handlers are passed to this function.
86
- * Return a message string to produce `{ content: [{type:"text", text: msg}], isError: true }`
87
- * instead of re-throwing. Return null to rethrow as a JSON-RPC error.
88
- *
89
- * Default: undefined (all errors are re-thrown, existing behaviour).
90
- */
91
- toolErrorMapper?: ToolErrorMapper;
92
- /**
93
- * OAuth2/Bearer authentication configuration.
94
- * When provided, HTTP requests require a valid Bearer token.
95
- * STDIO transport is unaffected (local, no auth needed).
96
- */
97
- auth?: import("./auth/types.js").AuthOptions;
98
- /**
99
- * Content Security Policy for HTML resources (MCP Apps).
100
- * When provided, injects a CSP `<meta>` tag into HTML content before serving.
101
- * This protects against XSS even in STDIO mode where HTTP headers are unavailable.
102
- *
103
- * @example
104
- * ```typescript
105
- * resourceCsp: { allowInline: true }
106
- * ```
107
- */
108
- resourceCsp?: import("./security/csp.js").CspOptions;
109
- /**
110
- * Pre-declare the `resources` capability before transport connection.
111
- *
112
- * When true, installs `resources/list` and `resources/read` handlers at
113
- * construction time (before start/startHttp). Resources can then be added
114
- * dynamically after startup via registerResource() without hitting the
115
- * SDK's "Cannot register capabilities after connecting to transport" error.
116
- *
117
- * Use this when resources are discovered asynchronously (e.g., MCP relay/proxy
118
- * that discovers child servers after the stdio handshake).
119
- */
120
- expectResources?: boolean;
121
- /**
122
- * HTTP transport mode. Only `"stateless"` is supported as of spec 2026-07-28.
123
- *
124
- * Per-request transport: no handshake, no `Mcp-Session-Id`.
125
- * `protocolVersion` is read from
126
- * `params._meta["io.modelcontextprotocol/protocolVersion"]` on every
127
- * request. `GET /mcp` returns 405; use `subscriptions/listen` instead.
128
- */
129
- transport?: "stateless";
130
- /**
131
- * Cache hints emitted on list and read results (spec 2026-07-28,
132
- * `CacheableResult`, SEP-2549).
133
- *
134
- * `ttlMs` and `cacheScope` are **required** fields of those results, so the
135
- * framework always emits them. The defaults are deliberately inert:
136
- *
137
- * - `ttlMs: 0` — "revalidate every time", the HTTP `max-age=0` equivalent.
138
- * Caching is a per-deployment decision: a server whose tool list is built
139
- * from a live database must not have a stale window chosen for it. Opt in
140
- * with a real value.
141
- * - `cacheScope: "private"` — shared intermediaries must not cache the
142
- * response. Anything else would be unsafe by default here, since results can
143
- * be scoped to the authenticated principal or tenant. Use `"public"` only for
144
- * a server whose lists are genuinely identical for every caller.
145
- */
146
- cache?: {
147
- /** Freshness window in milliseconds. Default `0`. */
148
- ttlMs?: number;
149
- /** Whether shared caches may store the response. Default `"private"`. */
150
- scope?: "public" | "private";
151
- };
152
- /**
153
- * Authorization key a task is bound to, derived from the request that created it.
154
- *
155
- * A task can only be read, answered or cancelled by a caller whose key matches.
156
- * The default is the authenticated subject, which is right for a
157
- * single-authority deployment and **not enough** for anything that authorizes on
158
- * more than identity: a tenant-scoped server where the same subject may act for
159
- * several tenants needs the tenant in the key, or a task created under one
160
- * tenant stays reachable from another.
161
- *
162
- * The framework cannot derive that itself — tenancy lives in a consumer's own
163
- * middleware — so it is a hook rather than a guess. Return a stable string; it is
164
- * compared verbatim.
165
- *
166
- * **It must derive everything from its two arguments.** `tasks/*` requests do
167
- * not run the middleware pipeline, so anything a middleware injects into the
168
- * pipeline context — the built-in tenant middleware's `tenantId`, for instance —
169
- * is NOT visible here. Read the header, or resolve it yourself; the hook may be
170
- * async precisely so a lookup is possible. A hook that expects pipeline state
171
- * silently sees `undefined` on every call, which collapses every caller onto one
172
- * key.
173
- *
174
- * Returning an empty or non-string value is refused rather than accepted, since
175
- * that is what the obvious implementation yields when the value it reads is
176
- * absent, and accepting it would share tasks between callers.
177
- *
178
- * Called on task creation and on every `tasks/get` / `tasks/update` /
179
- * `tasks/cancel`. It must return the same key for the same caller across those
180
- * calls, or the creator stops being able to reach its own task (fail-closed).
181
- *
182
- * @example
183
- * ```typescript
184
- * taskOwnerKey: (authInfo, request) =>
185
- * `${authInfo?.subject}@${request.headers.get("x-tenant-id")}`
186
- * ```
187
- */
188
- taskOwnerKey?: (authInfo: import("./auth/types.js").AuthInfo | undefined, request: Request) => string | Promise<string>;
189
- /**
190
- * Multi Round-Trip Requests (spec 2026-07-28, SEP-2322).
191
- *
192
- * Configures how `requestState` is protected when a tool handler asks the
193
- * client for input mid-call. Consulted by stateless HTTP and by the v2 stdio
194
- * serving entry. On a legacy stdio connection the SDK fulfils the embedded
195
- * requests through its compatibility shim, then re-enters the same verified
196
- * handler; application code keeps one MRTR contract across both eras.
197
- *
198
- * Without `signingKey`, `requestState` travels unprotected and the server logs
199
- * a warning at startup. That is only acceptable when tampering with it can
200
- * cause nothing worse than the request failing.
201
- */
202
- mrtr?: import("./mrtr/mod.js").MrtrOptions;
203
- /**
204
- * Protocol extensions this server declares (spec 2026-07-28).
205
- *
206
- * Keyed by reverse-DNS extension identifier — e.g.
207
- * `{ "io.modelcontextprotocol/tasks": {} }`. Surfaced under
208
- * `capabilities.extensions` on `server/discover` and `initialize`, and only
209
- * when non-empty: an empty object would assert "no extensions supported",
210
- * which is a claim the framework cannot make on a consumer's behalf.
211
- *
212
- * Declaring an extension here does not implement it — it advertises what the
213
- * consumer has wired up.
214
- */
215
- extensions?: Readonly<Record<string, unknown>>;
216
- }
217
- /**
218
- * MCP Apps UI metadata for tools (SEP-1865 + PML extensions)
219
- *
220
- * Mirrors the structural fields of the official MCP Apps `McpUiToolMeta`
221
- * contract and adds PML-specific `emits`/`accepts` fields for cross-UI sync
222
- * rules. Keeping this public declaration structural avoids leaking the
223
- * upstream package's internal declaration-module layout into Node consumers.
224
- *
225
- * @example
226
- * ```typescript
227
- * const tool: MCPTool = {
228
- * name: "query_table",
229
- * description: "Query database table",
230
- * inputSchema: { ... },
231
- * _meta: {
232
- * ui: {
233
- * resourceUri: "ui://mcp-std/table-viewer",
234
- * emits: ["filter", "select"],
235
- * accepts: ["setData", "highlight"]
236
- * }
237
- * }
238
- * };
239
- * ```
240
- */
241
- export interface McpUiToolMeta {
242
- /**
243
- * Resource URI for the UI. MUST use ui:// scheme.
244
- * Narrows the optional base field to required for server tools.
245
- * @example "ui://mcp-std/table-viewer"
246
- */
247
- resourceUri: string;
248
- /**
249
- * Who can access this tool. Defaults to both the model and the app.
250
- */
251
- visibility?: Array<"model" | "app">;
252
- /** CSP belongs on the UI resource, not on tool metadata. */
253
- csp?: never;
254
- /** Permissions belong on the UI resource, not on tool metadata. */
255
- permissions?: never;
256
- /**
257
- * Events this UI can emit (PML extension for sync rules)
258
- * Used by PML orchestrator to build cross-UI event routing
259
- * @example ["filter", "select", "sort", "paginate"]
260
- */
261
- emits?: string[];
262
- /**
263
- * Events this UI can accept (PML extension for sync rules)
264
- * Used by PML orchestrator to build cross-UI event routing
265
- * @example ["setData", "highlight", "scrollTo"]
266
- */
267
- accepts?: string[];
268
- }
269
- /**
270
- * MCP Tool metadata container.
271
- *
272
- * Carries optional UI hints and routing metadata for MCP Apps (SEP-1865).
273
- */
274
- export interface MCPToolMeta {
275
- /** UI configuration for rendering this tool's output in an MCP App */
276
- ui?: McpUiToolMeta;
277
- }
278
- /**
279
- * MCP Resource definition for registration
280
- */
281
- export interface MCPResource {
282
- /**
283
- * Resource URI. SHOULD use ui:// scheme for MCP Apps.
284
- * @example "ui://mcp-std/table-viewer"
285
- */
286
- uri: string;
287
- /** Human-readable name */
288
- name: string;
289
- /** Description of the resource */
290
- description?: string;
291
- /** Optional display title, distinct from the protocol-required `name`. */
292
- title?: string;
293
- /** Optional visual hints advertised in `resources/list`. */
294
- icons?: Array<{
295
- src: string;
296
- mimeType?: string;
297
- sizes?: string[];
298
- theme?: "light" | "dark";
299
- }>;
300
- /** Optional client-facing resource annotations. */
301
- annotations?: {
302
- audience?: Array<"user" | "assistant">;
303
- priority?: number;
304
- lastModified?: string;
305
- };
306
- /** Optional protocol/extension metadata advertised in `resources/list`. */
307
- _meta?: Record<string, unknown>;
308
- /** MIME type, when known before the resource is read. */
309
- mimeType?: string;
310
- /**
311
- * Byte size of the resource when it is known.
312
- *
313
- * This is an exact byte-size attestation: when supplied, every read must
314
- * return exactly this many UTF-8 bytes for `text`, or decoded bytes for
315
- * `blob`. It is surfaced in `resources/list` so clients can make loading
316
- * decisions before reading. Must be a non-negative safe integer.
317
- */
318
- size?: number;
319
- }
320
- /**
321
- * Common fields of every resource response.
322
- */
323
- interface ResourceContentBase {
324
- /** URI of the resource. It must exactly match the URI that was requested. */
325
- uri: string;
326
- /** Non-empty MIME type of the content. */
327
- mimeType: string;
328
- /** Optional MCP metadata passed through to the protocol response. */
329
- _meta?: Record<string, unknown>;
330
- }
331
- /** A UTF-8/text resource response. */
332
- export interface TextResourceContent extends ResourceContentBase {
333
- /** Text payload, including HTML for MCP Apps. */
334
- text: string;
335
- /** Text and blob payloads are mutually exclusive. */
336
- blob?: never;
337
- }
338
- /** A binary resource response encoded as canonical standard base64. */
339
- export interface BlobResourceContent extends ResourceContentBase {
340
- /** Standard, padded base64 payload. */
341
- blob: string;
342
- /** Text and blob payloads are mutually exclusive. */
343
- text?: never;
344
- }
345
- /**
346
- * Content returned by a resource handler.
347
- *
348
- * Exactly one payload form is allowed: `text` for text/HTML, or `blob` for
349
- * binary content encoded as canonical standard base64. The framework validates
350
- * the same XOR contract at runtime before writing the response, which keeps
351
- * JavaScript consumers and unchecked handler results on the protocol-safe path.
352
- */
353
- export type ResourceContent = TextResourceContent | BlobResourceContent;
354
- /**
355
- * Resource handler callback
356
- *
357
- * @param uri - The requested resource URI as URL object
358
- * @returns A text or base64-blob ResourceContent whose URI matches `uri`
359
- *
360
- * @example
361
- * ```typescript
362
- * const handler: ResourceHandler = async (uri) => ({
363
- * uri: uri.toString(),
364
- * mimeType: MCP_APP_MIME_TYPE,
365
- * text: "<html>...</html>"
366
- * });
367
- *
368
- * // For binary content, return `blob` instead of `text`:
369
- * // { uri: uri.toString(), mimeType: "image/png", blob: "iVBORw0KGgo..." }
370
- * ```
371
- */
372
- export type ResourceHandler = (uri: URL) => Promise<ResourceContent> | ResourceContent;
373
- /** MCP Apps MIME type constant */
374
- export declare const MCP_APP_MIME_TYPE: "text/html;profile=mcp-app";
375
- /** URI scheme for MCP Apps resources */
376
- export declare const MCP_APP_URI_SCHEME: "ui:";
377
- /**
378
- * Well-known extension identifier for the MCP Apps protocol.
379
- *
380
- * Clients advertise MCP Apps support by including this key in
381
- * `clientCapabilities.extensions` (per the MCP SDK 1.29 extensions
382
- * feature). Servers read it via {@link getMcpAppsCapability} to decide
383
- * whether to register UI-rendering tools or fall back to text-only.
384
- *
385
- * @see {@link https://github.com/modelcontextprotocol/ext-apps | MCP Apps spec}
386
- */
387
- export declare const MCP_APPS_EXTENSION_ID: "io.modelcontextprotocol/ui";
388
- /**
389
- * MCP Apps protocol spec version this package targets.
390
- *
391
- * Matches the dated spec at
392
- * https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
393
- *
394
- * Bump this constant in the same commit that adopts a newer dated spec.
395
- */
396
- export declare const MCP_APPS_PROTOCOL_VERSION: "2026-01-26";
397
- /**
398
- * MCP Apps capability advertised by a client.
399
- *
400
- * Returned by {@link getMcpAppsCapability} after reading
401
- * `clientCapabilities.extensions[MCP_APPS_EXTENSION_ID]`.
402
- *
403
- * The capability object is intentionally minimal — the spec keeps it
404
- * extensible by adding fields rather than removing them, so consumers
405
- * MUST tolerate unknown fields.
406
- */
407
- export interface McpAppsClientCapability {
408
- /**
409
- * MIME types the client can render as MCP Apps.
410
- *
411
- * Typically includes `"text/html;profile=mcp-app"`. An empty or
412
- * absent array means the client advertised support but listed no
413
- * concrete mime types — defensively assume nothing.
414
- */
415
- mimeTypes?: string[];
416
- }
417
- /**
418
- * Read the MCP Apps capability from a client's advertised capabilities.
419
- *
420
- * Best-effort, defensive reader. Returns `undefined` for any of:
421
- * - `null` / `undefined` input
422
- * - `clientCapabilities` without an `extensions` field
423
- * - `extensions` without the {@link MCP_APPS_EXTENSION_ID} key
424
- * - extension value that is not a plain object (string, number, null, ...)
425
- *
426
- * Malformed `mimeTypes` (wrong type, non-string entries) are silently
427
- * filtered rather than thrown — agents reading this function need a
428
- * predictable contract that never crashes downstream consumers on
429
- * untrusted client data.
430
- *
431
- * **Validation scope:** this function only validates the *type* of
432
- * `mimeTypes` entries (must be string). It does NOT validate that the
433
- * strings look like valid mime types (e.g. empty strings or garbage
434
- * content pass through). Consumers should compare against known
435
- * constants like {@link MCP_APP_MIME_TYPE} via `.includes()` rather
436
- * than treating the array as a generic allowlist.
437
- *
438
- * @param clientCapabilities - The `ClientCapabilities` object from the
439
- * MCP SDK initialize handshake. May be `null` or `undefined` if the
440
- * client never sent capabilities.
441
- * @returns The MCP Apps capability if the client advertised support,
442
- * otherwise `undefined`.
443
- *
444
- * @example
445
- * ```typescript
446
- * const cap = getMcpAppsCapability(client.getClientCapabilities());
447
- * if (cap?.mimeTypes?.includes(MCP_APP_MIME_TYPE)) {
448
- * // register UI-rendering tools
449
- * } else {
450
- * // register text-only fallback tools
451
- * }
452
- * ```
453
- */
454
- export declare function getMcpAppsCapability(clientCapabilities: (Record<string, unknown> & {
455
- extensions?: Record<string, unknown>;
456
- }) | null | undefined): McpAppsClientCapability | undefined;
457
- /**
458
- * Behavioural hints for model clients (MCP SDK 1.27 ToolAnnotations).
459
- * Passed through in tools/list so hosts can adapt their UI accordingly.
460
- */
461
- export interface ToolAnnotations {
462
- /** Short human-readable title, may differ from tool name */
463
- title?: string;
464
- /** If true, tool has no side-effects and is safe to call speculatively */
465
- readOnlyHint?: boolean;
466
- /** If true, executing may produce irreversible effects */
467
- destructiveHint?: boolean;
468
- /** If true, repeated calls with same args produce same result */
469
- idempotentHint?: boolean;
470
- /** If true, tool may interact with entities outside the MCP system */
471
- openWorldHint?: boolean;
472
- }
473
- /**
474
- * MCP Tool definition (compatible with MCP protocol)
475
- */
476
- export interface MCPTool {
477
- /** Tool name */
478
- name: string;
479
- /** Human-readable description */
480
- description: string;
481
- /** JSON Schema for tool input */
482
- inputSchema: Record<string, unknown>;
483
- /**
484
- * JSON Schema for the tool's structured output (MCP SDK 1.27).
485
- * Passed through in tools/list so hosts can validate tool results.
486
- */
487
- outputSchema?: Record<string, unknown>;
488
- /** Behavioural hints passed to model clients */
489
- annotations?: ToolAnnotations;
490
- /**
491
- * Tool metadata including UI configuration for MCP Apps
492
- * @see McpUiToolMeta
493
- */
494
- _meta?: MCPToolMeta;
495
- /**
496
- * Required OAuth scopes to call this tool.
497
- * Enforced for HTTP calls. A scoped HTTP tool fails closed when the server has
498
- * no auth provider or the authenticated caller lacks one of these scopes.
499
- * STDIO is a trusted local transport and does not apply OAuth scope checks.
500
- * If empty or undefined, no scope check is performed.
501
- */
502
- requiredScopes?: string[];
503
- }
504
- /**
505
- * Tool handler function.
506
- *
507
- * Receives validated arguments and returns a result (or throws).
508
- * The return value is serialised as JSON inside a `text` content block.
509
- *
510
- * **Security**: Never pass `args` values directly to shell commands or SQL.
511
- * Always validate / sanitise inside the handler or via `inputSchema`.
512
- *
513
- * @param args - Validated tool arguments from the MCP client
514
- * @returns Tool result (string, object, or Promise thereof)
515
- *
516
- * @example
517
- * ```typescript
518
- * const handler: ToolHandler = async (args) => {
519
- * const rows = await db.query(args.sql as string);
520
- * return { rows, count: rows.length };
521
- * };
522
- * ```
523
- */
524
- export interface ToolHandlerContext {
525
- readonly toolName: string;
526
- readonly request?: Request;
527
- readonly sessionId?: string;
528
- readonly authInfo?: import("./auth/types.js").AuthInfo;
529
- readonly clientInfo?: Implementation;
530
- readonly clientCapabilities?: ClientCapabilities;
531
- /**
532
- * Answers to a previous `InputRequiredResult`, keyed by the ids the server
533
- * assigned (spec 2026-07-28 MRTR).
534
- *
535
- * Present only on a retry. Read from `params.inputResponses` — a sibling of
536
- * `_meta`, not a member of it, unlike every other per-request field. Getting
537
- * that wrong yields a silent `undefined` even when the client sent them.
538
- */
539
- readonly inputResponses?: Record<string, unknown>;
540
- /**
541
- * True when the client echoed a `requestState` that passed integrity
542
- * verification, so the handler may trust this is a legitimate retry of its own
543
- * earlier request.
544
- *
545
- * The token carries no application state — it binds the principal, method,
546
- * argument digest and expiry. Since the digest guarantees the arguments are
547
- * byte-identical to the original call, a handler reconstructs its context from
548
- * those arguments rather than from the token.
549
- */
550
- readonly retryVerified?: boolean;
551
- /**
552
- * Log level requested for this call (spec 2026-07-28), read from
553
- * `params._meta["io.modelcontextprotocol/logLevel"]`.
554
- *
555
- * `undefined` means the client requested no logging. A handler **MUST NOT**
556
- * emit `notifications/message` in that case — the level is not a filter you
557
- * may default, it is the client's opt-in.
558
- */
559
- readonly logLevel?: import("./middleware/types.js").McpLogLevel;
560
- }
561
- export type ToolHandler = (args: Record<string, unknown>, ctx?: ToolHandlerContext) => Promise<unknown> | unknown;
562
- /**
563
- * Structured tool result: separates the LLM text summary (content)
564
- * from the machine-readable payload (structuredContent).
565
- *
566
- * When a ToolHandler returns this shape, the framework produces a
567
- * CallToolResult with both `content` and `structuredContent` set,
568
- * keeping heavy data out of the LLM context.
569
- */
570
- export interface StructuredToolResult {
571
- /** Human-readable summary shown in content[0].text */
572
- content: string;
573
- /** Structured data conforming to the tool's outputSchema */
574
- structuredContent: Record<string, unknown>;
575
- }
576
- /**
577
- * Maps a thrown error to either a business error result (isError: true)
578
- * or signals that the error should be re-thrown as a JSON-RPC error.
579
- *
580
- * @returns A message string to produce `{ isError: true }`, or null to rethrow.
581
- */
582
- export type ToolErrorMapper = (error: unknown, toolName: string) => string | null;
583
- /**
584
- * Sampling client interface — no-op as of 0.24.0. The SamplingBridge was
585
- * removed with MCP 2026-07-28. This type is kept for source compatibility
586
- * only and will be removed in 0.25.0.
587
- *
588
- * @deprecated No-op as of 0.24.0. Will be removed in 0.25.0.
589
- */
590
- export interface SamplingClient {
591
- /**
592
- * Request LLM completion from the client
593
- * @param params - Sampling parameters (messages, tools, etc.)
594
- * @returns Completion result with content and stop reason
595
- */
596
- createMessage(params: SamplingParams): Promise<SamplingResult>;
597
- }
598
- /**
599
- * Parameters for sampling request — no-op as of 0.24.0.
600
- *
601
- * @deprecated No-op as of 0.24.0. Will be removed in 0.25.0.
602
- */
603
- export interface SamplingParams {
604
- messages: Array<{
605
- role: "user" | "assistant";
606
- content: string;
607
- }>;
608
- /** Tools available for the agent to use. Client handles execution. */
609
- tools?: Array<{
610
- name: string;
611
- description: string;
612
- inputSchema: Record<string, unknown>;
613
- }>;
614
- /** "auto" = LLM decides, "required" = must use tool, "none" = no tools */
615
- toolChoice?: "auto" | "required" | "none";
616
- maxTokens?: number;
617
- /** Hint for client: max agentic loop iterations */
618
- maxIterations?: number;
619
- /** Tool name patterns to filter (e.g., ['git_*', 'vfs_*']) */
620
- allowedToolPatterns?: string[];
621
- }
622
- /**
623
- * Result from sampling request — no-op as of 0.24.0.
624
- *
625
- * @deprecated No-op as of 0.24.0. Will be removed in 0.25.0.
626
- */
627
- export interface SamplingResult {
628
- content: Array<{
629
- type: string;
630
- text?: string;
631
- name?: string;
632
- input?: Record<string, unknown>;
633
- }>;
634
- stopReason: "end_turn" | "tool_use" | "max_tokens";
635
- }
636
- /**
637
- * Queue metrics for monitoring
638
- */
639
- export interface QueueMetrics {
640
- /** Number of requests currently executing */
641
- inFlight: number;
642
- /** Number of requests waiting in queue */
643
- queued: number;
644
- }
645
- /**
646
- * Promise resolver for pending requests
647
- */
648
- export interface PromiseResolver<T = unknown> {
649
- resolve: (value: T) => void;
650
- reject: (error: Error) => void;
651
- }
652
- /**
653
- * Request queue options
654
- */
655
- export interface QueueOptions {
656
- maxConcurrent: number;
657
- strategy: "sleep" | "queue" | "reject";
658
- sleepMs: number;
659
- }
660
- /**
661
- * Context passed to HTTP rate limit key extractor
662
- */
663
- export interface HttpRateLimitContext {
664
- /** Client IP address (from x-forwarded-for/x-real-ip) */
665
- ip: string;
666
- /** HTTP method */
667
- method: string;
668
- /** HTTP path (e.g. /mcp) */
669
- path: string;
670
- /** HTTP headers */
671
- headers: Headers;
672
- /** MCP session ID, if present */
673
- sessionId?: string;
674
- }
675
- /**
676
- * HTTP rate limit configuration
677
- */
678
- export interface HttpRateLimitOptions {
679
- /** Maximum requests per window */
680
- maxRequests: number;
681
- /** Time window in milliseconds */
682
- windowMs: number;
683
- /**
684
- * Function to extract client identifier from HTTP context
685
- * Default: uses IP address
686
- */
687
- keyExtractor?: (context: HttpRateLimitContext) => string;
688
- /**
689
- * Behavior when rate limit is exceeded
690
- * - 'reject': Return error immediately
691
- * - 'wait': Wait for slot with backoff
692
- */
693
- onLimitExceeded?: "reject" | "wait";
694
- }
695
- /**
696
- * Options for starting an HTTP server
697
- */
698
- export type { FetchHandler } from "./runtime/types.js";
699
- import type { FetchHandler } from "./runtime/types.js";
700
- export interface HttpServerOptions {
701
- /**
702
- * Port to listen on. Ignored when {@link embedded} is `true`.
703
- */
704
- port: number;
705
- /** Hostname to bind to (default: "0.0.0.0") */
706
- hostname?: string;
707
- /** Enable CORS (default: true) */
708
- cors?: boolean;
709
- /**
710
- * Allowed CORS origins (default: "*")
711
- * Use an allowlist in production.
712
- */
713
- corsOrigins?: "*" | string[];
714
- /**
715
- * Maximum request body size in bytes (default: 1_000_000).
716
- * Set to null to disable the limit.
717
- */
718
- maxBodyBytes?: number | null;
719
- /**
720
- * Require auth for HTTP mode. If true and auth is not configured, startHttp throws.
721
- */
722
- requireAuth?: boolean;
723
- /**
724
- * IP-based rate limiting for HTTP endpoints.
725
- */
726
- ipRateLimit?: HttpRateLimitOptions;
727
- /**
728
- * Custom HTTP routes registered alongside MCP protocol routes.
729
- * Uses Web standard Request/Response (no framework dependency).
730
- */
731
- customRoutes?: Array<{
732
- method: "get" | "post";
733
- path: string;
734
- handler: (req: Request) => Response | Promise<Response>;
735
- }>;
736
- /**
737
- * Callback when server is ready
738
- * @param info - Server address info
739
- */
740
- onListen?: (info: {
741
- hostname: string;
742
- port: number;
743
- }) => void;
744
- /**
745
- * Embedded mode: skip binding a port and instead surface the Hono fetch
746
- * handler via the {@link embeddedHandlerCallback} option. Used by
747
- * {@link McpApp.getFetchHandler} so consumers (Fresh, Hono,
748
- * Express, etc.) can mount the MCP HTTP stack inside their own server
749
- * without giving up port ownership.
750
- *
751
- * When `true`, `port`, `hostname`, and `onListen` are ignored.
752
- */
753
- embedded?: boolean;
754
- /**
755
- * Receives the Hono fetch handler when running in embedded mode.
756
- * Required when {@link embedded} is `true`. Called exactly once,
757
- * synchronously, before `startHttp` returns.
758
- *
759
- * Most consumers should use {@link McpApp.getFetchHandler}
760
- * instead of setting this directly.
761
- */
762
- embeddedHandlerCallback?: (handler: FetchHandler) => void;
763
- }
764
- /**
765
- * HTTP server instance returned by startHttp
766
- */
767
- export interface HttpServerInstance {
768
- /** Shutdown the HTTP server */
769
- shutdown(): Promise<void>;
770
- /** Server address info */
771
- addr: {
772
- hostname: string;
773
- port: number;
774
- };
775
- }
776
- //# sourceMappingURL=types.d.ts.map