@toa.io/extensions.exposition 1.0.0-alpha.283 → 1.0.0-alpha.285

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 (568) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/components/exposition.octets/types/index.d.ts +1 -1
  3. package/components/identity.bans/operations/transit.js +1 -1
  4. package/components/identity.bans/tsconfig.json +1 -1
  5. package/components/identity.bans/tsconfig.tsbuildinfo +1 -1
  6. package/components/identity.bans/types/index.d.ts +1 -1
  7. package/components/identity.basic/operations/add.js +1 -1
  8. package/components/identity.basic/operations/authenticate.js +1 -1
  9. package/components/identity.basic/operations/check.js +1 -1
  10. package/components/identity.basic/operations/delete.js +1 -1
  11. package/components/identity.basic/operations/incept.js +18 -2
  12. package/components/identity.basic/operations/info.js +1 -1
  13. package/components/identity.basic/operations/lib/credentials.js +1 -1
  14. package/components/identity.basic/operations/transit.js +1 -1
  15. package/components/identity.basic/source/incept.ts +29 -1
  16. package/components/identity.basic/tsconfig.json +1 -1
  17. package/components/identity.basic/tsconfig.tsbuildinfo +1 -1
  18. package/components/identity.basic/types/index.d.ts +3 -2
  19. package/components/identity.clients/operations/describe.js +1 -1
  20. package/components/identity.clients/operations/lib/Context.js +1 -1
  21. package/components/identity.clients/operations/lib/Entity.js +1 -1
  22. package/components/identity.clients/operations/lib/canonical.js +1 -1
  23. package/components/identity.clients/operations/lib/cimd.js +1 -1
  24. package/components/identity.clients/operations/lib/errors.js +1 -1
  25. package/components/identity.clients/operations/lib/index.js +1 -1
  26. package/components/identity.clients/operations/lib/redirect.js +1 -1
  27. package/components/identity.clients/operations/register.js +1 -1
  28. package/components/identity.clients/tsconfig.json +1 -1
  29. package/components/identity.clients/tsconfig.tsbuildinfo +1 -1
  30. package/components/identity.clients/types/index.d.ts +1 -1
  31. package/components/identity.credentials/operations/list.js +1 -1
  32. package/components/identity.credentials/tsconfig.json +4 -2
  33. package/components/identity.credentials/tsconfig.tsbuildinfo +1 -1
  34. package/components/identity.credentials/types/index.d.ts +1 -1
  35. package/components/identity.federation/operations/authenticate.js +7 -3
  36. package/components/identity.federation/operations/create.js +1 -1
  37. package/components/identity.federation/operations/decode.js +1 -1
  38. package/components/identity.federation/operations/delete.js +1 -1
  39. package/components/identity.federation/operations/incept.js +6 -2
  40. package/components/identity.federation/operations/lib/Configuration.js +1 -1
  41. package/components/identity.federation/operations/lib/Ctx.js +1 -1
  42. package/components/identity.federation/operations/lib/Payload.js +1 -1
  43. package/components/identity.federation/operations/lib/decode.js +1 -1
  44. package/components/identity.federation/operations/lib/discovery.js +1 -1
  45. package/components/identity.federation/operations/lib/errors.js +1 -1
  46. package/components/identity.federation/operations/lib/exchange.js +1 -1
  47. package/components/identity.federation/operations/lib/index.js +2 -1
  48. package/components/identity.federation/operations/lib/jose.js +1 -1
  49. package/components/identity.federation/operations/lib/principal.js +14 -0
  50. package/components/identity.federation/operations/lib/resolve.js +1 -1
  51. package/components/identity.federation/operations/list.js +1 -1
  52. package/components/identity.federation/operations/types/Scheme.js +1 -1
  53. package/components/identity.federation/operations/types/configuration.js +1 -1
  54. package/components/identity.federation/operations/types/context.js +1 -1
  55. package/components/identity.federation/operations/types/entity.js +1 -1
  56. package/components/identity.federation/operations/types/index.js +1 -1
  57. package/components/identity.federation/source/authenticate.ts +8 -2
  58. package/components/identity.federation/source/incept.ts +7 -1
  59. package/components/identity.federation/source/lib/index.ts +1 -0
  60. package/components/identity.federation/source/lib/principal.ts +17 -0
  61. package/components/identity.federation/source/types/context.ts +3 -0
  62. package/components/identity.federation/tsconfig.json +4 -2
  63. package/components/identity.federation/tsconfig.tsbuildinfo +1 -1
  64. package/components/identity.federation/types/index.d.ts +1 -1
  65. package/components/identity.grants/operations/authorize.js +1 -1
  66. package/components/identity.grants/operations/exchange.js +1 -1
  67. package/components/identity.grants/operations/lib/code.js +1 -1
  68. package/components/identity.grants/operations/lib/identify.js +1 -1
  69. package/components/identity.grants/operations/lib/index.js +1 -1
  70. package/components/identity.grants/operations/list.js +1 -1
  71. package/components/identity.grants/operations/revoke.js +1 -1
  72. package/components/identity.grants/tsconfig.json +1 -1
  73. package/components/identity.grants/tsconfig.tsbuildinfo +1 -1
  74. package/components/identity.grants/types/index.d.ts +1 -1
  75. package/components/identity.keys/operations/create.js +1 -1
  76. package/components/identity.keys/operations/disable.js +1 -1
  77. package/components/identity.keys/operations/revoke.js +1 -1
  78. package/components/identity.keys/tsconfig.json +1 -1
  79. package/components/identity.keys/tsconfig.tsbuildinfo +1 -1
  80. package/components/identity.keys/types/index.d.ts +1 -1
  81. package/components/identity.otp/operations/authenticate.js +1 -1
  82. package/components/identity.otp/operations/issue.js +1 -1
  83. package/components/identity.otp/operations/lib/Context.js +1 -1
  84. package/components/identity.otp/operations/lib/Entity.js +1 -1
  85. package/components/identity.otp/operations/lib/index.js +1 -1
  86. package/components/identity.otp/tsconfig.json +1 -1
  87. package/components/identity.otp/tsconfig.tsbuildinfo +1 -1
  88. package/components/identity.otp/types/index.d.ts +1 -1
  89. package/components/identity.passkeys/operations/authenticate.js +1 -1
  90. package/components/identity.passkeys/operations/challenge.js +1 -1
  91. package/components/identity.passkeys/operations/create.js +1 -1
  92. package/components/identity.passkeys/operations/delete.js +1 -1
  93. package/components/identity.passkeys/operations/lib/const.js +1 -1
  94. package/components/identity.passkeys/operations/list.js +1 -1
  95. package/components/identity.passkeys/operations/types/Configuration.js +1 -1
  96. package/components/identity.passkeys/operations/types/Context.js +1 -1
  97. package/components/identity.passkeys/operations/types/Passkey.js +1 -1
  98. package/components/identity.passkeys/operations/types/index.js +1 -1
  99. package/components/identity.passkeys/operations/use.js +1 -1
  100. package/components/identity.passkeys/tsconfig.json +1 -1
  101. package/components/identity.passkeys/tsconfig.tsbuildinfo +1 -1
  102. package/components/identity.passkeys/types/index.d.ts +1 -1
  103. package/components/identity.roles/operations/grant.js +1 -1
  104. package/components/identity.roles/operations/lib/Entity.js +1 -1
  105. package/components/identity.roles/operations/list.js +1 -1
  106. package/components/identity.roles/operations/principal.js +29 -5
  107. package/components/identity.roles/source/principal.ts +33 -5
  108. package/components/identity.roles/tsconfig.json +1 -1
  109. package/components/identity.roles/tsconfig.tsbuildinfo +1 -1
  110. package/components/identity.roles/types/index.d.ts +1 -1
  111. package/components/identity.tokens/operations/authenticate.js +1 -1
  112. package/components/identity.tokens/operations/decrypt.js +1 -1
  113. package/components/identity.tokens/operations/encrypt.js +1 -1
  114. package/components/identity.tokens/operations/issue.js +1 -1
  115. package/components/identity.tokens/operations/lib/form.js +1 -1
  116. package/components/identity.tokens/operations/lib/index.js +1 -1
  117. package/components/identity.tokens/operations/lib/jose.js +1 -1
  118. package/components/identity.tokens/operations/lib/key.js +1 -1
  119. package/components/identity.tokens/operations/lib/pad.js +1 -1
  120. package/components/identity.tokens/operations/revoke.js +1 -1
  121. package/components/identity.tokens/tsconfig.json +1 -1
  122. package/components/identity.tokens/tsconfig.tsbuildinfo +1 -1
  123. package/components/identity.tokens/types/index.d.ts +1 -1
  124. package/documentation/access.md +13 -0
  125. package/documentation/components.md +3 -0
  126. package/documentation/introspection.md +13 -5
  127. package/documentation/io.md +6 -0
  128. package/documentation/map.md +8 -0
  129. package/documentation/mcp.md +186 -0
  130. package/documentation/oauth.md +8 -7
  131. package/documentation/rpc.md +144 -0
  132. package/documentation/tree.md +3 -0
  133. package/features/identity.basic.feature +44 -0
  134. package/features/identity.federation.feature +2 -5
  135. package/features/introspection.feature +333 -0
  136. package/features/mcp.feature +691 -0
  137. package/features/oauth.discovery.feature +10 -11
  138. package/features/oauth.grants.feature +22 -9
  139. package/features/octets.cloudinary.feature +1 -0
  140. package/features/rpc.feature +429 -0
  141. package/features/steps/Cloudinary.ts +13 -0
  142. package/features/steps/Components.ts +0 -4
  143. package/features/steps/Gateway.ts +19 -2
  144. package/features/steps/Parameters.ts +18 -7
  145. package/features/steps/Realtime.ts +3 -0
  146. package/features/steps/components/echo/manifest.toa.yaml +1 -0
  147. package/features/steps/components/pots/manifest.toa.yaml +2 -0
  148. package/package.json +3 -3
  149. package/readme.md +3 -0
  150. package/schemas/annotation.cos.yaml +33 -0
  151. package/schemas/call.cos.yaml +18 -0
  152. package/source/Annotation.ts +31 -0
  153. package/source/Directive.test.ts +15 -15
  154. package/source/Directive.ts +77 -9
  155. package/source/Endpoint.test.ts +67 -0
  156. package/source/Endpoint.ts +31 -11
  157. package/source/Factory.ts +5 -1
  158. package/source/Gateway.ts +73 -11
  159. package/source/HTTP/Context.ts +7 -0
  160. package/source/HTTP/Server.ts +7 -1
  161. package/source/HTTP/exceptions.ts +2 -2
  162. package/source/HTTP/messages.ts +10 -1
  163. package/source/Introspection.ts +105 -0
  164. package/source/MCP/Server.ts +275 -0
  165. package/source/MCP/discover.ts +52 -0
  166. package/source/MCP/errors.ts +81 -0
  167. package/source/MCP/index.ts +1 -0
  168. package/source/MCP/schema.test.ts +85 -0
  169. package/source/MCP/schema.ts +87 -0
  170. package/source/MCP/tools.ts +157 -0
  171. package/source/MCP/types.ts +84 -0
  172. package/source/Query.ts +48 -8
  173. package/source/RPC/Context.ts +78 -0
  174. package/source/RPC/Dispatcher.ts +130 -0
  175. package/source/RPC/errors.test.ts +52 -0
  176. package/source/RPC/errors.ts +83 -0
  177. package/source/RPC/index.ts +1 -0
  178. package/source/RPC/names.test.ts +122 -0
  179. package/source/RPC/names.ts +183 -0
  180. package/source/RPC/types.ts +34 -0
  181. package/source/RTD/Directives.ts +52 -2
  182. package/source/RTD/Endpoint.ts +2 -1
  183. package/source/RTD/Method.ts +14 -11
  184. package/source/RTD/Node.ts +38 -7
  185. package/source/RTD/Route.ts +30 -3
  186. package/source/RTD/Tree.ts +37 -1
  187. package/source/RTD/expiration.test.ts +1 -1
  188. package/source/RTD/walk.test.ts +110 -0
  189. package/source/const.ts +15 -0
  190. package/source/deployment.ts +8 -1
  191. package/source/directives/auth/Anonymous.test.ts +38 -0
  192. package/source/directives/auth/Anonymous.ts +12 -0
  193. package/source/directives/auth/Anyone.ts +4 -0
  194. package/source/directives/auth/Authorization.ts +62 -3
  195. package/source/directives/auth/Delegate.test.ts +36 -0
  196. package/source/directives/auth/Delegate.ts +14 -0
  197. package/source/directives/auth/Echo.ts +5 -0
  198. package/source/directives/auth/Incept.ts +2 -1
  199. package/source/directives/auth/Role.ts +13 -0
  200. package/source/directives/auth/Rule.ts +29 -0
  201. package/source/directives/auth/Scheme.ts +5 -0
  202. package/source/directives/auth/types.ts +21 -0
  203. package/source/directives/cache/Cache.ts +1 -1
  204. package/source/directives/dev/Development.ts +1 -1
  205. package/source/directives/flow/Flow.ts +1 -1
  206. package/source/directives/index.ts +3 -1
  207. package/source/directives/io/Directive.ts +1 -1
  208. package/source/directives/io/IO.ts +32 -3
  209. package/source/directives/io/Input.ts +3 -2
  210. package/source/directives/io/Output.ts +6 -3
  211. package/source/directives/io/Status.test.ts +2 -2
  212. package/source/directives/io/Status.ts +1 -1
  213. package/source/directives/io/Throttle.ts +1 -1
  214. package/source/directives/io/lib/throttle/Quotas.ts +2 -2
  215. package/source/directives/map/Headers.ts +11 -0
  216. package/source/directives/map/Map.ts +10 -1
  217. package/source/directives/map/Mapping.ts +23 -0
  218. package/source/directives/map/Segments.ts +12 -0
  219. package/source/directives/mcp/MCP.ts +40 -0
  220. package/source/directives/mcp/Tool.test.ts +90 -0
  221. package/source/directives/mcp/Tool.ts +47 -0
  222. package/source/directives/mcp/index.ts +6 -0
  223. package/source/directives/oauth/Discovery.ts +10 -16
  224. package/source/directives/octets/Octets.ts +1 -1
  225. package/source/directives/require/Directive.ts +1 -1
  226. package/source/directives/require/Headers.ts +1 -1
  227. package/source/directives/require/Require.ts +2 -2
  228. package/source/schemas.ts +2 -0
  229. package/transpiled/Annotation.d.ts +24 -0
  230. package/transpiled/Directive.d.ts +18 -1
  231. package/transpiled/Directive.js +50 -6
  232. package/transpiled/Directive.js.map +1 -1
  233. package/transpiled/Endpoint.d.ts +9 -0
  234. package/transpiled/Endpoint.js +27 -11
  235. package/transpiled/Endpoint.js.map +1 -1
  236. package/transpiled/Factory.js +5 -1
  237. package/transpiled/Factory.js.map +1 -1
  238. package/transpiled/Gateway.d.ts +19 -2
  239. package/transpiled/Gateway.js +51 -9
  240. package/transpiled/Gateway.js.map +1 -1
  241. package/transpiled/HTTP/Context.d.ts +6 -0
  242. package/transpiled/HTTP/Context.js +6 -0
  243. package/transpiled/HTTP/Context.js.map +1 -1
  244. package/transpiled/HTTP/Server.d.ts +5 -1
  245. package/transpiled/HTTP/exceptions.d.ts +1 -1
  246. package/transpiled/HTTP/exceptions.js +2 -2
  247. package/transpiled/HTTP/exceptions.js.map +1 -1
  248. package/transpiled/HTTP/messages.d.ts +6 -0
  249. package/transpiled/HTTP/messages.js +9 -1
  250. package/transpiled/HTTP/messages.js.map +1 -1
  251. package/transpiled/Introspection.d.ts +42 -0
  252. package/transpiled/Introspection.js +50 -1
  253. package/transpiled/Introspection.js.map +1 -1
  254. package/transpiled/MCP/Server.d.ts +41 -0
  255. package/transpiled/MCP/Server.js +180 -0
  256. package/transpiled/MCP/Server.js.map +1 -0
  257. package/transpiled/MCP/discover.d.ts +13 -0
  258. package/transpiled/MCP/discover.js +29 -0
  259. package/transpiled/MCP/discover.js.map +1 -0
  260. package/transpiled/MCP/errors.d.ts +24 -0
  261. package/transpiled/MCP/errors.js +67 -0
  262. package/transpiled/MCP/errors.js.map +1 -0
  263. package/transpiled/MCP/index.d.ts +1 -0
  264. package/transpiled/MCP/index.js +2 -0
  265. package/transpiled/MCP/index.js.map +1 -0
  266. package/transpiled/MCP/schema.d.ts +18 -0
  267. package/transpiled/MCP/schema.js +64 -0
  268. package/transpiled/MCP/schema.js.map +1 -0
  269. package/transpiled/MCP/tools.d.ts +31 -0
  270. package/transpiled/MCP/tools.js +122 -0
  271. package/transpiled/MCP/tools.js.map +1 -0
  272. package/transpiled/MCP/types.d.ts +66 -0
  273. package/transpiled/MCP/types.js +13 -0
  274. package/transpiled/MCP/types.js.map +1 -0
  275. package/transpiled/Query.d.ts +7 -0
  276. package/transpiled/Query.js +38 -7
  277. package/transpiled/Query.js.map +1 -1
  278. package/transpiled/RPC/Context.d.ts +11 -0
  279. package/transpiled/RPC/Context.js +63 -0
  280. package/transpiled/RPC/Context.js.map +1 -0
  281. package/transpiled/RPC/Dispatcher.d.ts +19 -0
  282. package/transpiled/RPC/Dispatcher.js +100 -0
  283. package/transpiled/RPC/Dispatcher.js.map +1 -0
  284. package/transpiled/RPC/errors.d.ts +18 -0
  285. package/transpiled/RPC/errors.js +67 -0
  286. package/transpiled/RPC/errors.js.map +1 -0
  287. package/transpiled/RPC/index.d.ts +1 -0
  288. package/transpiled/RPC/index.js +2 -0
  289. package/transpiled/RPC/index.js.map +1 -0
  290. package/transpiled/RPC/names.d.ts +31 -0
  291. package/transpiled/RPC/names.js +121 -0
  292. package/transpiled/RPC/names.js.map +1 -0
  293. package/transpiled/RPC/types.d.ts +27 -0
  294. package/transpiled/RPC/types.js +8 -0
  295. package/transpiled/RPC/types.js.map +1 -0
  296. package/transpiled/RTD/Directives.d.ts +41 -2
  297. package/transpiled/RTD/Endpoint.d.ts +2 -1
  298. package/transpiled/RTD/Method.d.ts +8 -3
  299. package/transpiled/RTD/Method.js +12 -10
  300. package/transpiled/RTD/Method.js.map +1 -1
  301. package/transpiled/RTD/Node.d.ts +20 -2
  302. package/transpiled/RTD/Node.js +22 -4
  303. package/transpiled/RTD/Node.js.map +1 -1
  304. package/transpiled/RTD/Route.d.ts +2 -1
  305. package/transpiled/RTD/Route.js +27 -2
  306. package/transpiled/RTD/Route.js.map +1 -1
  307. package/transpiled/RTD/Tree.d.ts +3 -1
  308. package/transpiled/RTD/Tree.js +26 -0
  309. package/transpiled/RTD/Tree.js.map +1 -1
  310. package/transpiled/const.d.ts +12 -0
  311. package/transpiled/const.js +12 -0
  312. package/transpiled/const.js.map +1 -1
  313. package/transpiled/deployment.js +4 -0
  314. package/transpiled/deployment.js.map +1 -1
  315. package/transpiled/directives/auth/Anonymous.d.ts +6 -0
  316. package/transpiled/directives/auth/Anonymous.js +10 -0
  317. package/transpiled/directives/auth/Anonymous.js.map +1 -1
  318. package/transpiled/directives/auth/Anyone.d.ts +1 -0
  319. package/transpiled/directives/auth/Anyone.js +3 -0
  320. package/transpiled/directives/auth/Anyone.js.map +1 -1
  321. package/transpiled/directives/auth/Authorization.d.ts +27 -1
  322. package/transpiled/directives/auth/Authorization.js +49 -1
  323. package/transpiled/directives/auth/Authorization.js.map +1 -1
  324. package/transpiled/directives/auth/Delegate.d.ts +5 -0
  325. package/transpiled/directives/auth/Delegate.js +10 -0
  326. package/transpiled/directives/auth/Delegate.js.map +1 -1
  327. package/transpiled/directives/auth/Echo.d.ts +2 -0
  328. package/transpiled/directives/auth/Echo.js +4 -0
  329. package/transpiled/directives/auth/Echo.js.map +1 -1
  330. package/transpiled/directives/auth/Incept.js +2 -1
  331. package/transpiled/directives/auth/Incept.js.map +1 -1
  332. package/transpiled/directives/auth/Role.d.ts +2 -0
  333. package/transpiled/directives/auth/Role.js +9 -0
  334. package/transpiled/directives/auth/Role.js.map +1 -1
  335. package/transpiled/directives/auth/Rule.d.ts +5 -0
  336. package/transpiled/directives/auth/Rule.js +20 -0
  337. package/transpiled/directives/auth/Rule.js.map +1 -1
  338. package/transpiled/directives/auth/Scheme.d.ts +2 -0
  339. package/transpiled/directives/auth/Scheme.js +4 -0
  340. package/transpiled/directives/auth/Scheme.js.map +1 -1
  341. package/transpiled/directives/auth/types.d.ts +16 -0
  342. package/transpiled/directives/cache/Cache.d.ts +1 -1
  343. package/transpiled/directives/cache/Cache.js +1 -1
  344. package/transpiled/directives/cache/Cache.js.map +1 -1
  345. package/transpiled/directives/dev/Development.d.ts +1 -1
  346. package/transpiled/directives/dev/Development.js +1 -1
  347. package/transpiled/directives/dev/Development.js.map +1 -1
  348. package/transpiled/directives/flow/Flow.d.ts +1 -1
  349. package/transpiled/directives/flow/Flow.js +1 -1
  350. package/transpiled/directives/flow/Flow.js.map +1 -1
  351. package/transpiled/directives/index.js +2 -1
  352. package/transpiled/directives/index.js.map +1 -1
  353. package/transpiled/directives/io/Directive.d.ts +1 -1
  354. package/transpiled/directives/io/IO.d.ts +7 -1
  355. package/transpiled/directives/io/IO.js +23 -3
  356. package/transpiled/directives/io/IO.js.map +1 -1
  357. package/transpiled/directives/io/Input.d.ts +3 -2
  358. package/transpiled/directives/io/Input.js +2 -1
  359. package/transpiled/directives/io/Input.js.map +1 -1
  360. package/transpiled/directives/io/Output.d.ts +5 -3
  361. package/transpiled/directives/io/Output.js +4 -2
  362. package/transpiled/directives/io/Output.js.map +1 -1
  363. package/transpiled/directives/io/Status.d.ts +1 -1
  364. package/transpiled/directives/io/Status.js +1 -1
  365. package/transpiled/directives/io/Status.js.map +1 -1
  366. package/transpiled/directives/io/Throttle.d.ts +1 -1
  367. package/transpiled/directives/io/Throttle.js +1 -1
  368. package/transpiled/directives/io/Throttle.js.map +1 -1
  369. package/transpiled/directives/io/lib/throttle/Quotas.d.ts +1 -1
  370. package/transpiled/directives/io/lib/throttle/Quotas.js +2 -2
  371. package/transpiled/directives/io/lib/throttle/Quotas.js.map +1 -1
  372. package/transpiled/directives/map/Headers.d.ts +2 -0
  373. package/transpiled/directives/map/Headers.js +8 -0
  374. package/transpiled/directives/map/Headers.js.map +1 -1
  375. package/transpiled/directives/map/Map.d.ts +3 -1
  376. package/transpiled/directives/map/Map.js +7 -1
  377. package/transpiled/directives/map/Map.js.map +1 -1
  378. package/transpiled/directives/map/Mapping.d.ts +13 -0
  379. package/transpiled/directives/map/Mapping.js +20 -0
  380. package/transpiled/directives/map/Mapping.js.map +1 -1
  381. package/transpiled/directives/map/Segments.d.ts +3 -0
  382. package/transpiled/directives/map/Segments.js +9 -0
  383. package/transpiled/directives/map/Segments.js.map +1 -1
  384. package/transpiled/directives/mcp/MCP.d.ts +15 -0
  385. package/transpiled/directives/mcp/MCP.js +29 -0
  386. package/transpiled/directives/mcp/MCP.js.map +1 -0
  387. package/transpiled/directives/mcp/Tool.d.ts +18 -0
  388. package/transpiled/directives/mcp/Tool.js +34 -0
  389. package/transpiled/directives/mcp/Tool.js.map +1 -0
  390. package/transpiled/directives/mcp/index.d.ts +4 -0
  391. package/transpiled/directives/mcp/index.js +4 -0
  392. package/transpiled/directives/mcp/index.js.map +1 -0
  393. package/transpiled/directives/oauth/Discovery.js +10 -13
  394. package/transpiled/directives/oauth/Discovery.js.map +1 -1
  395. package/transpiled/directives/octets/Octets.d.ts +1 -1
  396. package/transpiled/directives/octets/Octets.js +1 -1
  397. package/transpiled/directives/octets/Octets.js.map +1 -1
  398. package/transpiled/directives/require/Directive.d.ts +1 -1
  399. package/transpiled/directives/require/Headers.d.ts +1 -1
  400. package/transpiled/directives/require/Headers.js +1 -1
  401. package/transpiled/directives/require/Headers.js.map +1 -1
  402. package/transpiled/directives/require/Require.d.ts +1 -1
  403. package/transpiled/directives/require/Require.js +2 -2
  404. package/transpiled/directives/require/Require.js.map +1 -1
  405. package/transpiled/schemas.d.ts +2 -0
  406. package/transpiled/schemas.js +1 -0
  407. package/transpiled/schemas.js.map +1 -1
  408. package/tsconfig.tsbuildinfo +1 -1
  409. package/components/identity.bans/operations/transit.d.ts +0 -14
  410. package/components/identity.bans/operations/transit.js.map +0 -1
  411. package/components/identity.basic/operations/add.d.ts +0 -3
  412. package/components/identity.basic/operations/add.js.map +0 -1
  413. package/components/identity.basic/operations/authenticate.d.ts +0 -13
  414. package/components/identity.basic/operations/authenticate.js.map +0 -1
  415. package/components/identity.basic/operations/check.d.ts +0 -7
  416. package/components/identity.basic/operations/check.js.map +0 -1
  417. package/components/identity.basic/operations/delete.d.ts +0 -7
  418. package/components/identity.basic/operations/delete.js.map +0 -1
  419. package/components/identity.basic/operations/incept.d.ts +0 -12
  420. package/components/identity.basic/operations/incept.js.map +0 -1
  421. package/components/identity.basic/operations/info.d.ts +0 -10
  422. package/components/identity.basic/operations/info.js.map +0 -1
  423. package/components/identity.basic/operations/lib/credentials.d.ts +0 -5
  424. package/components/identity.basic/operations/lib/credentials.js.map +0 -1
  425. package/components/identity.basic/operations/transit.d.ts +0 -15
  426. package/components/identity.basic/operations/transit.js.map +0 -1
  427. package/components/identity.clients/operations/describe.d.ts +0 -27
  428. package/components/identity.clients/operations/describe.js.map +0 -1
  429. package/components/identity.clients/operations/lib/Context.d.ts +0 -29
  430. package/components/identity.clients/operations/lib/Context.js.map +0 -1
  431. package/components/identity.clients/operations/lib/Entity.d.ts +0 -29
  432. package/components/identity.clients/operations/lib/Entity.js.map +0 -1
  433. package/components/identity.clients/operations/lib/canonical.d.ts +0 -11
  434. package/components/identity.clients/operations/lib/canonical.js.map +0 -1
  435. package/components/identity.clients/operations/lib/cimd.d.ts +0 -8
  436. package/components/identity.clients/operations/lib/cimd.js.map +0 -1
  437. package/components/identity.clients/operations/lib/errors.d.ts +0 -7
  438. package/components/identity.clients/operations/lib/errors.js.map +0 -1
  439. package/components/identity.clients/operations/lib/index.d.ts +0 -6
  440. package/components/identity.clients/operations/lib/index.js.map +0 -1
  441. package/components/identity.clients/operations/lib/redirect.d.ts +0 -10
  442. package/components/identity.clients/operations/lib/redirect.js.map +0 -1
  443. package/components/identity.clients/operations/register.d.ts +0 -37
  444. package/components/identity.clients/operations/register.js.map +0 -1
  445. package/components/identity.credentials/operations/list.d.ts +0 -52
  446. package/components/identity.credentials/operations/list.js.map +0 -1
  447. package/components/identity.federation/operations/authenticate.d.ts +0 -16
  448. package/components/identity.federation/operations/authenticate.js.map +0 -1
  449. package/components/identity.federation/operations/create.d.ts +0 -8
  450. package/components/identity.federation/operations/create.js.map +0 -1
  451. package/components/identity.federation/operations/decode.d.ts +0 -3
  452. package/components/identity.federation/operations/decode.js.map +0 -1
  453. package/components/identity.federation/operations/delete.d.ts +0 -8
  454. package/components/identity.federation/operations/delete.js.map +0 -1
  455. package/components/identity.federation/operations/incept.d.ts +0 -11
  456. package/components/identity.federation/operations/incept.js.map +0 -1
  457. package/components/identity.federation/operations/lib/Configuration.d.ts +0 -39
  458. package/components/identity.federation/operations/lib/Configuration.js.map +0 -1
  459. package/components/identity.federation/operations/lib/Ctx.d.ts +0 -8
  460. package/components/identity.federation/operations/lib/Ctx.js.map +0 -1
  461. package/components/identity.federation/operations/lib/Payload.d.ts +0 -5
  462. package/components/identity.federation/operations/lib/Payload.js.map +0 -1
  463. package/components/identity.federation/operations/lib/decode.d.ts +0 -3
  464. package/components/identity.federation/operations/lib/decode.js.map +0 -1
  465. package/components/identity.federation/operations/lib/discovery.d.ts +0 -5
  466. package/components/identity.federation/operations/lib/discovery.js.map +0 -1
  467. package/components/identity.federation/operations/lib/errors.d.ts +0 -77
  468. package/components/identity.federation/operations/lib/errors.js.map +0 -1
  469. package/components/identity.federation/operations/lib/exchange.d.ts +0 -3
  470. package/components/identity.federation/operations/lib/exchange.js.map +0 -1
  471. package/components/identity.federation/operations/lib/index.d.ts +0 -4
  472. package/components/identity.federation/operations/lib/index.js.map +0 -1
  473. package/components/identity.federation/operations/lib/jose.d.ts +0 -1
  474. package/components/identity.federation/operations/lib/jose.js.map +0 -1
  475. package/components/identity.federation/operations/lib/resolve.d.ts +0 -3
  476. package/components/identity.federation/operations/lib/resolve.js.map +0 -1
  477. package/components/identity.federation/operations/list.d.ts +0 -7
  478. package/components/identity.federation/operations/list.js.map +0 -1
  479. package/components/identity.federation/operations/types/Scheme.d.ts +0 -1
  480. package/components/identity.federation/operations/types/Scheme.js.map +0 -1
  481. package/components/identity.federation/operations/types/configuration.d.ts +0 -22
  482. package/components/identity.federation/operations/types/configuration.js.map +0 -1
  483. package/components/identity.federation/operations/types/context.d.ts +0 -36
  484. package/components/identity.federation/operations/types/context.js.map +0 -1
  485. package/components/identity.federation/operations/types/entity.d.ts +0 -9
  486. package/components/identity.federation/operations/types/entity.js.map +0 -1
  487. package/components/identity.federation/operations/types/index.d.ts +0 -4
  488. package/components/identity.federation/operations/types/index.js.map +0 -1
  489. package/components/identity.grants/operations/authorize.d.ts +0 -35
  490. package/components/identity.grants/operations/authorize.js.map +0 -1
  491. package/components/identity.grants/operations/exchange.d.ts +0 -37
  492. package/components/identity.grants/operations/exchange.js.map +0 -1
  493. package/components/identity.grants/operations/lib/code.d.ts +0 -15
  494. package/components/identity.grants/operations/lib/code.js.map +0 -1
  495. package/components/identity.grants/operations/lib/identify.d.ts +0 -6
  496. package/components/identity.grants/operations/lib/identify.js.map +0 -1
  497. package/components/identity.grants/operations/lib/index.d.ts +0 -3
  498. package/components/identity.grants/operations/lib/index.js.map +0 -1
  499. package/components/identity.grants/operations/list.d.ts +0 -13
  500. package/components/identity.grants/operations/list.js.map +0 -1
  501. package/components/identity.grants/operations/revoke.d.ts +0 -18
  502. package/components/identity.grants/operations/revoke.js.map +0 -1
  503. package/components/identity.keys/operations/create.d.ts +0 -22
  504. package/components/identity.keys/operations/create.js.map +0 -1
  505. package/components/identity.keys/operations/disable.d.ts +0 -5
  506. package/components/identity.keys/operations/disable.js.map +0 -1
  507. package/components/identity.keys/operations/revoke.d.ts +0 -15
  508. package/components/identity.keys/operations/revoke.js.map +0 -1
  509. package/components/identity.otp/operations/authenticate.d.ts +0 -12
  510. package/components/identity.otp/operations/authenticate.js.map +0 -1
  511. package/components/identity.otp/operations/issue.d.ts +0 -12
  512. package/components/identity.otp/operations/issue.js.map +0 -1
  513. package/components/identity.otp/operations/lib/Context.d.ts +0 -16
  514. package/components/identity.otp/operations/lib/Context.js.map +0 -1
  515. package/components/identity.otp/operations/lib/Entity.d.ts +0 -6
  516. package/components/identity.otp/operations/lib/Entity.js.map +0 -1
  517. package/components/identity.otp/operations/lib/index.d.ts +0 -1
  518. package/components/identity.otp/operations/lib/index.js.map +0 -1
  519. package/components/identity.passkeys/operations/authenticate.d.ts +0 -16
  520. package/components/identity.passkeys/operations/authenticate.js.map +0 -1
  521. package/components/identity.passkeys/operations/challenge.d.ts +0 -35
  522. package/components/identity.passkeys/operations/challenge.js.map +0 -1
  523. package/components/identity.passkeys/operations/create.d.ts +0 -19
  524. package/components/identity.passkeys/operations/create.js.map +0 -1
  525. package/components/identity.passkeys/operations/delete.d.ts +0 -8
  526. package/components/identity.passkeys/operations/delete.js.map +0 -1
  527. package/components/identity.passkeys/operations/lib/const.d.ts +0 -1
  528. package/components/identity.passkeys/operations/lib/const.js.map +0 -1
  529. package/components/identity.passkeys/operations/list.d.ts +0 -7
  530. package/components/identity.passkeys/operations/list.js.map +0 -1
  531. package/components/identity.passkeys/operations/types/Configuration.d.ts +0 -6
  532. package/components/identity.passkeys/operations/types/Configuration.js.map +0 -1
  533. package/components/identity.passkeys/operations/types/Context.d.ts +0 -16
  534. package/components/identity.passkeys/operations/types/Context.js.map +0 -1
  535. package/components/identity.passkeys/operations/types/Passkey.d.ts +0 -12
  536. package/components/identity.passkeys/operations/types/Passkey.js.map +0 -1
  537. package/components/identity.passkeys/operations/types/index.d.ts +0 -2
  538. package/components/identity.passkeys/operations/types/index.js.map +0 -1
  539. package/components/identity.passkeys/operations/use.d.ts +0 -16
  540. package/components/identity.passkeys/operations/use.js.map +0 -1
  541. package/components/identity.roles/operations/grant.d.ts +0 -10
  542. package/components/identity.roles/operations/grant.js.map +0 -1
  543. package/components/identity.roles/operations/lib/Entity.d.ts +0 -5
  544. package/components/identity.roles/operations/lib/Entity.js.map +0 -1
  545. package/components/identity.roles/operations/list.d.ts +0 -2
  546. package/components/identity.roles/operations/list.js.map +0 -1
  547. package/components/identity.roles/operations/principal.d.ts +0 -13
  548. package/components/identity.roles/operations/principal.js.map +0 -1
  549. package/components/identity.tokens/operations/authenticate.d.ts +0 -10
  550. package/components/identity.tokens/operations/authenticate.js.map +0 -1
  551. package/components/identity.tokens/operations/decrypt.d.ts +0 -16
  552. package/components/identity.tokens/operations/decrypt.js.map +0 -1
  553. package/components/identity.tokens/operations/encrypt.d.ts +0 -9
  554. package/components/identity.tokens/operations/encrypt.js.map +0 -1
  555. package/components/identity.tokens/operations/issue.d.ts +0 -25
  556. package/components/identity.tokens/operations/issue.js.map +0 -1
  557. package/components/identity.tokens/operations/lib/form.d.ts +0 -8
  558. package/components/identity.tokens/operations/lib/form.js.map +0 -1
  559. package/components/identity.tokens/operations/lib/index.d.ts +0 -4
  560. package/components/identity.tokens/operations/lib/index.js.map +0 -1
  561. package/components/identity.tokens/operations/lib/jose.d.ts +0 -1
  562. package/components/identity.tokens/operations/lib/jose.js.map +0 -1
  563. package/components/identity.tokens/operations/lib/key.d.ts +0 -1
  564. package/components/identity.tokens/operations/lib/key.js.map +0 -1
  565. package/components/identity.tokens/operations/lib/pad.d.ts +0 -1
  566. package/components/identity.tokens/operations/lib/pad.js.map +0 -1
  567. package/components/identity.tokens/operations/revoke.d.ts +0 -2
  568. package/components/identity.tokens/operations/revoke.js.map +0 -1
