@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
package/README.md CHANGED
@@ -1,649 +1,21 @@
1
- # @casys/mcp-server
1
+ # @casys/mcp-server (deprecated alias)
2
2
 
3
- [![npm](https://img.shields.io/npm/v/@casys/mcp-server)](https://www.npmjs.com/package/@casys/mcp-server)
4
- [![JSR](https://jsr.io/badges/@casys/mcp-server)](https://jsr.io/@casys/mcp-server)
5
3
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
4
 
7
- **The "Hono for MCP"** — a production-grade framework for building Model Context
8
- Protocol servers in TypeScript.
9
-
10
- Composable middleware, OAuth2 auth, dual transport, observability, and
11
- everything you need to ship reliable MCP servers. Built on the official
12
- [`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server)
13
- and
14
- [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk)
15
- packages.
16
-
17
- ```
18
- rate-limit → auth → custom middleware → scope-check → validation → backpressure → handler
19
- ```
20
-
21
- ---
22
-
23
- ## Why @casys/mcp-server?
24
-
25
- The official SDK gives you the protocol. This framework gives you the production
26
- stack.
27
-
28
- | | Official SDK | @casys/mcp-server |
29
- | --------------------------- | :----------: | :----------------------------: |
30
- | MCP protocol compliance | Yes | Yes |
31
- | Concurrency control | -- | 3 backpressure strategies |
32
- | Middleware pipeline | -- | Composable onion model |
33
- | OAuth2 / JWT auth | -- | Built-in + 4 OIDC presets |
34
- | Rate limiting | -- | Sliding window, per-client |
35
- | Schema validation | -- | JSON Schema (ajv) |
36
- | Streamable HTTP (stateless) | Manual | `startHttp()` / handler |
37
- | OpenTelemetry tracing | -- | Automatic spans per tool call |
38
- | Prometheus metrics | -- | `/metrics` endpoint |
39
- | MCP Apps (UI resources) | Manual | `registerResource()` + `ui://` |
40
-
41
- ---
42
-
43
- ## Install
5
+ > **Deprecated:** the framework moved to
6
+ > [`@casys/mcp-platform`](https://github.com/Casys-AI/mcp-platform/blob/main/packages/platform/README.md).
7
+ > This package re-exports it unchanged so existing imports keep working. New code should install
8
+ > `@casys/mcp-platform` directly.
44
9
 
45
10
  ```bash
46
- # Deno (primary target — JSR)
47
- deno add jsr:@casys/mcp-server
48
-
49
- # Node (secondary — npm, native ESM build)
50
- npm install @casys/mcp-server
11
+ npm install @casys/mcp-server # works, but deprecated
12
+ npm install @casys/mcp-platform # canonical
51
13
  ```
52
14
 
53
- ## Runtime targets
54
-
55
- `@casys/mcp-server` is **Deno-first**. The canonical deployment path is Deno 2.x
56
- running on [Deno Deploy](https://deno.com/deploy) or self-hosted Deno, with a
57
- Node 20+ distribution as a secondary target. The npm package contains compiled
58
- ESM JavaScript and TypeScript declarations; its runtime selector loads the Node
59
- HTTP adapter without evaluating the Deno adapter.
60
-
61
- | Runtime | Status |
62
- | --------------------------------------------- | :--------------: |
63
- | **Deno 2.x** (Deno Deploy, self-hosted) | ✅ Primary |
64
- | **Node.js 20+** (Express, Hono-on-Node, bare) | ✅ Secondary |
65
- | **Cloudflare Workers / workerd** | ❌ Not supported |
66
- | **Browser / WebContainer** | ❌ Not supported |
67
-
68
- If you need to target Cloudflare Workers or the browser, use
69
- [`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server)
70
- directly with its workerd / browser shims — that package focuses on the protocol
71
- and runtime portability, while `@casys/mcp-server` focuses on the production
72
- stack (auth, middleware, observability, multi-tenant, MCP Apps helpers) for Deno
73
- deployments.
74
-
75
- ---
76
-
77
- ## Quick Start
78
-
79
- ### STDIO Server (5 lines)
80
-
81
15
  ```typescript
16
+ // Old imports keep working:
82
17
  import { McpApp } from "@casys/mcp-server";
83
18
 
84
- const server = new McpApp({ name: "my-server", version: "1.0.0" });
85
-
86
- server.registerTool(
87
- {
88
- name: "greet",
89
- description: "Greet a user",
90
- inputSchema: {
91
- type: "object",
92
- properties: { name: { type: "string" } },
93
- required: ["name"],
94
- },
95
- },
96
- ({ name }) => `Hello, ${name}!`,
97
- );
98
-
99
- await server.start();
100
- ```
101
-
102
- Provider repositories that expose a native stdio CLI should test their actual
103
- documented command, transport flags, protocol eras, stdout discipline, and EOF
104
- cleanup. Use the
105
- [native stdio provider testing guide](https://github.com/Casys-AI/mcp-server/blob/main/docs/guides/native-stdio-provider-testing.md)
106
- as a test-only adoption kit.
107
-
108
- ### HTTP Server with Auth
109
-
110
- ```typescript
111
- import { createGoogleAuthProvider, McpApp } from "@casys/mcp-server";
112
-
113
- const server = new McpApp({
114
- name: "my-api",
115
- version: "1.0.0",
116
- maxConcurrent: 10,
117
- backpressureStrategy: "queue",
118
- validateSchema: true,
119
- rateLimit: { maxRequests: 100, windowMs: 60_000 },
120
- auth: {
121
- provider: createGoogleAuthProvider({
122
- audience: "https://my-mcp.example.com",
123
- resource: "https://my-mcp.example.com",
124
- }),
125
- },
126
- });
127
-
128
- server.registerTool(
129
- {
130
- name: "query",
131
- description: "Query the database",
132
- inputSchema: {
133
- type: "object",
134
- properties: { sql: { type: "string" } },
135
- },
136
- requiredScopes: ["db:read"],
137
- },
138
- async ({ sql }) => ({ rows: [] }),
139
- );
140
-
141
- await server.startHttp({ port: 3000 });
142
- // GET /health → { status: "ok" }
143
- // GET /metrics → Prometheus text format
144
- // POST /mcp → JSON-RPC (tools/call, tools/list, ...)
145
- // GET /mcp → 405 Method Not Allowed (stateless transport)
146
- ```
147
-
148
- See the
149
- [HTTP security guide](https://github.com/Casys-AI/mcp-server/blob/main/docs/guides/securing-your-http-server.md)
150
- to choose between a shared static allowlist, identity-aware static credentials,
151
- and OIDC/JWT.
152
-
153
- **Secure-by-default HTTP options:**
154
-
155
- ```typescript
156
- await server.startHttp({
157
- port: 3000,
158
- requireAuth: true, // fail fast if auth isn't configured
159
- corsOrigins: ["https://app.example.com"],
160
- maxBodyBytes: 1_000_000, // 1 MB
161
- ipRateLimit: { maxRequests: 120, windowMs: 60_000 },
162
- });
163
- ```
164
-
165
- **Notes:**
166
-
167
- - `requireAuth: true` throws if no auth provider is configured
168
- - `corsOrigins` defaults to `"*"` — use an allowlist in production
169
- - `maxBodyBytes` defaults to **1 MB** (set `null` to disable)
170
- - `ipRateLimit` keys on client IP by default
171
-
172
- ---
173
-
174
- ## Features
175
-
176
- ### Middleware Pipeline
177
-
178
- Composable onion model — same mental model as Hono, Koa, or Express.
179
-
180
- ```typescript
181
- import type { Middleware } from "@casys/mcp-server";
182
-
183
- const timing: Middleware = async (ctx, next) => {
184
- const start = performance.now();
185
- const result = await next();
186
- console.log(
187
- `${ctx.toolName} took ${(performance.now() - start).toFixed(0)}ms`,
188
- );
189
- return result;
190
- };
191
-
192
- server.use(timing);
193
- ```
194
-
195
- Built-in pipeline:
196
- `rate-limit → auth → custom → scope-check → validation → backpressure → handler`
197
-
198
- ### OAuth2 / JWT Auth
199
-
200
- Four OIDC presets out of the box:
201
-
202
- ```typescript
203
- import {
204
- createAuth0AuthProvider, // Auth0
205
- createGitHubAuthProvider, // GitHub Actions OIDC
206
- createGoogleAuthProvider, // Google OIDC
207
- createOIDCAuthProvider, // Generic OIDC (Keycloak, Okta, etc.)
208
- } from "@casys/mcp-server";
209
-
210
- const auth0 = createAuth0AuthProvider({
211
- domain: "my-tenant.auth0.com",
212
- audience: "https://my-mcp.example.com",
213
- resource: "https://my-mcp.example.com",
214
- scopesSupported: ["read", "write"],
215
- });
216
- ```
217
-
218
- Or use `JwtAuthProvider` directly for custom setups:
219
-
220
- ```typescript
221
- import { JwtAuthProvider } from "@casys/mcp-server";
222
-
223
- const provider = new JwtAuthProvider({
224
- issuer: "https://my-idp.example.com",
225
- audience: "https://my-mcp.example.com",
226
- resource: "https://my-mcp.example.com",
227
- authorizationServers: ["https://my-idp.example.com"],
228
- });
229
- ```
230
-
231
- Token verification is cached (SHA-256 hash → AuthInfo, TTL = min(token expiry,
232
- 5min)) to avoid redundant JWKS round-trips.
233
-
234
- ### YAML + Env Config
235
-
236
- For binary distribution — users configure auth without code:
237
-
238
- ```yaml
239
- # mcp-server.yaml
240
- auth:
241
- provider: auth0
242
- audience: https://my-mcp.example.com
243
- resource: https://my-mcp.example.com
244
- domain: my-tenant.auth0.com
245
- scopesSupported: [read, write, admin]
246
- ```
247
-
248
- Env vars override YAML at deploy time:
249
-
250
- ```bash
251
- MCP_AUTH_AUDIENCE=https://prod.example.com ./my-server --http --port 3000
252
- ```
253
-
254
- Priority: `programmatic > env vars > YAML > no auth`
255
-
256
- ### MRTR requestState replay protection
257
-
258
- When a tool returns `resultType: "input_required"`, configure a signing key so
259
- the framework can bind the continuation to the principal, method, arguments,
260
- expiry, and a random nonce:
261
-
262
- ```typescript
263
- const server = new McpApp({
264
- name: "my-api",
265
- version: "1.0.0",
266
- mrtr: {
267
- signingKey: Deno.env.get("MCP_MRTR_SIGNING_KEY"),
268
- },
269
- });
270
- ```
271
-
272
- Each verified nonce is consumed before the handler runs. With no explicit
273
- `replayStore`, the built-in `MemoryMrtrReplayStore` rejects a second use within
274
- one continuously running process.
275
-
276
- Multi-instance or restart-safe deployments must inject one durable atomic store
277
- shared by every instance:
278
-
279
- ```typescript
280
- import type { MrtrReplayStore } from "@casys/mcp-server";
281
-
282
- const replayStore: MrtrReplayStore = {
283
- async consume(nonce, expiresAt) {
284
- // Atomically reserve the nonce until its signed expiry.
285
- // Redis equivalent: SET mrtr:<nonce> 1 NX EXAT <expiresAt>
286
- return await reserveNonce(nonce, expiresAt);
287
- },
288
- };
289
-
290
- const server = new McpApp({
291
- name: "my-api",
292
- version: "1.0.0",
293
- mrtr: {
294
- signingKey: Deno.env.get("MCP_MRTR_SIGNING_KEY"),
295
- replayStore,
296
- },
297
- });
298
- ```
299
-
300
- `consume()` must return `true` only for the caller that wins the atomic
301
- reservation, `false` for a nonce already consumed, and throw when the store is
302
- unavailable. Store failures are fail-closed; the handler is not executed.
303
-
304
- This is at-most-once admission, not exactly-once completion. If business logic
305
- commits and the response is lost, replaying the same token is rejected.
306
- Returning the prior result safely requires a separate idempotency/result ledger,
307
- ideally paired with idempotency support in the downstream system.
308
-
309
- ### RFC 9728
310
-
311
- When auth is configured, the framework automatically exposes
312
- `GET /.well-known/oauth-protected-resource` per
313
- [RFC 9728](https://www.rfc-editor.org/rfc/rfc9728).
314
-
315
- ### DCR Discovery Proxy (RFC 8414 + RFC 7591)
316
-
317
- IdPs without native Dynamic Client Registration (Zitadel, unconfigured Keycloak,
318
- Okta free tier) don't publish `registration_endpoint` in their AS metadata, so
319
- MCP clients like Claude.ai or Cursor can't auto-register.
320
-
321
- `createAsMetadataHandler` is a framework-agnostic Web Standard handler that
322
- proxies the upstream RFC 8414 metadata and injects a `registration_endpoint`
323
- pointing to your own DCR proxy:
324
-
325
- ```typescript
326
- // routes/.well-known/oauth-authorization-server.ts (Fresh example)
327
- import { createAsMetadataHandler } from "@casys/mcp-server";
328
-
329
- const handle = createAsMetadataHandler({
330
- upstreamIssuer: "https://my-tenant.zitadel.cloud",
331
- registrationEndpoint: "https://my-app.example.com/oauth/register",
332
- // cacheTtlMs?: 24h default, stale-while-revalidate
333
- // extraFields?: override scopes_supported, etc.
334
- });
335
-
336
- export const handler = { GET: (ctx) => handle(ctx.req) };
337
- ```
338
-
339
- Then point the PRM at your own host so clients hit the enriched metadata:
340
-
341
- ```typescript
342
- authorizationServers: ["https://my-app.example.com"],
343
- ```
344
-
345
- The DCR endpoint itself (RFC 7591 `/oauth/register`) is out of scope — mount it
346
- in your framework and forward to the IdP's admin API.
347
-
348
- **Path caveat**: if the MCP server lives at `/mcp`, clients may build the
349
- discovery URL as `<host>/.well-known/oauth-authorization-server/mcp`. Mount the
350
- handler at the exact path your PRM advertises.
351
-
352
- ### Observability
353
-
354
- Every tool call emits an **OpenTelemetry span** with rich attributes:
355
-
356
- ```
357
- mcp.tool.call query
358
- mcp.tool.name = "query"
359
- mcp.server.name = "my-api"
360
- mcp.transport = "http"
361
- mcp.session.id = "a1b2c3..."
362
- mcp.tool.duration_ms = 42
363
- mcp.tool.success = true
364
- ```
365
-
366
- Enable with Deno's native OTEL support:
367
-
368
- ```bash
369
- OTEL_DENO=true deno run --unstable-otel server.ts
370
- ```
371
-
372
- The HTTP server exposes a **Prometheus-compatible** `/metrics` endpoint:
373
-
374
- ```
375
- mcp_server_tool_calls_total 1024
376
- mcp_server_tool_calls_success_total 1018
377
- mcp_server_tool_calls_failed_total 6
378
- mcp_server_tool_call_duration_ms_bucket{le="50"} 892
379
- mcp_server_tool_call_duration_ms_bucket{le="100"} 987
380
- mcp_server_tool_calls_by_name{tool="query",status="success"} 512
381
- mcp_server_active_requests 3
382
- mcp_server_uptime_seconds 86400
383
- ```
384
-
385
- Programmatic access:
386
-
387
- ```typescript
388
- server.getServerMetrics(); // Full snapshot (counters, histograms, gauges)
389
- server.getPrometheusMetrics(); // Prometheus text format string
390
- ```
391
-
392
- ### Concurrency Control
393
-
394
- Three backpressure strategies when the server is at capacity:
395
-
396
- | Strategy | Behavior |
397
- | ----------------- | ------------------------------------------ |
398
- | `sleep` (default) | Busy-wait with configurable sleep interval |
399
- | `queue` | FIFO queue with ordered release |
400
- | `reject` | Fail fast with immediate error |
401
-
402
- ```typescript
403
- new McpApp({
404
- maxConcurrent: 10,
405
- backpressureStrategy: "queue",
406
- });
407
- ```
408
-
409
- ### Rate Limiting
410
-
411
- Sliding window rate limiter with per-client tracking:
412
-
413
- ```typescript
414
- new McpApp({
415
- rateLimit: {
416
- maxRequests: 100,
417
- windowMs: 60_000,
418
- keyExtractor: (ctx) => ctx.args.clientId as string,
419
- onLimitExceeded: "wait", // or "reject"
420
- },
421
- });
19
+ // New code should use:
20
+ import { McpApp } from "@casys/mcp-platform";
422
21
  ```
423
-
424
- For HTTP endpoints, use `startHttp({ ipRateLimit: ... })` to rate limit by
425
- client IP (or custom key).
426
-
427
- ### Security Best Practices (Tool Handlers)
428
-
429
- Tool handlers receive **untrusted JSON input**. Treat args as hostile:
430
-
431
- - **Define strict schemas**: `additionalProperties: false`, `minLength`,
432
- `pattern`, `enum`.
433
- - **Never pass raw args to a shell** (`Deno.Command`, `child_process.exec`). If
434
- you must, use an allowlist + argv array (no shell).
435
- - **Validate paths & resources**: allowlisted roots, deny `..`, restrict env
436
- access.
437
- - **Prefer safe APIs**: parameterized DB queries, SDK methods, typed clients.
438
- - **Log sensitive actions**: file writes, network calls, admin ops.
439
-
440
- ### MCP Apps (UI Resources)
441
-
442
- Register interactive UIs as MCP resources:
443
-
444
- ```typescript
445
- import { MCP_APP_MIME_TYPE, McpApp } from "@casys/mcp-server";
446
-
447
- server.registerResource(
448
- { uri: "ui://my-server/viewer", name: "Data Viewer" },
449
- async (uri) => ({
450
- uri: uri.toString(),
451
- mimeType: MCP_APP_MIME_TYPE,
452
- text: "<html><body>...</body></html>",
453
- }),
454
- );
455
- ```
456
-
457
- Handlers return one payload form: `text` (including HTML) **or** `blob` for
458
- binary content encoded as standard padded base64. Existing text handlers remain
459
- valid. The framework also checks at runtime that the response URI exactly
460
- matches the requested URI and that the MIME type is non-empty, which protects
461
- JavaScript and unchecked TypeScript handlers as well as typed callers.
462
-
463
- ```typescript
464
- server.registerResource(
465
- { uri: "file://reports/latest.pdf", name: "Latest report", size: 184_320 },
466
- async (uri) => ({
467
- uri: uri.toString(),
468
- mimeType: "application/pdf",
469
- blob: await loadReportAsCanonicalBase64(),
470
- }),
471
- );
472
- ```
473
-
474
- `size` is optional resource metadata shown in `resources/list`; when present it
475
- must be a non-negative safe integer and is verified on every read against the
476
- exact UTF-8 byte length of `text` or decoded byte length of `blob`. Supplying
477
- `mimeType` in the resource metadata likewise binds every response to that exact
478
- MIME type. If it is absent, it is absent from `resources/list`; the handler
479
- still declares the MIME type when it serves the bytes. Resource content may
480
- include `_meta`. Put `annotations`, `icons`, `title`, and resource `_meta` on
481
- the `MCPResource` registration, where MCP defines those fields.
482
-
483
- With `resourceCsp`, CSP injection applies only to the `text` branch of an HTML
484
- resource. Blobs are never decoded, transformed, or re-encoded.
485
-
486
- Register resources before `start()` / `startHttp()` to install the resource
487
- handlers and advertise `resources: { listChanged: true }`. They can then be
488
- added or removed at any time through `unregisterResource(uri)`, which returns
489
- `true` only once. For a registry that starts empty and discovers resources
490
- asynchronously, construct with `expectResources: true`; that mode installs the
491
- same handlers at construction time:
492
-
493
- ```typescript
494
- const app = new McpApp({
495
- name: "relay",
496
- version: "1.0.0",
497
- expectResources: true,
498
- });
499
-
500
- // After start(): list/read/templates handlers are already installed.
501
- app.registerResource(resource, handler);
502
- app.unregisterResource(resource.uri); // true, then false if called again
503
- ```
504
-
505
- #### Capability negotiation (clients that don't support MCP Apps)
506
-
507
- Not every MCP client renders UI resources. Clients that do advertise the
508
- [MCP Apps extension](https://github.com/modelcontextprotocol/ext-apps) in their
509
- capabilities (per the SDK 1.29 `extensions` field). Read it from a tool handler
510
- to decide between rich UI and a text-only fallback:
511
-
512
- ```typescript
513
- import { MCP_APP_MIME_TYPE, McpApp } from "@casys/mcp-server";
514
-
515
- const app = new McpApp({ name: "weather-server", version: "1.0.0" });
516
-
517
- app.registerTool(
518
- {
519
- name: "get-weather",
520
- description: "Get the weather forecast for a city",
521
- inputSchema: {
522
- type: "object",
523
- properties: { city: { type: "string" } },
524
- required: ["city"],
525
- },
526
- },
527
- async ({ city }) => {
528
- const forecast = await fetchForecast(city);
529
- const cap = app.getClientMcpAppsCapability();
530
-
531
- if (cap?.mimeTypes?.includes(MCP_APP_MIME_TYPE)) {
532
- // Rich UI: small text summary + interactive resource
533
- return {
534
- content: [{ type: "text", text: `Forecast for ${city} loaded` }],
535
- _meta: { ui: { resourceUri: `ui://weather/${city}` } },
536
- };
537
- }
538
-
539
- // Text-only fallback for clients that can't render the UI
540
- return {
541
- content: [{ type: "text", text: formatForecastAsText(forecast) }],
542
- };
543
- },
544
- );
545
- ```
546
-
547
- `getClientMcpAppsCapability()` returns `undefined` before the client has
548
- completed its initialize handshake, when the client doesn't advertise MCP Apps
549
- support, or when the advertised capability is malformed. The standalone
550
- `getMcpAppsCapability(clientCapabilities)` function is also exported for use
551
- against arbitrary capability objects.
552
-
553
- The constants `MCP_APPS_EXTENSION_ID` (`"io.modelcontextprotocol/ui"`) and
554
- `MCP_APPS_PROTOCOL_VERSION` (`"2026-01-26"`) are exported for agents that need
555
- to introspect the protocol target directly.
556
-
557
- ---
558
-
559
- ## API Reference
560
-
561
- ### McpApp
562
-
563
- > **Note:** `ConcurrentMCPServer` and `ConcurrentServerOptions` remain exported
564
- > as `@deprecated` aliases for backwards compatibility and will be removed in
565
- > v1.0. New code should use `McpApp` / `McpAppOptions`. The aliases point to the
566
- > exact same class — `instanceof` checks pass on both.
567
-
568
- ```typescript
569
- const server = new McpApp(options: McpAppOptions);
570
-
571
- // Registration (before start, unless expectResources: true)
572
- server.registerTool(tool, handler);
573
- server.registerTools(tools, handlers);
574
- server.registerResource(resource, handler);
575
- server.registerResources(resources, handlers);
576
- server.unregisterResource(resourceUri); // safe before or after start
577
- server.use(middleware);
578
-
579
- // Transport
580
- await server.start(); // STDIO
581
- await server.startHttp({ port: 3000 }); // HTTP + SSE
582
- await server.stop(); // Graceful shutdown
583
-
584
- // Observability
585
- server.getMetrics(); // { inFlight, queued }
586
- server.getServerMetrics(); // Full snapshot
587
- server.getPrometheusMetrics(); // Prometheus text format
588
- server.getRateLimitMetrics(); // { keys, totalRequests }
589
-
590
- // Introspection
591
- server.getToolCount();
592
- server.getToolNames();
593
- server.getResourceCount();
594
- server.getResourceUris();
595
- ```
596
-
597
- ### Standalone Components
598
-
599
- Each component works independently:
600
-
601
- ```typescript
602
- import { RateLimiter, RequestQueue, SchemaValidator } from "@casys/mcp-server";
603
-
604
- // Rate limiter
605
- const limiter = new RateLimiter({ maxRequests: 10, windowMs: 1000 });
606
- if (limiter.checkLimit("client-123")) {
607
- /* proceed */
608
- }
609
-
610
- // Request queue
611
- const queue = new RequestQueue({
612
- maxConcurrent: 5,
613
- strategy: "queue",
614
- sleepMs: 10,
615
- });
616
- await queue.acquire();
617
- try {
618
- /* work */
619
- } finally {
620
- queue.release();
621
- }
622
-
623
- // Schema validator
624
- const validator = new SchemaValidator();
625
- validator.addSchema("tool", {
626
- type: "object",
627
- properties: { n: { type: "number" } },
628
- });
629
- validator.validate("tool", { n: 5 }); // { valid: true, errors: [] }
630
- ```
631
-
632
- ---
633
-
634
- ## HTTP Endpoints
635
-
636
- When running with `startHttp()`:
637
-
638
- | Method | Path | Description |
639
- | ------ | --------------------------------------- | ----------------------------------------------------------- |
640
- | `POST` | `/mcp` or `/` | JSON-RPC endpoint (initialize, tools/call, tools/list, ...) |
641
- | `GET` | `/health` | Health check |
642
- | `GET` | `/metrics` | Prometheus metrics |
643
- | `GET` | `/.well-known/oauth-protected-resource` | RFC 9728 metadata (when auth enabled) |
644
-
645
- ---
646
-
647
- ## License
648
-
649
- MIT