crypto-quant-signal-mcp 1.32.0 → 1.33.0

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 (410) hide show
  1. package/.cursor-plugin/plugin.json +1 -1
  2. package/README.md +13 -9
  3. package/dist/facilitator.js +2 -0
  4. package/dist/facilitator.js.map +1 -1
  5. package/dist/index.d.ts +22 -5
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +156 -47
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/adapters/_upstream-fetch.d.ts.map +1 -1
  10. package/dist/lib/adapters/_upstream-fetch.js +3 -2
  11. package/dist/lib/adapters/_upstream-fetch.js.map +1 -1
  12. package/dist/lib/adapters/aster.d.ts.map +1 -1
  13. package/dist/lib/adapters/aster.js +7 -0
  14. package/dist/lib/adapters/aster.js.map +1 -1
  15. package/dist/lib/adapters/binance.d.ts.map +1 -1
  16. package/dist/lib/adapters/binance.js +51 -11
  17. package/dist/lib/adapters/binance.js.map +1 -1
  18. package/dist/lib/adapters/bingx.d.ts +2 -0
  19. package/dist/lib/adapters/bingx.d.ts.map +1 -1
  20. package/dist/lib/adapters/bingx.js +22 -1
  21. package/dist/lib/adapters/bingx.js.map +1 -1
  22. package/dist/lib/adapters/bitget.d.ts +7 -0
  23. package/dist/lib/adapters/bitget.d.ts.map +1 -1
  24. package/dist/lib/adapters/bitget.js +43 -12
  25. package/dist/lib/adapters/bitget.js.map +1 -1
  26. package/dist/lib/adapters/bybit.d.ts +7 -0
  27. package/dist/lib/adapters/bybit.d.ts.map +1 -1
  28. package/dist/lib/adapters/bybit.js +42 -10
  29. package/dist/lib/adapters/bybit.js.map +1 -1
  30. package/dist/lib/adapters/hyperliquid.d.ts +8 -0
  31. package/dist/lib/adapters/hyperliquid.d.ts.map +1 -1
  32. package/dist/lib/adapters/hyperliquid.js +23 -2
  33. package/dist/lib/adapters/hyperliquid.js.map +1 -1
  34. package/dist/lib/adapters/kucoin.d.ts +8 -0
  35. package/dist/lib/adapters/kucoin.d.ts.map +1 -1
  36. package/dist/lib/adapters/kucoin.js +18 -0
  37. package/dist/lib/adapters/kucoin.js.map +1 -1
  38. package/dist/lib/adapters/okx.d.ts +8 -0
  39. package/dist/lib/adapters/okx.d.ts.map +1 -1
  40. package/dist/lib/adapters/okx.js +47 -37
  41. package/dist/lib/adapters/okx.js.map +1 -1
  42. package/dist/lib/asset-class-detection.d.ts +164 -66
  43. package/dist/lib/asset-class-detection.d.ts.map +1 -1
  44. package/dist/lib/asset-class-detection.js +405 -232
  45. package/dist/lib/asset-class-detection.js.map +1 -1
  46. package/dist/lib/asset-tiers.d.ts +13 -6
  47. package/dist/lib/asset-tiers.d.ts.map +1 -1
  48. package/dist/lib/asset-tiers.js +23 -9
  49. package/dist/lib/asset-tiers.js.map +1 -1
  50. package/dist/lib/chat-engine.d.ts +24 -1
  51. package/dist/lib/chat-engine.d.ts.map +1 -1
  52. package/dist/lib/chat-engine.js +62 -12
  53. package/dist/lib/chat-engine.js.map +1 -1
  54. package/dist/lib/chat-rate-limit.d.ts +9 -2
  55. package/dist/lib/chat-rate-limit.d.ts.map +1 -1
  56. package/dist/lib/chat-rate-limit.js +9 -2
  57. package/dist/lib/chat-rate-limit.js.map +1 -1
  58. package/dist/lib/client-registry.d.ts +27 -0
  59. package/dist/lib/client-registry.d.ts.map +1 -1
  60. package/dist/lib/client-registry.js +20 -2
  61. package/dist/lib/client-registry.js.map +1 -1
  62. package/dist/lib/client-setup.d.ts +36 -0
  63. package/dist/lib/client-setup.d.ts.map +1 -0
  64. package/dist/lib/client-setup.js +59 -0
  65. package/dist/lib/client-setup.js.map +1 -0
  66. package/dist/lib/credential-outcome.d.ts +11 -1
  67. package/dist/lib/credential-outcome.d.ts.map +1 -1
  68. package/dist/lib/credential-outcome.js +8 -1
  69. package/dist/lib/credential-outcome.js.map +1 -1
  70. package/dist/lib/credential-refusal.d.ts +21 -11
  71. package/dist/lib/credential-refusal.d.ts.map +1 -1
  72. package/dist/lib/credential-refusal.js +12 -5
  73. package/dist/lib/credential-refusal.js.map +1 -1
  74. package/dist/lib/digest-signal-performance.d.ts +48 -0
  75. package/dist/lib/digest-signal-performance.d.ts.map +1 -0
  76. package/dist/lib/digest-signal-performance.js +72 -0
  77. package/dist/lib/digest-signal-performance.js.map +1 -0
  78. package/dist/lib/email.d.ts +10 -0
  79. package/dist/lib/email.d.ts.map +1 -1
  80. package/dist/lib/email.js +44 -19
  81. package/dist/lib/email.js.map +1 -1
  82. package/dist/lib/errors.d.ts +53 -5
  83. package/dist/lib/errors.d.ts.map +1 -1
  84. package/dist/lib/errors.js +65 -7
  85. package/dist/lib/errors.js.map +1 -1
  86. package/dist/lib/exchange-adapter.d.ts.map +1 -1
  87. package/dist/lib/exchange-adapter.js +69 -1
  88. package/dist/lib/exchange-adapter.js.map +1 -1
  89. package/dist/lib/exchange-universe.d.ts +17 -1
  90. package/dist/lib/exchange-universe.d.ts.map +1 -1
  91. package/dist/lib/exchange-universe.js +32 -11
  92. package/dist/lib/exchange-universe.js.map +1 -1
  93. package/dist/lib/feature-registry.d.ts +22 -0
  94. package/dist/lib/feature-registry.d.ts.map +1 -1
  95. package/dist/lib/feature-registry.js +20 -0
  96. package/dist/lib/feature-registry.js.map +1 -1
  97. package/dist/lib/free-keys-store.d.ts +13 -0
  98. package/dist/lib/free-keys-store.d.ts.map +1 -1
  99. package/dist/lib/free-keys-store.js +18 -7
  100. package/dist/lib/free-keys-store.js.map +1 -1
  101. package/dist/lib/funding-venues.d.ts +21 -14
  102. package/dist/lib/funding-venues.d.ts.map +1 -1
  103. package/dist/lib/funding-venues.js +33 -24
  104. package/dist/lib/funding-venues.js.map +1 -1
  105. package/dist/lib/funnel-scoreboard.d.ts.map +1 -1
  106. package/dist/lib/funnel-scoreboard.js +14 -7
  107. package/dist/lib/funnel-scoreboard.js.map +1 -1
  108. package/dist/lib/funnel-snapshot.d.ts.map +1 -1
  109. package/dist/lib/funnel-snapshot.js +7 -4
  110. package/dist/lib/funnel-snapshot.js.map +1 -1
  111. package/dist/lib/integrations-data/mcp-clients.d.ts +14 -0
  112. package/dist/lib/integrations-data/mcp-clients.d.ts.map +1 -1
  113. package/dist/lib/integrations-data/mcp-clients.js +41 -26
  114. package/dist/lib/integrations-data/mcp-clients.js.map +1 -1
  115. package/dist/lib/integrations-data/types.d.ts +9 -0
  116. package/dist/lib/integrations-data/types.d.ts.map +1 -1
  117. package/dist/lib/license.d.ts +66 -0
  118. package/dist/lib/license.d.ts.map +1 -1
  119. package/dist/lib/license.js +81 -4
  120. package/dist/lib/license.js.map +1 -1
  121. package/dist/lib/lifecycle/identity.d.ts +15 -0
  122. package/dist/lib/lifecycle/identity.d.ts.map +1 -1
  123. package/dist/lib/lifecycle/identity.js +38 -1
  124. package/dist/lib/lifecycle/identity.js.map +1 -1
  125. package/dist/lib/lifecycle/steps.d.ts.map +1 -1
  126. package/dist/lib/lifecycle/steps.js +1 -2
  127. package/dist/lib/lifecycle/steps.js.map +1 -1
  128. package/dist/lib/lifecycle-copy.d.ts +11 -18
  129. package/dist/lib/lifecycle-copy.d.ts.map +1 -1
  130. package/dist/lib/lifecycle-copy.js +13 -28
  131. package/dist/lib/lifecycle-copy.js.map +1 -1
  132. package/dist/lib/live-price.d.ts +107 -27
  133. package/dist/lib/live-price.d.ts.map +1 -1
  134. package/dist/lib/live-price.js +148 -35
  135. package/dist/lib/live-price.js.map +1 -1
  136. package/dist/lib/market-regime-scanner.d.ts +16 -0
  137. package/dist/lib/market-regime-scanner.d.ts.map +1 -1
  138. package/dist/lib/market-regime-scanner.js +30 -17
  139. package/dist/lib/market-regime-scanner.js.map +1 -1
  140. package/dist/lib/market-sessions-constants.d.ts +264 -13
  141. package/dist/lib/market-sessions-constants.d.ts.map +1 -1
  142. package/dist/lib/market-sessions-constants.js +125 -18
  143. package/dist/lib/market-sessions-constants.js.map +1 -1
  144. package/dist/lib/market-sessions.d.ts +5 -2
  145. package/dist/lib/market-sessions.d.ts.map +1 -1
  146. package/dist/lib/market-sessions.js +7 -6
  147. package/dist/lib/market-sessions.js.map +1 -1
  148. package/dist/lib/nav-manifest.d.ts +1 -1
  149. package/dist/lib/nav-manifest.d.ts.map +1 -1
  150. package/dist/lib/nav-manifest.js +2 -1
  151. package/dist/lib/nav-manifest.js.map +1 -1
  152. package/dist/lib/oauth/challenge.d.ts +71 -0
  153. package/dist/lib/oauth/challenge.d.ts.map +1 -0
  154. package/dist/lib/oauth/challenge.js +123 -0
  155. package/dist/lib/oauth/challenge.js.map +1 -0
  156. package/dist/lib/oauth/clients.d.ts +53 -0
  157. package/dist/lib/oauth/clients.d.ts.map +1 -0
  158. package/dist/lib/oauth/clients.js +223 -0
  159. package/dist/lib/oauth/clients.js.map +1 -0
  160. package/dist/lib/oauth/limits.d.ts +49 -0
  161. package/dist/lib/oauth/limits.d.ts.map +1 -0
  162. package/dist/lib/oauth/limits.js +102 -0
  163. package/dist/lib/oauth/limits.js.map +1 -0
  164. package/dist/lib/oauth/metadata.d.ts +39 -0
  165. package/dist/lib/oauth/metadata.d.ts.map +1 -0
  166. package/dist/lib/oauth/metadata.js +99 -0
  167. package/dist/lib/oauth/metadata.js.map +1 -0
  168. package/dist/lib/oauth/mode.d.ts +22 -0
  169. package/dist/lib/oauth/mode.d.ts.map +1 -0
  170. package/dist/lib/oauth/mode.js +29 -0
  171. package/dist/lib/oauth/mode.js.map +1 -0
  172. package/dist/lib/oauth/pages.d.ts +45 -0
  173. package/dist/lib/oauth/pages.d.ts.map +1 -0
  174. package/dist/lib/oauth/pages.js +109 -0
  175. package/dist/lib/oauth/pages.js.map +1 -0
  176. package/dist/lib/oauth/provider.d.ts +37 -0
  177. package/dist/lib/oauth/provider.d.ts.map +1 -0
  178. package/dist/lib/oauth/provider.js +363 -0
  179. package/dist/lib/oauth/provider.js.map +1 -0
  180. package/dist/lib/oauth/resolve.d.ts +27 -0
  181. package/dist/lib/oauth/resolve.d.ts.map +1 -0
  182. package/dist/lib/oauth/resolve.js +135 -0
  183. package/dist/lib/oauth/resolve.js.map +1 -0
  184. package/dist/lib/oauth/routes.d.ts +24 -0
  185. package/dist/lib/oauth/routes.d.ts.map +1 -0
  186. package/dist/lib/oauth/routes.js +420 -0
  187. package/dist/lib/oauth/routes.js.map +1 -0
  188. package/dist/lib/oauth/store.d.ts +127 -0
  189. package/dist/lib/oauth/store.d.ts.map +1 -0
  190. package/dist/lib/oauth/store.js +314 -0
  191. package/dist/lib/oauth/store.js.map +1 -0
  192. package/dist/lib/off-origin-redirect.d.ts +10 -1
  193. package/dist/lib/off-origin-redirect.d.ts.map +1 -1
  194. package/dist/lib/off-origin-redirect.js +23 -3
  195. package/dist/lib/off-origin-redirect.js.map +1 -1
  196. package/dist/lib/performance-db.d.ts +84 -16
  197. package/dist/lib/performance-db.d.ts.map +1 -1
  198. package/dist/lib/performance-db.js +197 -51
  199. package/dist/lib/performance-db.js.map +1 -1
  200. package/dist/lib/pfe-defect-window-rows.d.ts +23 -0
  201. package/dist/lib/pfe-defect-window-rows.d.ts.map +1 -0
  202. package/dist/lib/pfe-defect-window-rows.js +397 -0
  203. package/dist/lib/pfe-defect-window-rows.js.map +1 -0
  204. package/dist/lib/pfe-scoring.d.ts +125 -2
  205. package/dist/lib/pfe-scoring.d.ts.map +1 -1
  206. package/dist/lib/pfe-scoring.js +267 -12
  207. package/dist/lib/pfe-scoring.js.map +1 -1
  208. package/dist/lib/platform-egress.d.ts +12 -0
  209. package/dist/lib/platform-egress.d.ts.map +1 -0
  210. package/dist/lib/platform-egress.js +82 -0
  211. package/dist/lib/platform-egress.js.map +1 -0
  212. package/dist/lib/pre-trade-calc.d.ts +79 -0
  213. package/dist/lib/pre-trade-calc.d.ts.map +1 -0
  214. package/dist/lib/pre-trade-calc.js +77 -0
  215. package/dist/lib/pre-trade-calc.js.map +1 -0
  216. package/dist/lib/pre-trade-check-log.d.ts +91 -0
  217. package/dist/lib/pre-trade-check-log.d.ts.map +1 -0
  218. package/dist/lib/pre-trade-check-log.js +187 -0
  219. package/dist/lib/pre-trade-check-log.js.map +1 -0
  220. package/dist/lib/pre-trade-costs.d.ts +79 -0
  221. package/dist/lib/pre-trade-costs.d.ts.map +1 -0
  222. package/dist/lib/pre-trade-costs.js +78 -0
  223. package/dist/lib/pre-trade-costs.js.map +1 -0
  224. package/dist/lib/pre-trade-decision.d.ts +236 -0
  225. package/dist/lib/pre-trade-decision.d.ts.map +1 -0
  226. package/dist/lib/pre-trade-decision.js +372 -0
  227. package/dist/lib/pre-trade-decision.js.map +1 -0
  228. package/dist/lib/pre-trade-rules.d.ts +243 -0
  229. package/dist/lib/pre-trade-rules.d.ts.map +1 -0
  230. package/dist/lib/pre-trade-rules.js +182 -0
  231. package/dist/lib/pre-trade-rules.js.map +1 -0
  232. package/dist/lib/public-performance-formatter.d.ts.map +1 -1
  233. package/dist/lib/public-performance-formatter.js +1 -0
  234. package/dist/lib/public-performance-formatter.js.map +1 -1
  235. package/dist/lib/quota-notice.d.ts +8 -0
  236. package/dist/lib/quota-notice.d.ts.map +1 -1
  237. package/dist/lib/quota-notice.js +11 -0
  238. package/dist/lib/quota-notice.js.map +1 -1
  239. package/dist/lib/quota-surfaces.d.ts.map +1 -1
  240. package/dist/lib/quota-surfaces.js +12 -0
  241. package/dist/lib/quota-surfaces.js.map +1 -1
  242. package/dist/lib/receipts.d.ts +2 -2
  243. package/dist/lib/receipts.d.ts.map +1 -1
  244. package/dist/lib/receipts.js +2 -1
  245. package/dist/lib/receipts.js.map +1 -1
  246. package/dist/lib/refuse-encoded-bodies.d.ts +34 -0
  247. package/dist/lib/refuse-encoded-bodies.d.ts.map +1 -0
  248. package/dist/lib/refuse-encoded-bodies.js +53 -0
  249. package/dist/lib/refuse-encoded-bodies.js.map +1 -0
  250. package/dist/lib/regime-snapshots.d.ts +6 -0
  251. package/dist/lib/regime-snapshots.d.ts.map +1 -1
  252. package/dist/lib/regime-snapshots.js +12 -0
  253. package/dist/lib/regime-snapshots.js.map +1 -1
  254. package/dist/lib/scan-shared.d.ts +5 -4
  255. package/dist/lib/scan-shared.d.ts.map +1 -1
  256. package/dist/lib/scan-shared.js +19 -23
  257. package/dist/lib/scan-shared.js.map +1 -1
  258. package/dist/lib/signin-identity.d.ts +5 -0
  259. package/dist/lib/signin-identity.d.ts.map +1 -1
  260. package/dist/lib/signin-identity.js +4 -2
  261. package/dist/lib/signin-identity.js.map +1 -1
  262. package/dist/lib/tier-warning.d.ts +8 -1
  263. package/dist/lib/tier-warning.d.ts.map +1 -1
  264. package/dist/lib/tier-warning.js +12 -4
  265. package/dist/lib/tier-warning.js.map +1 -1
  266. package/dist/lib/tool-call-pipeline.d.ts.map +1 -1
  267. package/dist/lib/tool-call-pipeline.js +71 -6
  268. package/dist/lib/tool-call-pipeline.js.map +1 -1
  269. package/dist/lib/tool-metadata-projection.d.ts +22 -0
  270. package/dist/lib/tool-metadata-projection.d.ts.map +1 -0
  271. package/dist/lib/tool-metadata-projection.js +17 -0
  272. package/dist/lib/tool-metadata-projection.js.map +1 -0
  273. package/dist/lib/tool-param-schema.d.ts +108 -2
  274. package/dist/lib/tool-param-schema.d.ts.map +1 -1
  275. package/dist/lib/tool-param-schema.js +68 -1
  276. package/dist/lib/tool-param-schema.js.map +1 -1
  277. package/dist/lib/tools-list-event.d.ts +8 -0
  278. package/dist/lib/tools-list-event.d.ts.map +1 -1
  279. package/dist/lib/tools-list-event.js +7 -1
  280. package/dist/lib/tools-list-event.js.map +1 -1
  281. package/dist/lib/tradfi-funding.d.ts +2 -1
  282. package/dist/lib/tradfi-funding.d.ts.map +1 -1
  283. package/dist/lib/tradfi-funding.js +6 -14
  284. package/dist/lib/tradfi-funding.js.map +1 -1
  285. package/dist/lib/underlying-type.d.ts +1 -22
  286. package/dist/lib/underlying-type.d.ts.map +1 -1
  287. package/dist/lib/underlying-type.js +19 -146
  288. package/dist/lib/underlying-type.js.map +1 -1
  289. package/dist/lib/universe-admission.d.ts +33 -0
  290. package/dist/lib/universe-admission.d.ts.map +1 -1
  291. package/dist/lib/universe-admission.js +61 -0
  292. package/dist/lib/universe-admission.js.map +1 -1
  293. package/dist/lib/venue-fees.d.ts +33 -0
  294. package/dist/lib/venue-fees.d.ts.map +1 -0
  295. package/dist/lib/venue-fees.js +79 -0
  296. package/dist/lib/venue-fees.js.map +1 -0
  297. package/dist/lib/venue-margin-tiers.d.ts +52 -0
  298. package/dist/lib/venue-margin-tiers.d.ts.map +1 -0
  299. package/dist/lib/venue-margin-tiers.js +146 -0
  300. package/dist/lib/venue-margin-tiers.js.map +1 -0
  301. package/dist/lib/venue-market-state.d.ts +58 -0
  302. package/dist/lib/venue-market-state.d.ts.map +1 -0
  303. package/dist/lib/venue-market-state.js +155 -0
  304. package/dist/lib/venue-market-state.js.map +1 -0
  305. package/dist/lib/verdict-factors.d.ts +3 -2
  306. package/dist/lib/verdict-factors.d.ts.map +1 -1
  307. package/dist/lib/verdict-factors.js +1 -1
  308. package/dist/lib/verdict-factors.js.map +1 -1
  309. package/dist/lib/verdict-rule-assignment.d.ts +9 -1
  310. package/dist/lib/verdict-rule-assignment.d.ts.map +1 -1
  311. package/dist/lib/verdict-rule-assignment.js +10 -2
  312. package/dist/lib/verdict-rule-assignment.js.map +1 -1
  313. package/dist/lib/webhook-api.d.ts +4 -3
  314. package/dist/lib/webhook-api.d.ts.map +1 -1
  315. package/dist/lib/webhook-api.js +4 -3
  316. package/dist/lib/webhook-api.js.map +1 -1
  317. package/dist/lib/webhook-delivery.d.ts +3 -2
  318. package/dist/lib/webhook-delivery.d.ts.map +1 -1
  319. package/dist/lib/webhook-delivery.js +14 -45
  320. package/dist/lib/webhook-delivery.js.map +1 -1
  321. package/dist/lib/webhook-ssrf.d.ts +33 -0
  322. package/dist/lib/webhook-ssrf.d.ts.map +1 -1
  323. package/dist/lib/webhook-ssrf.js +112 -1
  324. package/dist/lib/webhook-ssrf.js.map +1 -1
  325. package/dist/lib/welcome-page.d.ts.map +1 -1
  326. package/dist/lib/welcome-page.js +44 -9
  327. package/dist/lib/welcome-page.js.map +1 -1
  328. package/dist/lib/x402-bazaar.d.ts.map +1 -1
  329. package/dist/lib/x402-bazaar.js +92 -1
  330. package/dist/lib/x402-bazaar.js.map +1 -1
  331. package/dist/lib/x402-http-routes.d.ts +4 -3
  332. package/dist/lib/x402-http-routes.d.ts.map +1 -1
  333. package/dist/lib/x402-http-routes.js +34 -29
  334. package/dist/lib/x402-http-routes.js.map +1 -1
  335. package/dist/lib/x402-idempotency-store.d.ts +17 -0
  336. package/dist/lib/x402-idempotency-store.d.ts.map +1 -1
  337. package/dist/lib/x402-idempotency-store.js +39 -1
  338. package/dist/lib/x402-idempotency-store.js.map +1 -1
  339. package/dist/lib/x402-operator-wallets.d.ts +16 -0
  340. package/dist/lib/x402-operator-wallets.d.ts.map +1 -1
  341. package/dist/lib/x402-operator-wallets.js +16 -0
  342. package/dist/lib/x402-operator-wallets.js.map +1 -1
  343. package/dist/lib/x402.d.ts +25 -0
  344. package/dist/lib/x402.d.ts.map +1 -1
  345. package/dist/lib/x402.js +38 -2
  346. package/dist/lib/x402.js.map +1 -1
  347. package/dist/resources/signal-performance.d.ts.map +1 -1
  348. package/dist/resources/signal-performance.js +3 -2
  349. package/dist/resources/signal-performance.js.map +1 -1
  350. package/dist/scripts/adapter-history-contiguity.d.ts +23 -6
  351. package/dist/scripts/adapter-history-contiguity.d.ts.map +1 -1
  352. package/dist/scripts/adapter-history-contiguity.js +74 -27
  353. package/dist/scripts/adapter-history-contiguity.js.map +1 -1
  354. package/dist/scripts/asset-class-totality.d.ts +29 -0
  355. package/dist/scripts/asset-class-totality.d.ts.map +1 -0
  356. package/dist/scripts/asset-class-totality.js +198 -0
  357. package/dist/scripts/asset-class-totality.js.map +1 -0
  358. package/dist/scripts/backfill-outcomes.d.ts +2 -1
  359. package/dist/scripts/backfill-outcomes.d.ts.map +1 -1
  360. package/dist/scripts/backfill-outcomes.js +13 -4
  361. package/dist/scripts/backfill-outcomes.js.map +1 -1
  362. package/dist/scripts/backfill-x402-payer-wallet.d.ts +1 -1
  363. package/dist/scripts/backfill-x402-payer-wallet.d.ts.map +1 -1
  364. package/dist/scripts/backfill-x402-payer-wallet.js +2 -1
  365. package/dist/scripts/backfill-x402-payer-wallet.js.map +1 -1
  366. package/dist/scripts/monitor.js +8 -12
  367. package/dist/scripts/monitor.js.map +1 -1
  368. package/dist/scripts/pre-trade-health.d.ts +120 -0
  369. package/dist/scripts/pre-trade-health.d.ts.map +1 -0
  370. package/dist/scripts/pre-trade-health.js +226 -0
  371. package/dist/scripts/pre-trade-health.js.map +1 -0
  372. package/dist/scripts/product-updates-digest.js +0 -2
  373. package/dist/scripts/product-updates-digest.js.map +1 -1
  374. package/dist/scripts/seed-signals.d.ts.map +1 -1
  375. package/dist/scripts/seed-signals.js +6 -0
  376. package/dist/scripts/seed-signals.js.map +1 -1
  377. package/dist/scripts/stripe-rak-smoke.d.ts +195 -0
  378. package/dist/scripts/stripe-rak-smoke.d.ts.map +1 -0
  379. package/dist/scripts/stripe-rak-smoke.js +990 -0
  380. package/dist/scripts/stripe-rak-smoke.js.map +1 -0
  381. package/dist/tool-descriptions.d.ts +23 -0
  382. package/dist/tool-descriptions.d.ts.map +1 -1
  383. package/dist/tool-descriptions.js +96 -30
  384. package/dist/tool-descriptions.js.map +1 -1
  385. package/dist/tools/get-market-regime.d.ts.map +1 -1
  386. package/dist/tools/get-market-regime.js +40 -22
  387. package/dist/tools/get-market-regime.js.map +1 -1
  388. package/dist/tools/get-trade-call.d.ts.map +1 -1
  389. package/dist/tools/get-trade-call.js +11 -9
  390. package/dist/tools/get-trade-call.js.map +1 -1
  391. package/dist/tools/knowledge-tools.d.ts.map +1 -1
  392. package/dist/tools/knowledge-tools.js +4 -1
  393. package/dist/tools/knowledge-tools.js.map +1 -1
  394. package/dist/tools/pre-trade-check.d.ts +281 -0
  395. package/dist/tools/pre-trade-check.d.ts.map +1 -0
  396. package/dist/tools/pre-trade-check.js +664 -0
  397. package/dist/tools/pre-trade-check.js.map +1 -0
  398. package/dist/tools/scan-funding-arb.d.ts.map +1 -1
  399. package/dist/tools/scan-funding-arb.js +35 -88
  400. package/dist/tools/scan-funding-arb.js.map +1 -1
  401. package/dist/tools/scan-market-regimes.d.ts +1 -1
  402. package/dist/tools/scan-trade-calls.d.ts +4 -3
  403. package/dist/tools/scan-trade-calls.d.ts.map +1 -1
  404. package/dist/tools/scan-trade-calls.js +3 -1
  405. package/dist/tools/scan-trade-calls.js.map +1 -1
  406. package/dist/types.d.ts +15 -7
  407. package/dist/types.d.ts.map +1 -1
  408. package/package.json +1 -1
  409. package/plugin.json +1 -1
  410. package/server.json +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crypto-quant-signal-mcp",