@@ -0,0 +1,81 @@
1
+ import * as http from '../HTTP/index.js'
2
+ import { JSONRPC, type Failure, type Response } from './types.js'
3
+
4
+ /* The five JSON-RPC 2.0 fixes, which mean the same to every client. */
5
+ export const PARSE = -32700
6
+ export const INVALID_REQUEST = -32600
7
+ export const METHOD_NOT_FOUND = -32601
8
+ export const INVALID_PARAMS = -32602
9
+ export const INTERNAL = -32603
10
+
11
+ /*
12
+ * MCP's own. It reserves -32020 to -32099 for the specification and tells an implementation
13
+ * to use nothing of -32000 to -32019 at all — which is where this gateway's JSON-RPC codes
14
+ * sit, so none of them is answered here.
15
+ */
16
+ export const HEADER_MISMATCH = -32020
17
+ export const MISSING_CAPABILITY = -32021
18
+ export const UNSUPPORTED_VERSION = -32022
19
+
20
+ export function failure (code: number, message: string, data?: unknown): Failure {
21
+ const value: Failure = { code, message }
22
+
23
+ if (data !== undefined)
24
+ value.data = data
25
+
26
+ return value
27
+ }
28
+
29
+ export function response (id: string | number | null, error: Failure): Response {
30
+ return { jsonrpc: JSONRPC, id, error }
31
+ }
32
+
33
+ /**
34
+ * What an exception says as a JSON-RPC error.
35
+ *
36
+ * The readable text is `body`, never `message`: `http.Exception` calls `super()` with no
37
+ * argument, so every one of them carries an empty `message`.
38
+ */
39
+ export function of (exception: unknown): Failure {
40
+ if (exception instanceof http.NotFound || exception instanceof http.MethodNotAllowed)
41
+ return failure(METHOD_NOT_FOUND, text(exception, 'Method not found'))
42
+
43
+ if (exception instanceof http.BadRequest)
44
+ return failure(INVALID_PARAMS, text(exception, 'Invalid params'))
45
+
46
+ return failure(INTERNAL, 'Internal error')
47
+ }
48
+
49
+ /**
50
+ * What the call was refused with, which a model reads and may correct itself by: what the
51
+ * operation said, where it said anything, and otherwise what the status means here.
52
+ */
53
+ export function refusal (exception: http.ClientError): string {
54
+ const body = exception.body
55
+
56
+ if (typeof body !== 'object' || body === null || typeof body.code !== 'string')
57
+ return text(exception, REFUSALS[exception.status] ?? 'Refused')
58
+
59
+ const message = body.message as unknown
60
+
61
+ return typeof message === 'string' && message !== '' ? message : body.code as string
62
+ }
63
+
64
+ /**
65
+ * A refusal a model can act on, where the reply carried no words of its own. `auth` does
66
+ * not say which of its directives refused, and `auth:id` is what most of them are: a call
67
+ * naming a record that is not the caller's is the likeliest thing to have gone wrong.
68
+ */
69
+ const REFUSALS: Record<number, string> = {
70
+ 400: 'The arguments were refused',
71
+ 403: "Not authorized. If an argument names an identity or a record, it may not be the caller's own",
72
+ 404: 'There is nothing at that address',
73
+ 409: 'The record changed while the call was made',
74
+ 429: 'Too many calls'
75
+ }
76
+
77
+ function text (exception: http.Exception, fallback: string): string {
78
+ return typeof exception.body === 'string' && exception.body !== ''
79
+ ? exception.body
80
+ : fallback
81
+ }
@@ -0,0 +1 @@
1
+ export { Server } from './Server.js'
@@ -0,0 +1,85 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+
4
+ import { annotations, input, output } from './schema.js'
5
+ import type { Introspection, Schema } from '../Introspection.js'
6
+
7
+ const schema = (value: object): Schema => value as unknown as Schema
8
+
9
+ describe('input', () => {
10
+ it('should ask for a route variable by the name the template gives it', () => {
11
+ assert.deepEqual(input({ route: { id: schema({ type: 'string' }) } }, ['id']), {
12
+ type: 'object',
13
+ properties: { id: { type: 'string' } },
14
+ required: ['id'],
15
+ additionalProperties: false
16
+ })
17
+ })
18
+
19
+ it('should ask for a variable the operation does not declare', () => {
20
+ assert.deepEqual(input({}, ['id']), {
21
+ type: 'object',
22
+ properties: { id: { type: 'string' } },
23
+ required: ['id'],
24
+ additionalProperties: false
25
+ })
26
+ })
27
+
28
+ it('should carry the querystring under a name of its own', () => {
29
+ const introspection: Introspection = { query: { limit: schema({ type: 'integer' }) } }
30
+ const { properties } = input(introspection, []) as { properties: Record<string, any> }
31
+
32
+ assert.equal(properties.query.type, 'object')
33
+ assert.deepEqual(properties.query.properties, { limit: { type: 'integer' } })
34
+ })
35
+
36
+ it('should leave a header where a call has nowhere to put one', () => {
37
+ const introspection: Introspection = {
38
+ headers: { token: { header: 'x-access-token', type: 'string' } }
39
+ }
40
+
41
+ assert.deepEqual(input(introspection, []),
42
+ { type: 'object', properties: {}, additionalProperties: false })
43
+ })
44
+
45
+ it('should take the body as it is, requiring what it requires', () => {
46
+ const introspection: Introspection = {
47
+ input: schema({
48
+ type: 'object',
49
+ properties: { title: { type: 'string' }, volume: { type: 'number' } },
50
+ required: ['title']
51
+ })
52
+ }
53
+
54
+ assert.deepEqual(input(introspection, []), {
55
+ type: 'object',
56
+ properties: { title: { type: 'string' }, volume: { type: 'number' } },
57
+ required: ['title'],
58
+ additionalProperties: false
59
+ })
60
+ })
61
+ })
62
+
63
+ describe('output', () => {
64
+ it('should state a schema the operation declared', () => {
65
+ const declared = schema({ type: 'object', properties: { id: { type: 'string' } } })
66
+
67
+ assert.deepEqual(output({ output: declared }), declared)
68
+ })
69
+
70
+ it('should state none where the operation declared none', () => {
71
+ // an operation's `output` is optional and normalizes to `{}`, which describes nothing
72
+ assert.equal(output({ output: schema({}) }), undefined)
73
+ assert.equal(output({}), undefined)
74
+ })
75
+ })
76
+
77
+ describe('annotations', () => {
78
+ it('should read what the verb says of the call', () => {
79
+ assert.deepEqual(annotations('GET'), { readOnlyHint: true })
80
+ assert.deepEqual(annotations('HEAD'), { readOnlyHint: true })
81
+ assert.deepEqual(annotations('DELETE'), { destructiveHint: true, idempotentHint: true })
82
+ assert.deepEqual(annotations('PUT'), { idempotentHint: true })
83
+ assert.equal(annotations('POST'), undefined)
84
+ })
85
+ })
@@ -0,0 +1,87 @@
1
+ import type { Introspection, Schema } from '../Introspection.js'
2
+ import type { Annotations } from './types.js'
3
+
4
+ /**
5
+ * What a tool takes, which is what the procedure takes: a route variable by the name the
6
+ * template gives it, the querystring under a name of its own, and what is left is the body.
7
+ *
8
+ * A `map:headers` property is not here: a call carries no headers of its own, so there is
9
+ * nowhere for a model to put one.
10
+ */
11
+ export function input (introspection: Introspection, variables: string[]): object {
12
+ const properties: Record<string, unknown> = {}
13
+ const required: string[] = []
14
+
15
+ /*
16
+ * By the name the template gives it, which is what the tool's own name states and what
17
+ * resolving it consumes. A `map:segments` renaming is the gateway's, as invisible here as
18
+ * it is to whoever writes the path; and a variable the operation does not declare has no
19
+ * schema of its own, being a segment.
20
+ */
21
+ for (const variable of variables) {
22
+ properties[variable] = introspection.route?.[variable] ?? { type: 'string' }
23
+ required.push(variable)
24
+ }
25
+
26
+ // it is a querystring on the wire, which is nothing a model knows or needs to; what it
27
+ // is to a caller is the part of a call that picks what the call is about
28
+ if (introspection.query !== undefined)
29
+ properties.query = {
30
+ type: 'object',
31
+ description: 'Which records the call works on: what to match, in what order, ' +
32
+ 'and how many at once.',
33
+ properties: introspection.query
34
+ }
35
+
36
+ const body = introspection.input as Shape | null | undefined
37
+
38
+ if (body?.properties !== undefined) {
39
+ Object.assign(properties, body.properties)
40
+ required.push(...body.required ?? [])
41
+ }
42
+
43
+ const schema: Record<string, unknown> = { type: 'object', properties }
44
+
45
+ if (required.length > 0)
46
+ schema.required = required
47
+
48
+ // what a name does not state is not a parameter, and a model should not invent one
49
+ schema.additionalProperties = false
50
+
51
+ return schema
52
+ }
53
+
54
+ /**
55
+ * What a tool answers with, where that is worth stating. An operation's `output` is optional
56
+ * and normalizes to `{}`, which describes nothing — and a schema the revision would have the
57
+ * reply validated against is worse said emptily than left unsaid.
58
+ */
59
+ export function output (introspection: Introspection): object | undefined {
60
+ const schema = introspection.output as Shape | null | undefined
61
+
62
+ if (schema === undefined || schema === null)
63
+ return undefined
64
+
65
+ return Object.keys(schema).length === 0 ? undefined : schema as object
66
+ }
67
+
68
+ /** What the verb says of the call, which the revision has a client treat as a hint. */
69
+ export function annotations (verb: string): Annotations | undefined {
70
+ const value: Annotations = {}
71
+
72
+ if (verb === 'GET' || verb === 'HEAD')
73
+ value.readOnlyHint = true
74
+
75
+ if (verb === 'DELETE')
76
+ value.destructiveHint = true
77
+
78
+ if (verb === 'PUT' || verb === 'DELETE')
79
+ value.idempotentHint = true
80
+
81
+ return Object.keys(value).length === 0 ? undefined : value
82
+ }
83
+
84
+ interface Shape {
85
+ properties?: Record<string, Schema>
86
+ required?: string[]
87
+ }
@@ -0,0 +1,157 @@
1
+ import * as http from '../HTTP/index.js'
2
+ import { fork } from '../RPC/Context.js'
3
+ import { address, name, split } from '../RPC/names.js'
4
+ import { METHOD_NOT_FOUND, failure, refusal, response } from './errors.js'
5
+ import { annotations, input, output } from './schema.js'
6
+ import { FAMILY, MCP, type Tool as Declaration } from '../directives/mcp/index.js'
7
+ import type { Segment } from '../RTD/segment.js'
8
+ import type { Parameter, Tree } from '../RTD/index.js'
9
+ import type { Params, Result, Tool } from './types.js'
10
+
11
+ /**
12
+ * Every method this caller may reach that is published as a tool, named as the procedure
13
+ * it is.
14
+ *
15
+ * A method is a tool where it says so with `mcp:tool`, and a default denies: a tree holds
16
+ * what an application serves, and most of it is machinery a model has no business reading.
17
+ * What a caller may then do with one is what `auth` says. The tree is walked once and each
18
+ * method describes itself, which is where that is decided and where `io` and `map` say what
19
+ * may be sent.
20
+ *
21
+ * Sorted, because the revision asks for an order a client can cache on.
22
+ */
23
+ export async function list (tree: Tree, context: http.Context): Promise<Tool[]> {
24
+ const tools: Tool[] = []
25
+
26
+ /*
27
+ * Each method is described as the procedure it would be, not as the request asking. What
28
+ * refuses a credentialed request at an `anonymous` route does not refuse the call a tool
29
+ * makes, and a list that says otherwise disagrees with what `tools/call` then does.
30
+ */
31
+ const describing: http.Context = Object.create(context,
32
+ { procedural: { value: true, enumerable: true } })
33
+
34
+ for (const { segments, verb, method } of tree.walk()) {
35
+ if (MCP.published(method.directives.declared<Declaration>(FAMILY)) === null)
36
+ continue
37
+
38
+ const named = name(segments, verb)
39
+
40
+ // a route a name cannot spell is a route nothing addresses, here or at `/.rpc`
41
+ if (named === null)
42
+ continue
43
+
44
+ const variables = parameters(segments)
45
+ const introspection = await method.explain(describing, variables)
46
+
47
+ if (introspection === null)
48
+ continue
49
+
50
+ const described = introspection.description
51
+ const schema = output(introspection)
52
+ const hints = annotations(verb)
53
+
54
+ // in the order the revision documents one, which is the order it is read in
55
+ const tool: Tool = {
56
+ name: named,
57
+ ...introspection.title === undefined ? {} : { title: introspection.title },
58
+ ...described === undefined ? {} : { description: described },
59
+ inputSchema: input(introspection, variables.map((variable) => variable.name)),
60
+ ...schema === undefined ? {} : { outputSchema: schema },
61
+ ...hints === undefined ? {} : { annotations: hints }
62
+ }
63
+
64
+ tools.push(tool)
65
+ }
66
+
67
+ return tools.sort((one, other) => one.name < other.name ? -1 : 1)
68
+ }
69
+
70
+ /**
71
+ * The call the tool is. Its arguments are the procedure's parameters, taken apart the way a
72
+ * request carries them, and what answers is the same `route` an ordinary request goes to.
73
+ *
74
+ * A name that is not a published tool is answered as no tool at all, whether or not a route
75
+ * would have taken it: what an application did not publish is not reachable here by guessing
76
+ * its name. What the caller may then do with one that is published is still `auth`'s to say.
77
+ */
78
+ export async function call (scope: Scope, named: string, args: Params): Promise<Result> {
79
+ if (!published(scope.tree, named))
80
+ throw new http.NotFound(response(null,
81
+ failure(METHOD_NOT_FOUND, `'${named}' is not a tool this server publishes`)))
82
+
83
+ const { path, verb, variables } = address(named, args)
84
+ const { query, input: body } = split(args, variables)
85
+ const clone = fork(scope.context, path, verb, query, body)
86
+
87
+ try {
88
+ const message = await scope.route(clone)
89
+
90
+ // what `io:output` restricts, over this call's reply rather than the envelope
91
+ await http.shape(clone, message)
92
+
93
+ return result(message.body)
94
+ } catch (exception) {
95
+ /*
96
+ * What the route made of this call is a value a model reads and may correct itself by:
97
+ * an operation that refused, an argument `io:input` would not take, a record that is
98
+ * not there, an identity `auth` would not let it act on. A credential is none of those
99
+ * — that is the client's to fix and not the model's, so it is answered as it is — and
100
+ * neither is a fault of this server, which is a protocol error and stays one.
101
+ */
102
+ if (exception instanceof http.ClientError && !(exception instanceof http.Unauthorized))
103
+ return { content: [{ type: 'text', text: refusal(exception) }], isError: true }
104
+
105
+ throw exception
106
+ }
107
+ }
108
+
109
+ /** Everything a call needs that is not the call: the request it is of, and what answers it. */
110
+ export interface Scope {
111
+ context: http.Context
112
+ route: http.Processor
113
+ tree: Tree
114
+ }
115
+
116
+ /**
117
+ * Whether the tree publishes this name as a tool. What `auth` makes of the caller is not
118
+ * asked here — the declaration is the route's and does not vary by who is calling, and the
119
+ * call that follows is authorized as any request to that route is.
120
+ */
121
+ function published (tree: Tree, named: string): boolean {
122
+ for (const { segments, verb, method } of tree.walk())
123
+ if (name(segments, verb) === named)
124
+ return MCP.published(method.directives.declared<Declaration>(FAMILY)) !== null
125
+
126
+ return false
127
+ }
128
+
129
+ function result (body: unknown): Result {
130
+ if (body === undefined || body === null)
131
+ return { content: [] }
132
+
133
+ return {
134
+ content: [{ type: 'text', text: JSON.stringify(body) }],
135
+ structuredContent: body
136
+ }
137
+ }
138
+
139
+ /**
140
+ * What a route template takes, by name. Describing has no values for them — a template is
141
+ * not a path — and nothing that describes a method reads one.
142
+ */
143
+ function parameters (segments: Segment[]): Parameter[] {
144
+ const params: Parameter[] = []
145
+
146
+ for (const segment of segments) {
147
+ if (segment.fragment !== null)
148
+ continue
149
+
150
+ if (segment.wildcard === true)
151
+ params.push({ name: '**', value: '' })
152
+ else if (segment.placeholder !== null)
153
+ params.push({ name: segment.placeholder, value: '' })
154
+ }
155
+
156
+ return params
157
+ }
@@ -0,0 +1,84 @@
1
+ /** The revision this endpoint serves, where a request carries its own metadata. */
2
+ export const MODERN = '2026-07-28'
3
+
4
+ /** The newest revision reached by an `initialize` handshake, which is what clients still send. */
5
+ export const LEGACY = '2025-11-25'
6
+
7
+ export const VERSIONS = [MODERN, LEGACY]
8
+
9
+ /** The version every JSON-RPC message states, which is not the protocol's. */
10
+ export const JSONRPC = '2.0'
11
+
12
+ /** The prefix the revision reserves for itself in `_meta`. */
13
+ export const RESERVED = 'io.modelcontextprotocol/'
14
+
15
+ export const PROTOCOL_VERSION = RESERVED + 'protocolVersion'
16
+ export const CLIENT_CAPABILITIES = RESERVED + 'clientCapabilities'
17
+ export const SERVER_INFO = RESERVED + 'serverInfo'
18
+
19
+ export type Params = Record<string, unknown>
20
+
21
+ export interface Message {
22
+ jsonrpc: string
23
+ method: string
24
+ params?: Params
25
+
26
+ /** Absent makes this a notification, which is answered by not answering. */
27
+ id?: string | number
28
+ }
29
+
30
+ export interface Failure {
31
+ code: number
32
+ message: string
33
+ data?: unknown
34
+ }
35
+
36
+ export interface Response {
37
+ jsonrpc: string
38
+ id: string | number | null
39
+ result?: unknown
40
+ error?: Failure
41
+ }
42
+
43
+ /**
44
+ * How long a complete result may be held, and by whom. `private` is a result that is the
45
+ * caller's alone — a list `auth` filtered for their identity is not another caller's list.
46
+ */
47
+ export interface Cache {
48
+ ttlMs: number
49
+ cacheScope: 'public' | 'private'
50
+ }
51
+
52
+ /** What a tool answers with: what a model reads, and the reply itself. */
53
+ export interface Result {
54
+ content: Content[]
55
+ structuredContent?: unknown
56
+
57
+ /** The operation refused, which is something a model can read and correct. */
58
+ isError?: boolean
59
+ }
60
+
61
+ export interface Content {
62
+ type: 'text'
63
+ text: string
64
+ }
65
+
66
+ export interface Tool {
67
+ name: string
68
+
69
+ /** what a person is shown where a client lists this tool; a name is an address */
70
+ title?: string
71
+
72
+ /** what the route states this method is */
73
+ description?: string
74
+ inputSchema: object
75
+ outputSchema?: object
76
+ annotations?: Annotations
77
+ }
78
+
79
+ /** What the verb says about the call, which the revision asks a client to treat as a hint. */
80
+ export interface Annotations {
81
+ readOnlyHint?: boolean
82
+ destructiveHint?: boolean
83
+ idempotentHint?: boolean
84
+ }
package/source/Query.ts CHANGED
@@ -4,6 +4,7 @@ import * as http from './HTTP/index.js'
4
4
  import { type Parameter } from './RTD/index.js'
