@casys/mcp-server 0.27.0 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/CHANGELOG.md +6 -1770
  2. package/README.md +10 -638
  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,24 +0,0 @@
1
- /**
2
- * Backpressure middleware.
3
- *
4
- * Controls concurrent execution using RequestQueue.
5
- * Acquires a slot before calling next(), releases after.
6
- *
7
- * @module lib/server/middleware/backpressure
8
- */
9
- import type { RequestQueue } from "../concurrency/request-queue.js";
10
- import type { Middleware } from "./types.js";
11
- /**
12
- * Create a backpressure middleware.
13
- *
14
- * Wraps the downstream pipeline in acquire/release:
15
- * ```
16
- * acquire() → next() → release()
17
- * ```
18
- *
19
- * The slot is always released, even if an error occurs.
20
- *
21
- * @param queue - RequestQueue instance with configured concurrency limits
22
- */
23
- export declare function createBackpressureMiddleware(queue: RequestQueue): Middleware;
24
- //# sourceMappingURL=backpressure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"backpressure.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/backpressure.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,YAAY,GAClB,UAAU,CASZ"}
@@ -1,31 +0,0 @@
1
- /**
2
- * Backpressure middleware.
3
- *
4
- * Controls concurrent execution using RequestQueue.
5
- * Acquires a slot before calling next(), releases after.
6
- *
7
- * @module lib/server/middleware/backpressure
8
- */
9
- /**
10
- * Create a backpressure middleware.
11
- *
12
- * Wraps the downstream pipeline in acquire/release:
13
- * ```
14
- * acquire() → next() → release()
15
- * ```
16
- *
17
- * The slot is always released, even if an error occurs.
18
- *
19
- * @param queue - RequestQueue instance with configured concurrency limits
20
- */
21
- export function createBackpressureMiddleware(queue) {
22
- return async (_ctx, next) => {
23
- await queue.acquire();
24
- try {
25
- return await next();
26
- }
27
- finally {
28
- queue.release();
29
- }
30
- };
31
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Middleware module for McpApp.
3
- *
4
- * @module lib/server/middleware
5
- */
6
- export type { Middleware, MiddlewareContext, MiddlewareResult, NextFunction, } from "./types.js";
7
- export { createMiddlewareRunner } from "./runner.js";
8
- export { createRateLimitMiddleware } from "./rate-limit.js";
9
- export { createValidationMiddleware } from "./validation.js";
10
- export { createBackpressureMiddleware } from "./backpressure.js";
11
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/mod.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Middleware module for McpApp.
3
- *
4
- * @module lib/server/middleware
5
- */
6
- // Runner
7
- export { createMiddlewareRunner } from "./runner.js";
8
- // Built-in middlewares
9
- export { createRateLimitMiddleware } from "./rate-limit.js";
10
- export { createValidationMiddleware } from "./validation.js";
11
- export { createBackpressureMiddleware } from "./backpressure.js";
@@ -1,22 +0,0 @@
1
- /**
2
- * Rate limiting middleware.
3
- *
4
- * Extracted from McpApp's inline rate limit logic.
5
- *
6
- * @module lib/server/middleware/rate-limit
7
- */
8
- import type { RateLimiter } from "../concurrency/rate-limiter.js";
9
- import type { RateLimitOptions } from "../types.js";
10
- import type { Middleware } from "./types.js";
11
- /**
12
- * Create a rate limiting middleware.
13
- *
14
- * Behavior depends on `options.onLimitExceeded`:
15
- * - `'reject'`: throws immediately when limit is exceeded
16
- * - `'wait'` (default): waits with backoff until a slot is available
17
- *
18
- * @param limiter - RateLimiter instance
19
- * @param options - Rate limit configuration
20
- */
21
- export declare function createRateLimitMiddleware(limiter: RateLimiter, options: RateLimitOptions): Middleware;
22
- //# sourceMappingURL=rate-limit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/rate-limit.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,gBAAgB,GACxB,UAAU,CAmBZ"}
@@ -1,33 +0,0 @@
1
- /**
2
- * Rate limiting middleware.
3
- *
4
- * Extracted from McpApp's inline rate limit logic.
5
- *
6
- * @module lib/server/middleware/rate-limit
7
- */
8
- /**
9
- * Create a rate limiting middleware.
10
- *
11
- * Behavior depends on `options.onLimitExceeded`:
12
- * - `'reject'`: throws immediately when limit is exceeded
13
- * - `'wait'` (default): waits with backoff until a slot is available
14
- *
15
- * @param limiter - RateLimiter instance
16
- * @param options - Rate limit configuration
17
- */
18
- export function createRateLimitMiddleware(limiter, options) {
19
- return async (ctx, next) => {
20
- const key = options.keyExtractor?.({ toolName: ctx.toolName, args: ctx.args }) ??
21
- "default";
22
- if (options.onLimitExceeded === "reject") {
23
- if (!limiter.checkLimit(key)) {
24
- const waitTime = limiter.getTimeUntilSlot(key);
25
- throw new Error(`Rate limit exceeded. Retry after ${Math.ceil(waitTime / 1000)}s`);
26
- }
27
- }
28
- else {
29
- await limiter.waitForSlot(key);
30
- }
31
- return next();
32
- };
33
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Middleware pipeline runner.
3
- *
4
- * Composes an array of middlewares into a single callable function
5
- * using the onion model: each middleware wraps the next.
6
- *
7
- * @module lib/server/middleware/runner
8
- */
9
- import type { Middleware, MiddlewareContext, MiddlewareResult } from "./types.js";
10
- /**
11
- * Create a middleware runner that composes middlewares + a final handler.
12
- *
13
- * Execution order (onion model):
14
- * ```
15
- * m1-before → m2-before → handler → m2-after → m1-after
16
- * ```
17
- *
18
- * @param middlewares - Array of middleware functions to execute in order
19
- * @param handler - Final handler (the tool execution)
20
- * @returns A function that runs the full pipeline for a given context
21
- *
22
- * @example
23
- * ```typescript
24
- * const run = createMiddlewareRunner(
25
- * [rateLimitMiddleware, validationMiddleware],
26
- * async (ctx) => toolHandler(ctx.args),
27
- * );
28
- * const result = await run({ toolName: "my_tool", args: { x: 1 } });
29
- * ```
30
- */
31
- export declare function createMiddlewareRunner(middlewares: Middleware[], handler: (ctx: MiddlewareContext) => Promise<MiddlewareResult>): (ctx: MiddlewareContext) => Promise<MiddlewareResult>;
32
- //# sourceMappingURL=runner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,UAAU,EAAE,EACzB,OAAO,EAAE,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,GAC7D,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAuBvD"}
@@ -1,49 +0,0 @@
1
- /**
2
- * Middleware pipeline runner.
3
- *
4
- * Composes an array of middlewares into a single callable function
5
- * using the onion model: each middleware wraps the next.
6
- *
7
- * @module lib/server/middleware/runner
8
- */
9
- /**
10
- * Create a middleware runner that composes middlewares + a final handler.
11
- *
12
- * Execution order (onion model):
13
- * ```
14
- * m1-before → m2-before → handler → m2-after → m1-after
15
- * ```
16
- *
17
- * @param middlewares - Array of middleware functions to execute in order
18
- * @param handler - Final handler (the tool execution)
19
- * @returns A function that runs the full pipeline for a given context
20
- *
21
- * @example
22
- * ```typescript
23
- * const run = createMiddlewareRunner(
24
- * [rateLimitMiddleware, validationMiddleware],
25
- * async (ctx) => toolHandler(ctx.args),
26
- * );
27
- * const result = await run({ toolName: "my_tool", args: { x: 1 } });
28
- * ```
29
- */
30
- export function createMiddlewareRunner(middlewares, handler) {
31
- return (ctx) => {
32
- let index = 0;
33
- let handlerCalled = false;
34
- // deno-lint-ignore require-await
35
- const next = async () => {
36
- if (index < middlewares.length) {
37
- const middleware = middlewares[index++];
38
- return middleware(ctx, next);
39
- }
40
- if (handlerCalled) {
41
- throw new Error("[MiddlewareRunner] next() called after pipeline already completed. " +
42
- "A middleware may be calling next() multiple times.");
43
- }
44
- handlerCalled = true;
45
- return handler(ctx);
46
- };
47
- return next();
48
- };
49
- }
@@ -1,76 +0,0 @@
1
- /**
2
- * Middleware pipeline types for McpApp.
3
- *
4
- * Provides an onion-model middleware system (similar to Koa/Hono)
5
- * where each middleware wraps the next, enabling before/after logic.
6
- *
7
- * @module lib/server/middleware/types
8
- */
9
- import type { ClientCapabilities, Implementation } from "@modelcontextprotocol/sdk/types.js";
10
- /**
11
- * MCP logging severities (RFC 5424 syslog levels), ordered least to most severe.
12
- *
13
- * Declared locally rather than imported: the SDK's `LoggingLevel` is tied to the
14
- * `logging/setLevel` RPC that spec 2026-07-28 removed, and this type now serves a
15
- * per-request field instead.
16
- */
17
- export type McpLogLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency";
18
- /**
19
- * Context passed through the middleware pipeline.
20
- * Each middleware can read and enrich the context.
21
- */
22
- export interface MiddlewareContext {
23
- /** Name of the tool being called */
24
- toolName: string;
25
- /** Tool arguments */
26
- args: Record<string, unknown>;
27
- /** HTTP request (only present for HTTP transport, undefined for STDIO) */
28
- request?: Request;
29
- /** Session ID (only present for HTTP transport) */
30
- sessionId?: string;
31
- /** Client implementation metadata (stateless HTTP transport, when provided) */
32
- clientInfo?: Implementation;
33
- /** Client capabilities metadata (stateless HTTP transport, when provided) */
34
- clientCapabilities?: ClientCapabilities;
35
- /** MRTR: answers the client echoed back on a retry (spec 2026-07-28). */
36
- inputResponses?: Record<string, unknown>;
37
- /** MRTR: whether the echoed `requestState` passed integrity verification. */
38
- retryVerified?: boolean;
39
- /**
40
- * Log level the client requested **for this request** (spec 2026-07-28).
41
- *
42
- * Replaces the removed `logging/setLevel` RPC: there is no server-wide level
43
- * to mutate any more, so the level travels with the call that wants it. Absent
44
- * means the client asked for no logging — and the spec is explicit that a
45
- * server **MUST NOT** emit `notifications/message` in that case.
46
- */
47
- logLevel?: McpLogLevel;
48
- /** Extensible by middlewares (e.g., authInfo added by auth middleware) */
49
- [key: string]: unknown;
50
- }
51
- /**
52
- * Result returned by a middleware or the final handler.
53
- */
54
- export type MiddlewareResult = unknown;
55
- /**
56
- * Function to invoke the next middleware in the chain.
57
- */
58
- export type NextFunction = () => Promise<MiddlewareResult>;
59
- /**
60
- * A middleware function.
61
- *
62
- * Receives the context and a `next()` function to call the next middleware.
63
- * Can short-circuit the pipeline by not calling `next()`.
64
- *
65
- * @example
66
- * ```typescript
67
- * const loggingMiddleware: Middleware = async (ctx, next) => {
68
- * console.log(`Before: ${ctx.toolName}`);
69
- * const result = await next();
70
- * console.log(`After: ${ctx.toolName}`);
71
- * return result;
72
- * };
73
- * ```
74
- */
75
- export type Middleware = (ctx: MiddlewareContext, next: NextFunction) => Promise<MiddlewareResult>;
76
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,oCAAoC,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,MAAM,GACN,QAAQ,GACR,SAAS,GACT,OAAO,GACP,UAAU,GACV,OAAO,GACP,WAAW,CAAC;AAEhB;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IAEjB,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9B,0EAA0E;IAC1E,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC,6EAA6E;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC;IAEvB,0EAA0E;IAC1E,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Middleware pipeline types for McpApp.
3
- *
4
- * Provides an onion-model middleware system (similar to Koa/Hono)
5
- * where each middleware wraps the next, enabling before/after logic.
6
- *
7
- * @module lib/server/middleware/types
8
- */
9
- export {};
@@ -1,24 +0,0 @@
1
- /**
2
- * Schema validation middleware.
3
- *
4
- * Validates tool arguments against JSON Schema before execution.
5
- *
6
- * @module lib/server/middleware/validation
7
- */
8
- import type { CompiledSchemaValidator, SchemaValidator } from "../validation/schema-validator.js";
9
- import type { Middleware, MiddlewareContext } from "./types.js";
10
- type CompiledSchemaResolver = (ctx: MiddlewareContext) => CompiledSchemaValidator | undefined;
11
- /**
12
- * Create a schema validation middleware.
13
- *
14
- * Validates `ctx.args` against the registered schema for `ctx.toolName`.
15
- * Throws with a descriptive error if validation fails.
16
- *
17
- * @param validator - SchemaValidator instance with pre-registered schemas
18
- * @param resolveCompiled - Optional replacement for name-based lookup. Return
19
- * undefined when the current call has no schema and validation should be
20
- * skipped.
21
- */
22
- export declare function createValidationMiddleware(validator: SchemaValidator, resolveCompiled?: CompiledSchemaResolver): Middleware;
23
- export {};
24
- //# sourceMappingURL=validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/src/middleware/validation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,eAAe,EAChB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEhE,KAAK,sBAAsB,GAAG,CAC5B,GAAG,EAAE,iBAAiB,KACnB,uBAAuB,GAAG,SAAS,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,eAAe,EAC1B,eAAe,CAAC,EAAE,sBAAsB,GACvC,UAAU,CAUZ"}
@@ -1,30 +0,0 @@
1
- /**
2
- * Schema validation middleware.
3
- *
4
- * Validates tool arguments against JSON Schema before execution.
5
- *
6
- * @module lib/server/middleware/validation
7
- */
8
- /**
9
- * Create a schema validation middleware.
10
- *
11
- * Validates `ctx.args` against the registered schema for `ctx.toolName`.
12
- * Throws with a descriptive error if validation fails.
13
- *
14
- * @param validator - SchemaValidator instance with pre-registered schemas
15
- * @param resolveCompiled - Optional replacement for name-based lookup. Return
16
- * undefined when the current call has no schema and validation should be
17
- * skipped.
18
- */
19
- export function createValidationMiddleware(validator, resolveCompiled) {
20
- // deno-lint-ignore require-await
21
- return async (ctx, next) => {
22
- if (resolveCompiled) {
23
- resolveCompiled(ctx)?.validateOrThrow(ctx.toolName, ctx.args);
24
- }
25
- else {
26
- validator.validateOrThrow(ctx.toolName, ctx.args);
27
- }
28
- return next();
29
- };
30
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * Capability check for MRTR inputRequests (spec 2026-07-28, SEP-2322).
3
- *
4
- * Rule 7 (MUST NOT): "Servers MUST NOT emit an inputRequest for a capability
5
- * the client has not declared in io.modelcontextprotocol/clientCapabilities."
6
- *
7
- * In the stateless transport model, `clientCapabilities` is per-request: it
8
- * arrives in `params._meta["io.modelcontextprotocol/clientCapabilities"]` and
9
- * is therefore already parsed by the time this check runs. There is no session
10
- * to cache it from — each call carries its own capability declaration.
11
- *
12
- * The function is pure: it takes the data it needs and returns a typed result.
13
- * No network, no server state, no side effects.
14
- *
15
- * @module lib/server/mrtr/capability-check
16
- */
17
- import type { InputRequestEntry } from "./types.js";
18
- /** Successful capability check — all methods map to declared capabilities. */
19
- export interface CapabilityCheckOk {
20
- /**
21
- * The canonical form of `inputRequests` — the value the caller MUST emit.
22
- *
23
- * Checking a JSON clone and then serialising the original is two serialisations,
24
- * and a stateful `toJSON()` can return different values for each. That is not a
25
- * theoretical gap: it reopens exactly the bypass canonicalisation was added to
26
- * close. Emit this, not the input.
27
- */
28
- readonly canonicalRequests?: Record<string, unknown>;
29
- readonly ok: true;
30
- }
31
- /** Failed capability check — one or more capabilities are missing. */
32
- export interface CapabilityCheckFail {
33
- /**
34
- * Which fault this is.
35
- *
36
- * `missing_capability` — the client did not declare something the request needs.
37
- * That is the client's to fix, and `-32021` says exactly that.
38
- *
39
- * `malformed` — the SERVER produced an input request that is structurally
40
- * invalid: an unknown method, a missing or non-object `params`, a map that will
41
- * not serialise. Reporting those as a missing capability tells the client to
42
- * declare something it already has, and hides a server bug behind a client-facing
43
- * error.
44
- */
45
- readonly kind: "missing_capability" | "malformed";
46
- /**
47
- * `ClientCapabilities`-shaped payload for the error's `data`, when the missing
48
- * capability is nested. Absent for top-level ones, where the caller derives it
49
- * from `missingCapabilities`.
50
- */
51
- readonly requiredCapabilities?: Record<string, unknown>;
52
- readonly ok: false;
53
- /**
54
- * Top-level `ClientCapabilities` keys the client did not declare but the
55
- * `inputRequests` map requires.
56
- *
57
- * Forward these directly into `-32021 MissingRequiredClientCapabilityError`
58
- * as `data.requiredCapabilities` (spec 2026-07-28 §per-request protocol fields).
59
- *
60
- * Example: `["sampling", "elicitation"]` if both are absent.
61
- */
62
- readonly missingCapabilities: string[];
63
- }
64
- export type CapabilityCheckResult = CapabilityCheckOk | CapabilityCheckFail;
65
- /**
66
- * The only methods an input request may carry, mapped to the capability each needs.
67
- *
68
- * Exported so the Tasks boundary enforces the same grammar. A task that requests
69
- * input uses MRTR request shapes, and a second, looser list there is how a task
70
- * ends up asking for a method no client implements — which strands it rather than
71
- * failing it.
72
- */
73
- export declare const METHOD_TO_CAPABILITY: Readonly<Record<string, string>>;
74
- export declare function checkInputRequestCapabilities(inputRequests: Record<string, InputRequestEntry>, clientCapabilities: Record<string, unknown> | undefined): CapabilityCheckResult;
75
- //# sourceMappingURL=capability-check.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"capability-check.d.ts","sourceRoot":"","sources":["../../../src/src/mrtr/capability-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD,8EAA8E;AAC9E,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,mBAAmB;IAClC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,IAAI,EAAE,oBAAoB,GAAG,WAAW,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxD,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB;;;;;;;;OAQG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;CACxC;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAS5E;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIjE,CAAC;AA+CF,wBAAgB,6BAA6B,CAC3C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAChD,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GACtD,qBAAqB,CAkKvB"}