3
- "version": "1.32.0",
3
+ "version": "1.33.0",
4
4
  "description": "Composite BUY/SELL/HOLD verdicts for crypto perpetual futures — cross-venue signal interpretation, funding-rate arbitrage scanning, market-regime detection, and an on-chain-anchored track record. Built for AI agents.",
5
5
  "author": {
6
6
  "name": "AlgoVault Labs",
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
  </p>
13
13
 
14
14
  <p align="center">
15
- <span data-tr-field="pfe_wr">90.4%</span> PFE win rate across <span data-tr-field="total_calls">1,171,612</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
15
+ <span data-tr-field="pfe_wr">90.6%</span> PFE win rate across <span data-tr-field="total_calls">1,266,265</span>+ verified calls. Merkle-verified on Base L2. Don't trust — verify. <!-- SNAPSHOT-LINE -->
16
16
  </p>
17
17
 
18
18
  <p align="center">
@@ -51,6 +51,8 @@ No code. No install. No API key to start — sign in free when you need more. Th
51
51
  | Name | `Crypto Quant Signal` |
52
52
  | URL | `https://api.algovault.com/mcp` |
53
53
 
54
+ If Claude asks how to sign in, choose **Sign in when needed**. When Claude asks, click **Connect** and sign in with your email.
55
+
54
56
  ![Add Connector](https://raw.githubusercontent.com/AlgoVaultLabs/crypto-quant-signal-mcp/main/docs/screenshots/Add-Connector.png)
55
57
 
56
58
  **2. Ask for a call.** In plain language:
@@ -113,7 +115,7 @@ The `_algovault` block is the envelope every tool response carries: the server v
113
115
  scripts/snapshot-landing-data.mjs at npm-publish + Hetzner-deploy. Do NOT hand-edit the
114
116
  numbers; edit "What's new" by hand. Wired by OPS-NPM-README-SINGLE-SOT-W1 (2026-05-31). -->
115
117
  <p align="center">
116
- <strong><span data-tr-field="pfe_wr">90.4%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">1,171,612</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">197</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
118
+ <strong><span data-tr-field="pfe_wr">90.6%</span> PFE Win Rate</strong> · <strong><span data-tr-field="total_calls">1,266,265</span> trade calls</strong> · <strong><span data-tr-field="merkle_batches">206</span> on-chain batches</strong> <!-- SNAPSHOT-LINE -->
117
119
  </p>
118
120
 
119
121
  <p align="center">
@@ -192,6 +194,7 @@ The MCP tools live at `https://api.algovault.com/mcp`. Every asset works across
192
194
  - **`get_trade_call`** <sub>(alias `get_trade_signal`)</sub> — composite BUY/SELL/HOLD verdict with confidence + regime, any asset, any timeframe.
193
195
  - **`scan_trade_calls`** — scans the top-N perps by open interest on a venue; returns every actionable call in one shot.
194
196
  - **`scan_market_regimes`** — screens a whole venue by market regime in one call: every coin whose regime matches your filter, with confidence and how long the regime has held. One call per returned row (at least one per request); coins that don't match are free.
197
+ - **`pre_trade_check`** — checks an order against your own rules before you place it: each rule passes or fails with its numbers, then GO, CAUTION or WAIT, with isolated liquidation per venue against your stop. Read-only: it places no orders.
195
198
  - **`scan_funding_arb`** — cross-venue funding-rate spreads across 7 venues (Hyperliquid, Binance, Bybit, Gate, KuCoin, Aster, OKX), ranked. The only MCP server doing multi-exchange derivatives arbitrage.
196
199
  - **`get_market_regime`** — classifies TRENDING_UP / TRENDING_DOWN / RANGING / VOLATILE for strategy selection.
197
200
  - **`search_knowledge`** + **`chat_knowledge`** — free BM25 search and grounded Q&A over the full knowledge bundle.
@@ -262,7 +265,14 @@ Pro 6-month is currently $129 — limited-time pricing; subscribe now and renewa
262
265
 
263
266
  ---
264
267
 
265
- ## What's new in v1.32.0
268
+ ## What's new in v1.33.0
269
+
270
+ - **🛡️ Check an order against your own rules before you place it.** `pre_trade_check` takes the order you intend to place and your limits (maximum leverage, loss at your stop, accuracy needed to break even, funding) and returns each rule's pass or fail with its numbers, then GO, CAUTION or WAIT. It also shows where isolated liquidation sits on each venue that publishes its margin tiers, and whether it hits before your stop.
271
+ - **🔐 Sign in from inside Claude.** Add AlgoVault as a custom connector and choose Sign in when needed. When Claude asks, click Connect and sign in with your email. On a paid plan, sign in with your subscription email and your plan applies.
272
+
273
+ **Upgrading from v1.32.x** — one tool was added, `pre_trade_check`; no tool or parameter was renamed or removed. A call with an argument the tool doesn't take is now refused, unbilled, and the refusal names the valid parameters; the published schemas never allowed extra arguments. Added AlgoVault in Claude before? Remove it and add it again, choosing Sign in when needed.
274
+
275
+ ### v1.32.x highlights (recap)
266
276
 
267
277
  - **🧭 Screen a whole venue by market regime in one call.** `scan_market_regimes` returns every coin whose regime matches your filter — TRENDING_UP, TRENDING_DOWN, RANGING or VOLATILE — with confidence, trend strength, ADX, volatility ratio and how long the regime has held. Filter by regime, confidence, asset class, liquidity, regime age or your own watchlist, then sort by confidence or by the newest regime change. You pay one call per returned row (at least one per request); coins that don't match are free. A venue or timeframe it can't serve right now is refused with the alternatives, and isn't billed. The screener is served from the hosted endpoint; a local install lists it and refuses the call with a pointer there.
268
278
 
@@ -276,12 +286,6 @@ Pro 6-month is currently $129 — limited-time pricing; subscribe now and renewa
276
286
 
277
287
  **Upgrading from v1.30.x** — one value in the response envelope changed: `_algovault.compatible_with` is now `[]` and names no companion package. If your client rendered those package names, stop rendering them; there is no companion package published today. Nothing else in the envelope changed, and no tool or parameter was added, renamed or removed.
278
288
 
279
- ### v1.30.x highlights (recap)
280
-
281
- - **🔑 Your key, one click away.** Every tool response that carries an auth block now returns `claim_url` and `claim_hint` in the `_algovault` envelope — a direct link to keep the key you are already using, and a heads-up before you reach the cap.
282
- - **💵 Six-month pricing is machine-readable.** `GET /api/plans/public` gains `price_usd_6month` on every tier, so a client can render prepay pricing instead of hardcoding it.
283
- - **🤝 Enterprise is quoted, not published.** The plans endpoint now returns `null` for Enterprise price and limits rather than a fixed figure. No key was removed — the values are null.
284
-
285
289
  > **Refresh your MCP client to pick up this release.** MCP clients cache `tools/list` at session start — Claude.ai/Desktop: toggle the connector off+on; Cursor/Cline: restart the MCP server connection.
286
290
 
287
291
  ---
@@ -29,6 +29,7 @@ const facilitator_1 = require("@x402/core/facilitator");
29
29
  const evm_1 = require("@x402/evm");
30
30
  // Facilitator-side ExactEvmScheme (different from the client-side one)
31
31
  const facilitator_2 = require("@x402/evm/exact/facilitator");
32
+ const refuse_encoded_bodies_js_1 = require("./lib/refuse-encoded-bodies.js");
32
33
  const PORT = parseInt(process.env.FACILITATOR_PORT || '4022', 10);
33
34
  const PRIVATE_KEY = process.env.FACILITATOR_PRIVATE_KEY;
34
35
  if (!PRIVATE_KEY) {
@@ -62,6 +63,7 @@ facilitator.onSettleFailure(async (ctx) => {
62
63
  });
63
64
  // ── HTTP Server ──
64
65
  const app = (0, express_1.default)();
66
+ app.use((0, refuse_encoded_bodies_js_1.refuseEncodedBodiesFromEnv)()); // OPS-NODE-SECURITY-FLOOR-W1: first, before any body is read
65
67
  app.use(express_1.default.json());
66
68
  app.post('/verify', async (req, res) => {
67
69
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"facilitator.js","sourceRoot":"","sources":["../src/facilitator.ts"],"names":[],"mappings":";;;;;;AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,sDAA8B;AAC9B,+BAA+D;AAC/D,4CAAoD;AACpD,wCAAmC;AACnC,wDAAyD;AACzD,mCAAmD;AACnD,uEAAuE;AACvE,6DAA6D;AAE7D,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,MAAM,EAAE,EAAE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;IACxF,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IAClC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IAC/B,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IACpB,OAAO,CAAC,GAAG,CAAC,8CAA8C,IAAI,EAAE,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,eAAe,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
+ import { z } from 'zod';
3
4
  import type { LicenseInfo } from './types.js';
4
5
  /**
5
6
  * OPS-MCP-SESSION-RESILIENCE-W1: single shared session-correlation resolver
@@ -41,16 +42,32 @@ export declare function handleMcpStateless(req: import('express').Request, res:
41
42
  * calls it. That the route actually INVOKES it is pinned separately by a source-order assertion —
42
43
  * a pure function nobody calls is the same defect one layer up.
43
44
  *
44
- * HTTP 200 + a JSON-RPC error, never 401. A 401 with `WWW-Authenticate` starts MCP's OAuth
45
- * discovery in conformant clients, and we run no OAuth server — the client would chase a document
46
- * that does not exist and surface a worse error than the one being fixed. `index.ts:367` already
47
- * pairs a status with a JSON-RPC error body on this route. CH3's plain-REST routes keep their 401;
48
- * two surfaces, two right answers.
45
+ * HTTP 200 + a JSON-RPC error for an API key — UNKNOWN and INDETERMINATE keep their 200 shapes and
46
+ * codes. `401` ONLY for TOKEN_INVALID, and only with OAuth on (GROWTH-AGENT-SIGNIN-OAUTH-W1 R2.12,
47
+ * C13 + C14): an invalid or expired access token MUST get 401 + `WWW-Authenticate` naming our
48
+ * protected-resource metadata, so the client re-runs OAuth. TOKEN_INVALID is routed here BEFORE
49
+ * `decideRefusal`, whose JSON-RPC tables cannot represent it. With `MCP_OAUTH` off an access-shaped
50
+ * bearer is MALFORMED and served, so this branch is unreachable — the rollback lever.
49
51
  *
50
52
  * POST only. `initialize`, `tools/list` and `tools/call` are all POST, so every JSON-RPC method is
51
53
  * covered; GET/DELETE are transport-level and keep their existing 405 rather than being answered
52
54
  * with a credential verdict they never asked for.
53
55
  */
54
56
  export declare function applyCredentialRefusal(req: import('express').Request, res: import('express').Response, license: LicenseInfo): boolean;
57
+ /**
58
+ * OPS-TOOL-PARAM-TRUTH-W1 CH1 — the ONE input seam every MCP tool and alias is registered through.
59
+ *
60
+ * `.tool(name, desc, rawShape, …)` let the SDK wrap the shape in a STRIP-mode `z.object`, so an
61
+ * unknown argument key was silently dropped and the call ran — and billed — unfiltered, while
62
+ * tools/list already advertised `additionalProperties: false` and x402 / A2MCP / ACP refused the same
63
+ * key. `.strict()` refuses it inside the SDK's `validateToolInput`, before the handler runs: no quota,
64
+ * no request_log row, no settlement. Strict and strip render the same JSON Schema, so tools/list
65
+ * bytes do not move.
66
+ *
67
+ * The errorMap is also the refusal's only observation point in our code (the handler never runs),
68
+ * so it writes the detection line. zod calls a schema's errorMap exactly once per issue, and an
69
+ * object yields at most one `unrecognized_keys` issue per parse: one line per refused call.
70
+ */
71
+ export declare function strictToolInput<S extends z.ZodRawShape>(tool: string, shape: S): z.ZodObject<S, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<S>, any> extends infer T ? { [k in keyof T]: T[k]; } : never, z.baseObjectInputType<S> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1]; } : never>;
55
72
  export declare function createSandboxServer(): McpServer;
56
73
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;AAIzG,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AAkO1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAQT;AAk1JD,wBAAgB,mBAAmB,cAElC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,SAAS,EAAuC,MAAM,yCAAyC,CAAC;AAGzG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,YAAY,CAAC;AA0O1D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,OAAO,SAAS,EAAE,OAAO,EAC9B,GAAG,EAAE,OAAO,SAAS,EAAE,QAAQ,EAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAaT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,qPAU9E;AA65JD,wBAAgB,mBAAmB,cAElC"}
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.resolveSessionCorrelationId = resolveSessionCorrelationId;
41
41
  exports.handleMcpStateless = handleMcpStateless;
42
42
  exports.applyCredentialRefusal = applyCredentialRefusal;
43
+ exports.strictToolInput = strictToolInput;
43
44
  exports.createSandboxServer = createSandboxServer;
44
45
  /**
45
46
  * crypto-quant-signal-mcp — Dual transport MCP server.
@@ -58,8 +59,14 @@ const zod_1 = require("zod");
58
59
  // `credentialOutcomeOf` is the single projection every consumer reads.
59
60
  const credential_refusal_js_1 = require("./lib/credential-refusal.js");
60
61
  const credential_outcome_js_1 = require("./lib/credential-outcome.js");
62
+ // GROWTH-AGENT-SIGNIN-OAUTH-W1 CH2/CH3: the ONE OAuth mode resolver, the Bearer-challenge builder both /mcp 401s send, and the sign-in challenge seam.
63
+ const mode_js_1 = require("./lib/oauth/mode.js");
64
+ const metadata_js_1 = require("./lib/oauth/metadata.js");
65
+ const challenge_js_1 = require("./lib/oauth/challenge.js");
66
+ const routes_js_1 = require("./lib/oauth/routes.js");
61
67
  const scan_trade_calls_js_1 = require("./tools/scan-trade-calls.js");
62
68
  const scan_market_regimes_js_1 = require("./tools/scan-market-regimes.js");
69
+ const pre_trade_check_js_1 = require("./tools/pre-trade-check.js");
63
70
  const signal_performance_js_1 = require("./resources/signal-performance.js");
64
71
  // DEV-TRACK-RECORD-TOOL-PARITY-W1 CH2: the ONE public allow-list projection of the track
65
72
  // record. Consumed here by BOTH `performance://signal-performance` and
@@ -86,6 +93,7 @@ const non_public_venue_counter_js_1 = require("./lib/non-public-venue-counter.js
86
93
  const venue_brand_colors_js_1 = require("./lib/venue-brand-colors.js");
87
94
  const funding_venues_js_1 = require("./lib/funding-venues.js");
88
95
  const license_js_1 = require("./lib/license.js");
96
+ const tool_metadata_projection_js_1 = require("./lib/tool-metadata-projection.js");
89
97
  const tool_call_pipeline_js_1 = require("./lib/tool-call-pipeline.js");
90
98
  const knowledge_tools_js_1 = require("./tools/knowledge-tools.js");
91
99
  const x402_js_1 = require("./lib/x402.js");
@@ -169,11 +177,12 @@ const carry_tracker_public_js_1 = require("./lib/carry-tracker-public.js");
169
177
  const carry_tracker_page_js_1 = require("./lib/carry-tracker-page.js");
170
178
  const account_handlers_js_1 = require("./lib/account-handlers.js");
171
179
  // IDENTITY-LIFECYCLE-W3 CH1 — the lifecycle email surfaces (unsubscribe + Resend inbound).
172
- const routes_js_1 = require("./lib/lifecycle/routes.js");
180
+ const routes_js_2 = require("./lib/lifecycle/routes.js");
173
181
  const census_js_1 = require("./lib/lifecycle/census.js");
174
182
  const site_nav_js_1 = require("./lib/site-nav.js");
175
183
  const site_theme_js_1 = require("./lib/site-theme.js");
176
184
  const oi_ranking_js_1 = require("./lib/oi-ranking.js");
185
+ const refuse_encoded_bodies_js_1 = require("./lib/refuse-encoded-bodies.js");
177
186
  /** Timing-safe string comparison to prevent side-channel attacks on admin key. */
178
187
  function safeCompare(a, b) {
179
188
  if (typeof a !== 'string' || typeof b !== 'string')
@@ -247,11 +256,12 @@ async function handleMcpStateless(req, res, makeServer) {
247
256
  * calls it. That the route actually INVOKES it is pinned separately by a source-order assertion —
248
257
  * a pure function nobody calls is the same defect one layer up.
249
258
  *
250
- * HTTP 200 + a JSON-RPC error, never 401. A 401 with `WWW-Authenticate` starts MCP's OAuth
251
- * discovery in conformant clients, and we run no OAuth server — the client would chase a document
252
- * that does not exist and surface a worse error than the one being fixed. `index.ts:367` already
253
- * pairs a status with a JSON-RPC error body on this route. CH3's plain-REST routes keep their 401;
254
- * two surfaces, two right answers.
259
+ * HTTP 200 + a JSON-RPC error for an API key — UNKNOWN and INDETERMINATE keep their 200 shapes and
260
+ * codes. `401` ONLY for TOKEN_INVALID, and only with OAuth on (GROWTH-AGENT-SIGNIN-OAUTH-W1 R2.12,
261
+ * C13 + C14): an invalid or expired access token MUST get 401 + `WWW-Authenticate` naming our
262
+ * protected-resource metadata, so the client re-runs OAuth. TOKEN_INVALID is routed here BEFORE
263
+ * `decideRefusal`, whose JSON-RPC tables cannot represent it. With `MCP_OAUTH` off an access-shaped
264
+ * bearer is MALFORMED and served, so this branch is unreachable — the rollback lever.
255
265
  *
256
266
  * POST only. `initialize`, `tools/list` and `tools/call` are all POST, so every JSON-RPC method is
257
267
  * covered; GET/DELETE are transport-level and keep their existing 405 rather than being answered
@@ -261,13 +271,44 @@ function applyCredentialRefusal(req, res, license) {
261
271
  if (req.method !== 'POST')
262
272
  return false;
263
273
  const body = req.body;
264
- const decision = (0, credential_refusal_js_1.decideRefusal)({ outcome: (0, credential_outcome_js_1.credentialOutcomeOf)(license) }, body?.method);
274
+ const outcome = (0, credential_outcome_js_1.credentialOutcomeOf)(license);
275
+ if (outcome === 'TOKEN_INVALID') {
276
+ (0, metadata_js_1.sendBearerChallenge)(res, req.originalUrl, 'The access token is invalid or expired.');
277
+ return true;
278
+ }
279
+ const decision = (0, credential_refusal_js_1.decideRefusal)({ outcome }, body?.method);
265
280
  if (!decision.refuse)
266
281
  return false;
267
282
  // Echo the request id per JSON-RPC 2.0; a notification (no id) gets null.
268
283
  res.status(200).json({ jsonrpc: '2.0', id: body?.id ?? null, error: decision.error });
269
284
  return true;
270
285
  }
286
+ /**
287
+ * OPS-TOOL-PARAM-TRUTH-W1 CH1 — the ONE input seam every MCP tool and alias is registered through.
288
+ *
289
+ * `.tool(name, desc, rawShape, …)` let the SDK wrap the shape in a STRIP-mode `z.object`, so an
290
+ * unknown argument key was silently dropped and the call ran — and billed — unfiltered, while
291
+ * tools/list already advertised `additionalProperties: false` and x402 / A2MCP / ACP refused the same
292
+ * key. `.strict()` refuses it inside the SDK's `validateToolInput`, before the handler runs: no quota,
293
+ * no request_log row, no settlement. Strict and strip render the same JSON Schema, so tools/list
294
+ * bytes do not move.
295
+ *
296
+ * The errorMap is also the refusal's only observation point in our code (the handler never runs),
297
+ * so it writes the detection line. zod calls a schema's errorMap exactly once per issue, and an
298
+ * object yields at most one `unrecognized_keys` issue per parse: one line per refused call.
299
+ */
300
+ function strictToolInput(tool, shape) {
301
+ const valid = Object.keys(shape).join(', ');
302
+ return zod_1.z.object(shape, {
303
+ errorMap: (issue, ctx) => {
304
+ if (issue.code !== zod_1.z.ZodIssueCode.unrecognized_keys)
305
+ return { message: ctx.defaultError };
306
+ const keyed = (0, license_js_1.getRequestLicense)().key ? 'y' : 'n';
307
+ console.log(`[tool-args] refused tool=${tool} unknown=${issue.keys.join(',')} keyed=${keyed}`);
308
+ return { message: `Unknown parameter(s): ${issue.keys.join(', ')}. Valid parameters: ${valid}.` };
309
+ },
310
+ }).strict();
311
+ }
271
312
  function createServer() {
272
313
  const server = new mcp_js_1.McpServer({
273
314
  name: 'crypto-quant-signal-mcp',
@@ -354,6 +395,11 @@ function createServer() {
354
395
  // (runScanMarketRegimes, dispatched by the tool-call pipeline); the read engine is
355
396
  // src/lib/market-regime-scanner.ts over CH1's bar-close snapshot.
356
397
  register('scan_market_regimes', scan_market_regimes_js_1.SCAN_MARKET_REGIMES_DESCRIPTION, scan_market_regimes_js_1.SCAN_MARKET_REGIMES_SCHEMA, { title: 'Market Regime Screener', ...tool_annotations_js_1.PUBLIC_READONLY_TOOL_ANNOTATIONS }, mcpHandler('scan_market_regimes'));
398
+ // ── Tool: pre_trade_check (DECISION-CALL-V1-W2) — pre-trade check for one perp order ──
399
+ // Thin handler: refusals + quota + envelope live in src/tools/pre-trade-check.ts
400
+ // (runPreTradeCheck, dispatched by the tool-call pipeline); the engine is
401
+ // src/lib/pre-trade-decision.ts over the shared venue-market-state reads.
402
+ register('pre_trade_check', pre_trade_check_js_1.PRE_TRADE_CHECK_DESCRIPTION, pre_trade_check_js_1.PRE_TRADE_CHECK_SCHEMA, { title: 'Pre-Trade Check', ...tool_annotations_js_1.PUBLIC_READONLY_TOOL_ANNOTATIONS }, mcpHandler('pre_trade_check'));
357
403
  // ── Tool 4: search_knowledge ──
358
404
  // AV-CHAT-MCP-W1 (C2, 2026-05-18). BM25 lexical retrieval over the auto-
359
405
  // generated KnowledgeBundle (dist/knowledge/latest.json). Free, fast, no
@@ -391,11 +437,21 @@ function createServer() {
391
437
  // EQUITY-TOOLS-DARK-RETIRE-W1: iterate the ENV-GATED live set (liveMcpToolNames) — OFF
392
438
  // drops the 2 equity tools (9→7). The equity register() calls above stay (harmless,
393
439
  // just not iterated); guard B below still checks toolDefs ⊆ allToolNames (DECLARED set).
440
+ // OPS-TOOL-PARAM-TRUTH-W1 CH1: `registerTool` keeps the input schema exactly as given, so every
441
+ // name inherits `strictToolInput` here. MCP_STRICT_TOOL_ARGS is read once per server: default on;
442
+ // `0` is the rollback lever — the raw shape, which the SDK wraps in a strip-mode object exactly as
443
+ // `.tool()` did.
444
+ const strictArgs = process.env.MCP_STRICT_TOOL_ARGS !== '0';
445
+ // GROWTH-AGENT-SIGNIN-OAUTH-W4-R2 CH1: the metadata is projected through the CALLER's platform profile.
446
+ // This runs once per POST inside the request context (stateless transport), so each caller's tools/list
447
+ // is its own; the default profile is the identity, so every other client is served byte-identical text.
448
+ const profile = (0, license_js_1.requestClientProfile)();
394
449
  for (const name of (0, equity_tools_flag_js_1.liveMcpToolNames)()) {
395
450
  const d = toolDefs[name];
396
451
  if (!d)
397
452
  throw new Error(`[feature-registry] "${name}" is in FEATURE_REGISTRY but has no handler def in createServer()`);
398
- server.tool(name, d.description, d.schema, d.annotations, d.handler);
453
+ const m = (0, tool_metadata_projection_js_1.projectToolMetadata)(name, d.description, d.schema, profile);
454
+ server.registerTool(name, { description: m.description, inputSchema: strictArgs ? strictToolInput(name, m.shape) : m.shape, annotations: d.annotations }, d.handler);
399
455
  }
400
456
  for (const defName of Object.keys(toolDefs)) {
401
457
  if (!(0, feature_registry_js_1.allToolNames)().includes(defName))
@@ -644,6 +700,7 @@ async function startHttp() {
644
700
  };
645
701
  const app = express();
646
702
  app.set('trust proxy', 1); // Trust Caddy reverse proxy for req.secure, req.ip
703
+ app.use((0, refuse_encoded_bodies_js_1.refuseEncodedBodiesFromEnv)()); // OPS-NODE-SECURITY-FLOOR-W1: first, before any body is read
647
704
  const port = parseInt(process.env.PORT || '3000', 10);
648
705
  // CORS — restrict to same-origin + algovault.com
649
706
  app.use((_req, res, next) => {
@@ -989,12 +1046,12 @@ async function startHttp() {
989
1046
  // n=17. A wildcard content-type is worth having — Resend's signature is computed over the raw
990
1047
  // bytes and a type mismatch would silently hand the verifier an empty body — so the fix is the
991
1048
  // function form, not a narrower type.
992
- app.post('/webhooks/resend', express.raw({ type: () => true }), routes_js_1.resendWebhookHandler);
1049
+ app.post('/webhooks/resend', express.raw({ type: () => true }), routes_js_2.resendWebhookHandler);
993
1050
  // ── IDENTITY-LIFECYCLE-W3 CH1 — RFC 8058 one-click unsubscribe + its human page.
994
1051
  // GET renders a one-button form and MUTATES NOTHING (mail scanners follow every link in a
995
1052
  // message); POST is the one-click endpoint named by the List-Unsubscribe header.
996
- app.get('/email/unsubscribe/:token', routes_js_1.unsubscribeGetHandler);
997
- app.post('/email/unsubscribe/:token', express.urlencoded({ extended: false }), routes_js_1.unsubscribePostHandler);
1053
+ app.get('/email/unsubscribe/:token', routes_js_2.unsubscribeGetHandler);
1054
+ app.post('/email/unsubscribe/:token', express.urlencoded({ extended: false }), routes_js_2.unsubscribePostHandler);
998
1055
  // ── Stripe Webhook (raw body required — must be before express.json()) ──
999
1056
  app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
1000
1057
  const sig = req.headers['stripe-signature'];
@@ -1947,7 +2004,8 @@ async function startHttp() {
1947
2004
  return res.status(401).json({ error: 'Unauthorized' });
1948
2005
  }
1949
2006
  try {
1950
- const [stats, holdStats] = await Promise.all([(0, signal_performance_js_1.getSignalPerformance)(), (0, performance_db_js_1.getHoldStats)()]);
2007
+ const stats = await (0, signal_performance_js_1.getSignalPerformance)();
2008
+ const holdStats = await (0, performance_db_js_1.getHoldStats)(stats.byAsset); // holds take the coin's headline tier
1951
2009
  res.json({ ...stats, ...holdStats });
1952
2010
  }
1953
2011
  catch (err) {
@@ -2412,9 +2470,11 @@ async function startHttp() {
2412
2470
  // timeframe_count) — read by landing/js/track-record-proxy.js to populate
2413
2471
  // every `data-tr-field="<name>"` span on track-record / signup / docs /
2414
2472
  // landing pages, so onboarding the 6th exchange auto-updates public copy.
2473
+ // OPS-ASSET-CLASS-TOTALITY-W1 Q1: holds take each coin's headline tier from the SAME rollup.
2474
+ const statsP = (0, signal_performance_js_1.getSignalPerformance)();
2415
2475
  const [stats, holdStats, asset_count] = await Promise.all([
2416
- (0, signal_performance_js_1.getSignalPerformance)(),
2417
- (0, performance_db_js_1.getHoldStats)(),
2476
+ statsP,
2477
+ statsP.then((s) => (0, performance_db_js_1.getHoldStats)(s.byAsset)),
2418
2478
  (0, capabilities_js_1.getAssetCount)(),
2419
2479
  ]);
2420
2480
  const totalHolds = holdStats.totalHolds || 0;
@@ -2845,10 +2905,10 @@ async function startHttp() {
2845
2905
  // the request. Public-shape: see audits/signup-email-shape-snapshot-2026-06-21.json
2846
2906
  // CALL-REGIME-WEBHOOK-LAYER-W1 (2026-05-29): outbound webhook subscription API
2847
2907
  // (POST/GET/DELETE /api/webhooks + POST /api/webhooks/:id/test). Universal
2848
- // access gated only by the monthly call quota; ships dark — the delivery worker
2849
- // only runs when WEBHOOK_DELIVERY_ENABLED=true (registration routes are always
2850
- // mounted so subscribers can pre-register, but nothing is delivered until the
2851
- // flag is on).
2908
+ // access gated only by the monthly call quota. The routes are always mounted.
2909
+ // The background delivery worker runs only when WEBHOOK_DELIVERY_ENABLED=true
2910
+ // (it is true in production). POST /api/webhooks/:id/test delivers immediately,
2911
+ // whatever the flag says.
2852
2912
  (0, webhook_api_js_1.registerWebhookRoutes)(app);
2853
2913
  // REFERRAL-LIGHT-W1 (C3): per-IP limiter on the public opt-in (mirrors recoverKeyLimiter).
2854
2914
  const signupEmailLimiter = rateLimit({
@@ -3110,6 +3170,24 @@ async function startHttp() {
3110
3170
  const { ensureUserCode } = await import('./lib/referral-store.js');
3111
3171
  const { shareLink } = await import('./lib/referral-constants.js');
3112
3172
  const identity = await resolveSigninIdentity(profile.email);
3173
+ // GROWTH-AGENT-SIGNIN-OAUTH-W1 R2.7: a live `av_mcp_authz` pending row means this sign-in
3174
+ // started at an MCP client's /authorize — bind the identity and continue to consent (or hand
3175
+ // the client `temporarily_unavailable` on INDETERMINATE). No cookie, an expired row, a store
3176
+ // fault or MCP_OAUTH off → false, and everything below renders today's page unchanged.
3177
+ if ((0, mode_js_1.resolveOAuthMode)() !== 'off') {
3178
+ const handled = await (0, routes_js_1.oauthCallbackBranch)(req, res, {
3179
+ identity,
3180
+ email: profile.email,
3181
+ via: id,
3182
+ clearCookies: [
3183
+ 'av_oauth_state=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
3184
+ 'av_oauth_next=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
3185
+ 'av_oauth_src=; HttpOnly; SameSite=Lax; Path=/auth; Max-Age=0',
3186
+ ],
3187
+ });
3188
+ if (handled)
3189
+ return;
3190
+ }
3113
3191
  // Stripe is configured and did not answer. Minting here is exactly how a paying human
3114
3192
  // acquires a shadow free identity, so mint nothing and send them to the page that can
3115
3193
  // resolve them once Stripe is back. REFUSE, never throw — this is a live serving path.
@@ -3355,6 +3433,13 @@ async function startHttp() {
3355
3433
  // route. Public data only (allow-list formatter in lib/plans-public-api.ts); no DB touch.
3356
3434
  (0, plans_public_api_js_1.registerPlansPublicRoutes)(app);
3357
3435
  // MCP endpoint
3436
+ // GROWTH-AGENT-SIGNIN-OAUTH-W1 R2.1: the authorization server mounts only when MCP_OAUTH is
3437
+ // optin|wall. Off (unset) prints the boot line and mounts nothing — all nine paths keep the 404.
3438
+ const oauthMode = (0, mode_js_1.resolveOAuthMode)();
3439
+ if (oauthMode === 'off')
3440
+ console.log('[oauth] mode=off');
3441
+ else
3442
+ await (0, routes_js_1.mountOAuth)(app, oauthMode);
3358
3443
  app.all('/mcp', express.json(), async (req, res) => {
3359
3444
  // OPS-X402-MCP-PRICE-BINDING-W1: for a priced `tools/call` POST, bind the x402
3360
3445
  // grant/settle to the CALLED tool's effective price. Parse the tool name (+ its
@@ -3375,9 +3460,10 @@ async function startHttp() {
3375
3460
  : undefined;
3376
3461
  // Resolve license per-request using 3-tier gate: x402 → API key → free
3377
3462
  // Async because x402 verification hits the Facilitator
3463
+ // `oauth: true` is passed ONLY here: an OAuth access token resolves on /mcp and nowhere else.
3378
3464
  const { license, pendingSettlement, x402Downgrade } = isPricedTool
3379
- ? await (0, license_js_1.resolveLicense)(req.headers, { tool: callTool, timeframe: callTimeframe })
3380
- : await (0, license_js_1.resolveLicense)(req.headers);
3465
+ ? await (0, license_js_1.resolveLicense)(req.headers, { tool: callTool, timeframe: callTimeframe, oauth: true })
3466
+ : await (0, license_js_1.resolveLicense)(req.headers, { oauth: true });
3381
3467
  // AUTH-THREE-STATE-W1 CH2 — THE CREDENTIAL GATE, AND ITS POSITION IS THE CONTRACT.
3382
3468
  //
3383
3469
  // It runs on the very next line after the license is resolved, which puts it BEFORE the skill
@@ -3392,22 +3478,6 @@ async function startHttp() {
3392
3478
  // a source-order test rather than left to review.
3393
3479
  if (applyCredentialRefusal(req, res, license))
3394
3480
  return;
3395
- // DOCS-SUPPORT-ANSWERS-AND-PUBLIC-VENUE-SCOPE-W1 CH1 — measure the narrow we just shipped.
3396
- //
3397
- // Narrowing the public `exchange` enum 17 -> 15 breaks any caller passing EDGEX/WEEX, and
3398
- // `request_log` has no `exchange` column, so we could not count them. This is the ONLY seam
3399
- // that sees the value: Zod validation runs inside the SDK's tool wrapper, so the tool handler
3400
- // never executes on a rejected call and cannot report it. The request body is already parsed
3401
- // here (`mcpBody`, for the x402 price binding above), so this reads it and adds no work.
3402
- //
3403
- // Position is deliberate: BELOW the credential gate, so a refused caller is not counted —
3404
- // consistent with 'a refusal claims nothing'. Observation only; it never blocks, and the SDK
3405
- // still owns the actual rejection.
3406
- if (callTool) {
3407
- const venueArg = mcpBody?.params?.arguments?.exchange;
3408
- if (typeof venueArg === 'string')
3409
- (0, non_public_venue_counter_js_1.recordNonPublicVenue)(venueArg, callTool, license.tier);
3410
- }
3411
3481
  // Hash client IP for privacy-safe analytics + the free-tier quota key.
3412
3482
  // OPS-MCP-DEFENSE-IN-DEPTH-W1 R2: req.ip (trust proxy=1) via the shared clientIp
3413
3483
  // helper — the raw leftmost-XFF parse was spoofable the moment a proxy hop
@@ -3432,6 +3502,28 @@ async function startHttp() {
3432
3502
  // (MCP_STATELESS=0) the POST-layer funnel emits don't meaningfully join, so a
3433
3503
  // default 'anon' label is harmless (only read when sessionId is set + stateless).
3434
3504
  const identityTier = sessionIdentity?.tier ?? 'anon';
3505
+ // GROWTH-AGENT-SIGNIN-OAUTH-W1 CH3 — THE SIGN-IN CHALLENGE, directly below the credential gate
3506
+ // and for the same reason: above every emit and every charge, so a challenged call consumes
3507
+ // NOTHING. `ipHash` / `sessionId` are hoisted above it (pure derivations, no writes) because the
3508
+ // wall's quota peek must key the caller's real free bucket. Off (`MCP_OAUTH` unset) never answers.
3509
+ if (await (0, challenge_js_1.applyChallenge)(req, res, license, x402Downgrade, { ipHash, sessionId }))
3510
+ return;
3511
+ // DOCS-SUPPORT-ANSWERS-AND-PUBLIC-VENUE-SCOPE-W1 CH1 — measure the narrow we just shipped.
3512
+ //
3513
+ // Narrowing the public `exchange` enum 17 -> 15 breaks any caller passing EDGEX/WEEX, and
3514
+ // `request_log` has no `exchange` column, so we could not count them. This is the ONLY seam
3515
+ // that sees the value: Zod validation runs inside the SDK's tool wrapper, so the tool handler
3516
+ // never executes on a rejected call and cannot report it. The request body is already parsed
3517
+ // here (`mcpBody`, for the x402 price binding above), so this reads it and adds no work.
3518
+ //
3519
+ // Position is deliberate: BELOW the credential gate, so a refused caller is not counted —
3520
+ // consistent with 'a refusal claims nothing'. Observation only; it never blocks, and the SDK
3521
+ // still owns the actual rejection.
3522
+ if (callTool) {
3523
+ const venueArg = mcpBody?.params?.arguments?.exchange;
3524
+ if (typeof venueArg === 'string')
3525
+ (0, non_public_venue_counter_js_1.recordNonPublicVenue)(venueArg, callTool, license.tier);
3526
+ }
3435
3527
  // OPS-ANALYTICS-GENUINE-VS-AUTOMATED-SPLIT-W1: classify THIS request ONCE
3436
3528
  // (single-derivation — the ONE authoritative automated-vs-human verdict). Pure fn
3437
3529
  // of (UA, IP, tier, is-this-a-real-call). Stored in the requestContext ALS below so
@@ -3569,7 +3661,8 @@ async function startHttp() {
3569
3661
  req.body &&
3570
3662
  typeof req.body === 'object' &&
3571
3663
  req.body.method === 'tools/list') {
3572
- (0, tools_list_event_js_1.recordMcpToolsListEvent)({ sessionId, licenseTier: license.tier, identityTier });
3664
+ // GROWTH-AGENT-SIGNIN-OAUTH-W4-R2 CH1: + the UA, so a directory scanner's family is measurable.
3665
+ (0, tools_list_event_js_1.recordMcpToolsListEvent)({ sessionId, licenseTier: license.tier, identityTier, userAgent: req.headers['user-agent'] ?? null });
3573
3666
  }
3574
3667
  // FUNNEL-FIX-ATTRIBUTION-W1: resolve the classified acquisition source ONCE here (request
3575
3668
  // headers in scope) and thread it via the ALS to the agent_sessions first-touch stamp.
@@ -3585,13 +3678,16 @@ async function startHttp() {
3585
3678
  // headers and the resolved tier are both in scope (same single-derivation pattern as
3586
3679
  // isAutomated / source above). Internal callers only — see resolveBackgroundPriority.
3587
3680
  const backgroundPriority = (0, license_js_1.resolveBackgroundPriority)(req.headers, license.tier);
3681
+ // DECISION-CALL-V2-PAYER-REF-W1: the x402 payer, resolved ONCE here from the settlement resolveLicense
3682
+ // returned (none on a downgraded proof), for the pre_trade_check log's caller_ref.
3683
+ const payerWallet = (0, license_js_1.resolvePayerWallet)(pendingSettlement);
3588
3684
  // Run the entire request handling inside AsyncLocalStorage context
3589
3685
  // so tool handlers read the correct per-request license
3590
3686
  // OPS-CLIENT-ATTRIBUTION-W1: thread the raw UA — the SAME string classifyTraffic just
3591
3687
  // consumed for `requestAuthenticity` — so logRequest stamps user_agent + client_name from
3592
3688
  // one value. Previously the UA was read here and discarded, leaving a heavy caller
3593
3689
  // classifiable but unnameable (30 candidate hashes missed in OPS-TOP-IP-FORENSICS-W1).
3594
- await license_js_1.requestContext.run({ license, sessionId, ipHash, isAutomated: requestAuthenticity.is_automated, userAgent: req.headers['user-agent'] ?? null, source: attributionSource, background: backgroundPriority }, async () => {
3690
+ await license_js_1.requestContext.run({ license, sessionId, ipHash, isAutomated: requestAuthenticity.is_automated, userAgent: req.headers['user-agent'] ?? null, source: attributionSource, background: backgroundPriority, payerWallet }, async () => {
3595
3691
  try {
3596
3692
  const sessionId = req.headers['mcp-session-id'];
3597
3693
  // OPS-X402-MCP-PRICE-BINDING-W1: an x402 proof was presented for a priced
@@ -3687,18 +3783,31 @@ async function startHttp() {
3687
3783
  res.status(500).json({ error: 'Internal server error' });
3688
3784
  }
3689
3785
  }
3690
- // Fire-and-forget: settle the x402 payment after the response is sent.
3786
+ // Fire-and-forget, after the response: the x402 settle DECISION. (DECISION-CALL-V1-W3)
3787
+ //
3788
+ // THE RULE: only a SERVED call settles. `callTool` stamped how the call ended on this request's
3789
+ // context; `x402SettlementAction` settles 'ok' and nothing else. A refusal, a throw, or no stamp
3790
+ // at all (the SDK rejected the call before any tool ran, or the transport threw) is UNSERVED: the
3791
+ // claim moves CLAIMED_PENDING → CLAIMED_UNSERVED and the buyer's authorization is never submitted.
3691
3792
  //
3692
- // PRICING-FLAT-CALL-BILLING-AND-6MONTH-W1 (R-A): the `getRequestVerdict() !== 'HOLD'`
3693
- // guard is GONE. It meant the per-call rail was paid only when the model said "trade",
3694
- // which is a structural incentive against the selectivity that IS the product — the
3695
- // published hold rate is ~99%, so the rail was collecting on roughly 1 call in 100 while
3696
- // serving all of them. A verdict is the product on every rail; HOLD is a verdict.
3793
+ // HOLD is served. PRICING-FLAT-CALL-BILLING-AND-6MONTH-W1 (R-A) removed the
3794
+ // `getRequestVerdict() !== 'HOLD'` guard because a verdict is the product on every rail, and
3795
+ // that stands: a HOLD stamps 'ok'.
3697
3796
  //
3698
- // An ERROR still never settles, and that is unchanged: this line only runs after a
3699
- // successful response, and every failure path above returns before reaching it.
3797
+ // _(Corrected DECISION-CALL-V1-W3: this said "an ERROR never settles … every failure path above
3798
+ // returns before reaching it". Two paths did not. The `catch` above falls through to here, so a
3799
+ // transport throw settled; and an in-band tool refusal is an ordinary JSON-RPC result, so a
3800
+ // refused paid call settled too. The decision now keys on what the tool did, not on the
3801
+ // transport having returned.)_
3700
3802
  if (pendingSettlement) {
3701
- (0, x402_js_1.settleX402Async)(pendingSettlement);
3803
+ const outcome = (0, license_js_1.getRequestToolOutcome)();
3804
+ if ((0, x402_js_1.x402SettlementAction)(outcome) === 'settle') {
3805
+ (0, x402_js_1.settleX402Async)(pendingSettlement);
3806
+ }
3807
+ else {
3808
+ (0, x402_js_1.markX402Unserved)(pendingSettlement);
3809
+ console.log(`[x402-mcp] unserved ${callTool ?? 'request'} (outcome=${outcome ?? 'none'}) — payment not settled`);
3810
+ }
3702
3811
  }
3703
3812
  });
3704
3813
  });