5
5
  import * as schemas from './schemas.js'
6
6
  import { queryable } from './Mapping.js'
7
+ import { take } from './Introspection.js'
7
8
  import type { Introspection, Schema } from './Introspection.js'
8
9
  import type * as syntax from './RTD/syntax/index.js'
9
10
  import type * as core from '@toa.io/core'
@@ -68,22 +69,43 @@ export class Query {
68
69
  }
69
70
  }
70
71
 
72
+ /**
73
+ * What the querystring carries: the parameters this method declares, taken out of the
74
+ * input because they are not the body's, and what a queryable method accepts besides.
75
+ *
76
+ * Only what it actually accepts — a criteria the declaration closes is refused, and so is
77
+ * a search where none was asked for.
78
+ */
71
79
  public explain (introspection: Introspection): Record<string, Schema> | null {
72
- if (this.query?.parameters === undefined || introspection.input?.type !== 'object')
73
- return null
74
-
75
80
  let query: Record<string, Schema> | null = null
76
81
 
77
- for (const parameter of this.query.parameters) {
78
- const schema = introspection.input.properties[parameter]
82
+ if (this.query?.parameters !== undefined)
83
+ for (const parameter of this.query.parameters) {
84
+ const schema = take(introspection, parameter)
85
+
86
+ // eslint-disable-next-line max-depth
87
+ if (schema === undefined)
88
+ continue
79
89
 
80
- if (schema !== undefined) {
81
90
  query ??= {}
82
91
  query[parameter] = schema
83
92
  }
84
93
 
85
- delete introspection.input.properties[parameter]
86
- }
94
+ if (!this.queryable)
95
+ return query
96
+
97
+ query ??= {}
98
+
99
+ if (!this.closed)
100
+ query.criteria = keyword('string',
101
+ 'What to match, in RSQL: `state==hot`, `rank=gt=5;name==*tea*`.')
102
+
103
+ query.sort = keyword('string', 'What to order by: `rank:desc`, or `rank` for ascending.')
104
+ query.limit = bounded('How many at once.', this.query.limit!)
105
+ query.omit = bounded('How many to skip.', this.query.omit!)
106
+
107
+ if (this.searchable)
108
+ query.search = keyword('string', 'What to search the text index for.')
87
109
 
88
110
  return query
89
111
  }
@@ -202,6 +224,24 @@ interface CriteriaGroup {
202
224
  operator: ',' | ';'
203
225
  }
204
226
 
227
+ function keyword (type: string, description: string): Schema {
228
+ return { type, description } as unknown as Schema
229
+ }
230
+
231
+ function bounded (description: string, bounds: syntax.Range): Schema {
232
+ const schema: Record<string, unknown> = {
233
+ type: 'integer',
234
+ description,
235
+ minimum: bounds.range[0],
236
+ maximum: bounds.range[1]
237
+ }
238
+
239
+ if (bounds.value !== undefined)
240
+ schema.default = bounds.value
241
+
242
+ return schema as unknown as Schema
243
+ }
244
+
205
245
  export interface QueryString {
206
246
  query: core.Query | null
207
247
  parameters: Record<string, string> | null
@@ -0,0 +1,78 @@
1
+ import * as http from '../HTTP/index.js'
2
+ import { Timing } from '../HTTP/Timing.js'
3
+ import type { Params } from './types.js'
4
+
5
+ /**
6
+ * One call, as a request the rest of the gateway can serve.
7
+ *
8
+ * The clone is the transport context except for what the call decides, so nothing
9
+ * downstream — the router, the directives, the endpoint, the mapping — knows it is one.
10
+ * It is derived from the context rather than built beside it, so everything not named
11
+ * here, `identity` included, is read through.
12
+ */
13
+ // eslint-disable-next-line max-params
14
+ export function fork (context: http.Context, path: string, verb: string,
15
+ query: Params | undefined, input: unknown): http.Context {
16
+ const url = new URL(path, context.url)
17
+
18
+ if (query !== undefined)
19
+ for (const [name, value] of Object.entries(query))
20
+ url.searchParams.set(name, String(value))
21
+
22
+ const headers = { ...context.request.headers }
23
+
24
+ // a conditional is the envelope's, and a call would answer 304 to a question nobody asked
25
+ delete headers['if-match']
26
+ delete headers['if-none-match']
27
+
28
+ const request = Object.create(context.request, {
29
+ method: { value: verb, enumerable: true },
30
+ headers: { value: headers, enumerable: true }
31
+ })
32
+
33
+ // its own, so an `io:output` restriction shapes this call's reply and no other
34
+ const pipelines: Pipelines = { body: [], response: [] }
35
+
36
+ return Object.create(context, {
37
+ /*
38
+ * A credential refuses an `anonymous` route because it would make the reply
39
+ * uncacheable. What a procedure answers is not a reply: it is a value in an envelope
40
+ * this gateway answers `no-store`, and the procedure's own headers are discarded.
41
+ */
42
+ procedural: { value: true, enumerable: true },
43
+ url: { value: url, enumerable: true },
44
+ request: { value: request, enumerable: true },
45
+ pipelines: { value: pipelines, enumerable: true },
46
+ /*
47
+ * Its own, so that what the stages of a call take is measured per call and stays there.
48
+ * `server-timing` is a header, and a request carrying thirty-two calls would otherwise
49
+ * write ninety-six values into one — where a trace says the same thing, per call.
50
+ */
51
+ timing: { value: new Timing(), enumerable: true },
52
+ body: {
53
+ value: async () => {
54
+ let value = input
55
+
56
+ for (const transform of pipelines.body)
57
+ value = await transform(value)
58
+
59
+ return value
60
+ }
61
+ },
62
+ /*
63
+ * The raw request is the envelope, and it has been read. `map:buffer` is the one
64
+ * directive that asks for it, and answering with a spent stream would hand the
65
+ * operation an empty string; refusing says what is actually the matter.
66
+ */
67
+ buffer: {
68
+ value: () => {
69
+ throw new http.BadRequest('`map:buffer` reads the request, which a call is not')
70
+ }
71
+ }
72
+ }) as http.Context
73
+ }
74
+
75
+ interface Pipelines {
76
+ body: Array<(input: unknown) => unknown>
77
+ response: Array<(output: http.OutgoingMessage) => void | Promise<void>>
78
+ }