@skillsmith/mcp-server 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/package.json +1 -1
  2. package/dist/.tsbuildinfo +0 -1
  3. package/dist/src/__tests__/get-skill.test.d.ts +0 -6
  4. package/dist/src/__tests__/get-skill.test.d.ts.map +0 -1
  5. package/dist/src/__tests__/get-skill.test.js +0 -88
  6. package/dist/src/__tests__/get-skill.test.js.map +0 -1
  7. package/dist/src/__tests__/middleware/errorFormatter.test.d.ts +0 -7
  8. package/dist/src/__tests__/middleware/errorFormatter.test.d.ts.map +0 -1
  9. package/dist/src/__tests__/middleware/errorFormatter.test.js +0 -304
  10. package/dist/src/__tests__/middleware/errorFormatter.test.js.map +0 -1
  11. package/dist/src/__tests__/middleware/license.test.d.ts +0 -7
  12. package/dist/src/__tests__/middleware/license.test.d.ts.map +0 -1
  13. package/dist/src/__tests__/middleware/license.test.js +0 -500
  14. package/dist/src/__tests__/middleware/license.test.js.map +0 -1
  15. package/dist/src/__tests__/search.test.d.ts +0 -6
  16. package/dist/src/__tests__/search.test.d.ts.map +0 -1
  17. package/dist/src/__tests__/search.test.js +0 -86
  18. package/dist/src/__tests__/search.test.js.map +0 -1
  19. package/dist/src/__tests__/test-utils.d.ts +0 -20
  20. package/dist/src/__tests__/test-utils.d.ts.map +0 -1
  21. package/dist/src/__tests__/test-utils.js +0 -91
  22. package/dist/src/__tests__/test-utils.js.map +0 -1
  23. package/dist/src/context/index.d.ts +0 -19
  24. package/dist/src/context/index.d.ts.map +0 -1
  25. package/dist/src/context/index.js +0 -25
  26. package/dist/src/context/index.js.map +0 -1
  27. package/dist/src/context/project-detector.d.ts +0 -145
  28. package/dist/src/context/project-detector.d.ts.map +0 -1
  29. package/dist/src/context/project-detector.js +0 -321
  30. package/dist/src/context/project-detector.js.map +0 -1
  31. package/dist/src/context.d.ts +0 -157
  32. package/dist/src/context.d.ts.map +0 -1
  33. package/dist/src/context.js +0 -231
  34. package/dist/src/context.js.map +0 -1
  35. package/dist/src/core-shim.d.ts +0 -7
  36. package/dist/src/core-shim.d.ts.map +0 -1
  37. package/dist/src/core-shim.js +0 -9
  38. package/dist/src/core-shim.js.map +0 -1
  39. package/dist/src/health/healthCheck.d.ts +0 -88
  40. package/dist/src/health/healthCheck.d.ts.map +0 -1
  41. package/dist/src/health/healthCheck.js +0 -117
  42. package/dist/src/health/healthCheck.js.map +0 -1
  43. package/dist/src/health/index.d.ts +0 -21
  44. package/dist/src/health/index.d.ts.map +0 -1
  45. package/dist/src/health/index.js +0 -21
  46. package/dist/src/health/index.js.map +0 -1
  47. package/dist/src/health/readinessCheck.d.ts +0 -139
  48. package/dist/src/health/readinessCheck.d.ts.map +0 -1
  49. package/dist/src/health/readinessCheck.js +0 -266
  50. package/dist/src/health/readinessCheck.js.map +0 -1
  51. package/dist/src/index.d.ts +0 -9
  52. package/dist/src/index.d.ts.map +0 -1
  53. package/dist/src/index.js +0 -236
  54. package/dist/src/index.js.map +0 -1
  55. package/dist/src/index.test.d.ts +0 -2
  56. package/dist/src/index.test.d.ts.map +0 -1
  57. package/dist/src/index.test.js +0 -43
  58. package/dist/src/index.test.js.map +0 -1
  59. package/dist/src/logger.d.ts +0 -26
  60. package/dist/src/logger.d.ts.map +0 -1
  61. package/dist/src/logger.js +0 -179
  62. package/dist/src/logger.js.map +0 -1
  63. package/dist/src/middleware/__tests__/csp.test.d.ts +0 -2
  64. package/dist/src/middleware/__tests__/csp.test.d.ts.map +0 -1
  65. package/dist/src/middleware/__tests__/csp.test.js +0 -390
  66. package/dist/src/middleware/__tests__/csp.test.js.map +0 -1
  67. package/dist/src/middleware/csp.d.ts +0 -103
  68. package/dist/src/middleware/csp.d.ts.map +0 -1
  69. package/dist/src/middleware/csp.js +0 -273
  70. package/dist/src/middleware/csp.js.map +0 -1
  71. package/dist/src/middleware/degradation.d.ts +0 -105
  72. package/dist/src/middleware/degradation.d.ts.map +0 -1
  73. package/dist/src/middleware/degradation.js +0 -319
  74. package/dist/src/middleware/degradation.js.map +0 -1
  75. package/dist/src/middleware/errorFormatter.d.ts +0 -119
  76. package/dist/src/middleware/errorFormatter.d.ts.map +0 -1
  77. package/dist/src/middleware/errorFormatter.js +0 -294
  78. package/dist/src/middleware/errorFormatter.js.map +0 -1
  79. package/dist/src/middleware/index.d.ts +0 -11
  80. package/dist/src/middleware/index.d.ts.map +0 -1
  81. package/dist/src/middleware/index.js +0 -16
  82. package/dist/src/middleware/index.js.map +0 -1
  83. package/dist/src/middleware/license.d.ts +0 -169
  84. package/dist/src/middleware/license.d.ts.map +0 -1
  85. package/dist/src/middleware/license.js +0 -292
  86. package/dist/src/middleware/license.js.map +0 -1
  87. package/dist/src/middleware/quota.d.ts +0 -182
  88. package/dist/src/middleware/quota.d.ts.map +0 -1
  89. package/dist/src/middleware/quota.js +0 -309
  90. package/dist/src/middleware/quota.js.map +0 -1
  91. package/dist/src/middleware/toolFeatureMapping.d.ts +0 -36
  92. package/dist/src/middleware/toolFeatureMapping.d.ts.map +0 -1
  93. package/dist/src/middleware/toolFeatureMapping.js +0 -96
  94. package/dist/src/middleware/toolFeatureMapping.js.map +0 -1
  95. package/dist/src/onboarding/first-run.d.ts +0 -65
  96. package/dist/src/onboarding/first-run.d.ts.map +0 -1
  97. package/dist/src/onboarding/first-run.js +0 -79
  98. package/dist/src/onboarding/first-run.js.map +0 -1
  99. package/dist/src/onboarding/index.d.ts +0 -7
  100. package/dist/src/onboarding/index.d.ts.map +0 -1
  101. package/dist/src/onboarding/index.js +0 -7
  102. package/dist/src/onboarding/index.js.map +0 -1
  103. package/dist/src/onboarding/install-assets.d.ts +0 -27
  104. package/dist/src/onboarding/install-assets.d.ts.map +0 -1
  105. package/dist/src/onboarding/install-assets.js +0 -128
  106. package/dist/src/onboarding/install-assets.js.map +0 -1
  107. package/dist/src/suggestions/index.d.ts +0 -21
  108. package/dist/src/suggestions/index.d.ts.map +0 -1
  109. package/dist/src/suggestions/index.js +0 -20
  110. package/dist/src/suggestions/index.js.map +0 -1
  111. package/dist/src/suggestions/suggestion-engine.d.ts +0 -185
  112. package/dist/src/suggestions/suggestion-engine.d.ts.map +0 -1
  113. package/dist/src/suggestions/suggestion-engine.js +0 -352
  114. package/dist/src/suggestions/suggestion-engine.js.map +0 -1
  115. package/dist/src/suggestions/types.d.ts +0 -88
  116. package/dist/src/suggestions/types.d.ts.map +0 -1
  117. package/dist/src/suggestions/types.js +0 -21
  118. package/dist/src/suggestions/types.js.map +0 -1
  119. package/dist/src/tools/analyze.d.ts +0 -151
  120. package/dist/src/tools/analyze.d.ts.map +0 -1
  121. package/dist/src/tools/analyze.js +0 -205
  122. package/dist/src/tools/analyze.js.map +0 -1
  123. package/dist/src/tools/compare.d.ts +0 -149
  124. package/dist/src/tools/compare.d.ts.map +0 -1
  125. package/dist/src/tools/compare.js +0 -464
  126. package/dist/src/tools/compare.js.map +0 -1
  127. package/dist/src/tools/get-skill.d.ts +0 -107
  128. package/dist/src/tools/get-skill.d.ts.map +0 -1
  129. package/dist/src/tools/get-skill.js +0 -260
  130. package/dist/src/tools/get-skill.js.map +0 -1
  131. package/dist/src/tools/index.d.ts +0 -20
  132. package/dist/src/tools/index.d.ts.map +0 -1
  133. package/dist/src/tools/index.js +0 -20
  134. package/dist/src/tools/index.js.map +0 -1
  135. package/dist/src/tools/install.d.ts +0 -122
  136. package/dist/src/tools/install.d.ts.map +0 -1
  137. package/dist/src/tools/install.js +0 -326
  138. package/dist/src/tools/install.js.map +0 -1
  139. package/dist/src/tools/recommend.d.ts +0 -169
  140. package/dist/src/tools/recommend.d.ts.map +0 -1
  141. package/dist/src/tools/recommend.js +0 -357
  142. package/dist/src/tools/recommend.js.map +0 -1
  143. package/dist/src/tools/search.d.ts +0 -114
  144. package/dist/src/tools/search.d.ts.map +0 -1
  145. package/dist/src/tools/search.js +0 -247
  146. package/dist/src/tools/search.js.map +0 -1
  147. package/dist/src/tools/suggest.d.ts +0 -181
  148. package/dist/src/tools/suggest.d.ts.map +0 -1
  149. package/dist/src/tools/suggest.js +0 -310
  150. package/dist/src/tools/suggest.js.map +0 -1
  151. package/dist/src/tools/uninstall.d.ts +0 -123
  152. package/dist/src/tools/uninstall.d.ts.map +0 -1
  153. package/dist/src/tools/uninstall.js +0 -250
  154. package/dist/src/tools/uninstall.js.map +0 -1
  155. package/dist/src/tools/validate.d.ts +0 -122
  156. package/dist/src/tools/validate.d.ts.map +0 -1
  157. package/dist/src/tools/validate.js +0 -497
  158. package/dist/src/tools/validate.js.map +0 -1
  159. package/dist/src/utils/installed-skills.d.ts +0 -101
  160. package/dist/src/utils/installed-skills.d.ts.map +0 -1
  161. package/dist/src/utils/installed-skills.js +0 -220
  162. package/dist/src/utils/installed-skills.js.map +0 -1
  163. package/dist/src/utils/validation.d.ts +0 -95
  164. package/dist/src/utils/validation.d.ts.map +0 -1
  165. package/dist/src/utils/validation.js +0 -186
  166. package/dist/src/utils/validation.js.map +0 -1
  167. package/dist/src/webhooks/index.d.ts +0 -8
  168. package/dist/src/webhooks/index.d.ts.map +0 -1
  169. package/dist/src/webhooks/index.js +0 -9
  170. package/dist/src/webhooks/index.js.map +0 -1
  171. package/dist/src/webhooks/webhook-endpoint.d.ts +0 -149
  172. package/dist/src/webhooks/webhook-endpoint.d.ts.map +0 -1
  173. package/dist/src/webhooks/webhook-endpoint.js +0 -339
  174. package/dist/src/webhooks/webhook-endpoint.js.map +0 -1
  175. package/dist/tests/compare.test.d.ts +0 -6
  176. package/dist/tests/compare.test.d.ts.map +0 -1
  177. package/dist/tests/compare.test.js +0 -225
  178. package/dist/tests/compare.test.js.map +0 -1
  179. package/dist/tests/context/project-detector.test.d.ts +0 -6
  180. package/dist/tests/context/project-detector.test.d.ts.map +0 -1
  181. package/dist/tests/context/project-detector.test.js +0 -719
  182. package/dist/tests/context/project-detector.test.js.map +0 -1
  183. package/dist/tests/e2e/compare.e2e.test.d.ts +0 -10
  184. package/dist/tests/e2e/compare.e2e.test.d.ts.map +0 -1
  185. package/dist/tests/e2e/compare.e2e.test.js +0 -296
  186. package/dist/tests/e2e/compare.e2e.test.js.map +0 -1
  187. package/dist/tests/e2e/install-flow.e2e.test.d.ts +0 -10
  188. package/dist/tests/e2e/install-flow.e2e.test.d.ts.map +0 -1
  189. package/dist/tests/e2e/install-flow.e2e.test.js +0 -229
  190. package/dist/tests/e2e/install-flow.e2e.test.js.map +0 -1
  191. package/dist/tests/e2e/recommend.e2e.test.d.ts +0 -12
  192. package/dist/tests/e2e/recommend.e2e.test.d.ts.map +0 -1
  193. package/dist/tests/e2e/recommend.e2e.test.js +0 -357
  194. package/dist/tests/e2e/recommend.e2e.test.js.map +0 -1
  195. package/dist/tests/e2e/skill-flow.e2e.test.d.ts +0 -10
  196. package/dist/tests/e2e/skill-flow.e2e.test.d.ts.map +0 -1
  197. package/dist/tests/e2e/skill-flow.e2e.test.js +0 -311
  198. package/dist/tests/e2e/skill-flow.e2e.test.js.map +0 -1
  199. package/dist/tests/e2e/suggest.e2e.test.d.ts +0 -13
  200. package/dist/tests/e2e/suggest.e2e.test.d.ts.map +0 -1
  201. package/dist/tests/e2e/suggest.e2e.test.js +0 -367
  202. package/dist/tests/e2e/suggest.e2e.test.js.map +0 -1
  203. package/dist/tests/e2e/utils/baseline-collector.d.ts +0 -107
  204. package/dist/tests/e2e/utils/baseline-collector.d.ts.map +0 -1
  205. package/dist/tests/e2e/utils/baseline-collector.js +0 -211
  206. package/dist/tests/e2e/utils/baseline-collector.js.map +0 -1
  207. package/dist/tests/e2e/utils/hardcoded-detector.d.ts +0 -46
  208. package/dist/tests/e2e/utils/hardcoded-detector.d.ts.map +0 -1
  209. package/dist/tests/e2e/utils/hardcoded-detector.js +0 -255
  210. package/dist/tests/e2e/utils/hardcoded-detector.js.map +0 -1
  211. package/dist/tests/e2e/utils/index.d.ts +0 -7
  212. package/dist/tests/e2e/utils/index.d.ts.map +0 -1
  213. package/dist/tests/e2e/utils/index.js +0 -7
  214. package/dist/tests/e2e/utils/index.js.map +0 -1
  215. package/dist/tests/e2e/utils/linear-reporter.d.ts +0 -60
  216. package/dist/tests/e2e/utils/linear-reporter.d.ts.map +0 -1
  217. package/dist/tests/e2e/utils/linear-reporter.js +0 -232
  218. package/dist/tests/e2e/utils/linear-reporter.js.map +0 -1
  219. package/dist/tests/health.test.d.ts +0 -9
  220. package/dist/tests/health.test.d.ts.map +0 -1
  221. package/dist/tests/health.test.js +0 -308
  222. package/dist/tests/health.test.js.map +0 -1
  223. package/dist/tests/integration/analyze.integration.test.d.ts +0 -2
  224. package/dist/tests/integration/analyze.integration.test.d.ts.map +0 -1
  225. package/dist/tests/integration/analyze.integration.test.js +0 -244
  226. package/dist/tests/integration/analyze.integration.test.js.map +0 -1
  227. package/dist/tests/integration/compare.integration.test.d.ts +0 -2
  228. package/dist/tests/integration/compare.integration.test.d.ts.map +0 -1
  229. package/dist/tests/integration/compare.integration.test.js +0 -120
  230. package/dist/tests/integration/compare.integration.test.js.map +0 -1
  231. package/dist/tests/integration/fixtures/test-skills.d.ts +0 -62
  232. package/dist/tests/integration/fixtures/test-skills.d.ts.map +0 -1
  233. package/dist/tests/integration/fixtures/test-skills.js +0 -644
  234. package/dist/tests/integration/fixtures/test-skills.js.map +0 -1
  235. package/dist/tests/integration/get-skill.integration.test.d.ts +0 -6
  236. package/dist/tests/integration/get-skill.integration.test.d.ts.map +0 -1
  237. package/dist/tests/integration/get-skill.integration.test.js +0 -203
  238. package/dist/tests/integration/get-skill.integration.test.js.map +0 -1
  239. package/dist/tests/integration/github-api.integration.test.d.ts +0 -14
  240. package/dist/tests/integration/github-api.integration.test.d.ts.map +0 -1
  241. package/dist/tests/integration/github-api.integration.test.js +0 -190
  242. package/dist/tests/integration/github-api.integration.test.js.map +0 -1
  243. package/dist/tests/integration/install.integration.test.d.ts +0 -6
  244. package/dist/tests/integration/install.integration.test.d.ts.map +0 -1
  245. package/dist/tests/integration/install.integration.test.js +0 -282
  246. package/dist/tests/integration/install.integration.test.js.map +0 -1
  247. package/dist/tests/integration/recommend.integration.test.d.ts +0 -2
  248. package/dist/tests/integration/recommend.integration.test.d.ts.map +0 -1
  249. package/dist/tests/integration/recommend.integration.test.js +0 -217
  250. package/dist/tests/integration/recommend.integration.test.js.map +0 -1
  251. package/dist/tests/integration/search.integration.test.d.ts +0 -6
  252. package/dist/tests/integration/search.integration.test.d.ts.map +0 -1
  253. package/dist/tests/integration/search.integration.test.js +0 -229
  254. package/dist/tests/integration/search.integration.test.js.map +0 -1
  255. package/dist/tests/integration/setup.d.ts +0 -74
  256. package/dist/tests/integration/setup.d.ts.map +0 -1
  257. package/dist/tests/integration/setup.js +0 -131
  258. package/dist/tests/integration/setup.js.map +0 -1
  259. package/dist/tests/integration/uninstall.integration.test.d.ts +0 -6
  260. package/dist/tests/integration/uninstall.integration.test.d.ts.map +0 -1
  261. package/dist/tests/integration/uninstall.integration.test.js +0 -296
  262. package/dist/tests/integration/uninstall.integration.test.js.map +0 -1
  263. package/dist/tests/integration/validate.integration.test.d.ts +0 -2
  264. package/dist/tests/integration/validate.integration.test.d.ts.map +0 -1
  265. package/dist/tests/integration/validate.integration.test.js +0 -181
  266. package/dist/tests/integration/validate.integration.test.js.map +0 -1
  267. package/dist/tests/onboarding/first-run.test.d.ts +0 -7
  268. package/dist/tests/onboarding/first-run.test.d.ts.map +0 -1
  269. package/dist/tests/onboarding/first-run.test.js +0 -264
  270. package/dist/tests/onboarding/first-run.test.js.map +0 -1
  271. package/dist/tests/performance/search-performance.test.d.ts +0 -10
  272. package/dist/tests/performance/search-performance.test.d.ts.map +0 -1
  273. package/dist/tests/performance/search-performance.test.js +0 -222
  274. package/dist/tests/performance/search-performance.test.js.map +0 -1
  275. package/dist/tests/recommend.test.d.ts +0 -6
  276. package/dist/tests/recommend.test.d.ts.map +0 -1
  277. package/dist/tests/recommend.test.js +0 -210
  278. package/dist/tests/recommend.test.js.map +0 -1
  279. package/dist/tests/suggestions/suggestion-engine.test.d.ts +0 -6
  280. package/dist/tests/suggestions/suggestion-engine.test.d.ts.map +0 -1
  281. package/dist/tests/suggestions/suggestion-engine.test.js +0 -448
  282. package/dist/tests/suggestions/suggestion-engine.test.js.map +0 -1
  283. package/dist/tests/test-utils.d.ts +0 -74
  284. package/dist/tests/test-utils.d.ts.map +0 -1
  285. package/dist/tests/test-utils.js +0 -98
  286. package/dist/tests/test-utils.js.map +0 -1
  287. package/dist/tests/tools.test.d.ts +0 -5
  288. package/dist/tests/tools.test.d.ts.map +0 -1
  289. package/dist/tests/tools.test.js +0 -138
  290. package/dist/tests/tools.test.js.map +0 -1
  291. package/dist/tests/unit/installed-skills.test.d.ts +0 -6
  292. package/dist/tests/unit/installed-skills.test.d.ts.map +0 -1
  293. package/dist/tests/unit/installed-skills.test.js +0 -285
  294. package/dist/tests/unit/installed-skills.test.js.map +0 -1
  295. package/dist/tests/unit/logger.test.d.ts +0 -6
  296. package/dist/tests/unit/logger.test.d.ts.map +0 -1
  297. package/dist/tests/unit/logger.test.js +0 -281
  298. package/dist/tests/unit/logger.test.js.map +0 -1
  299. package/dist/tests/validate.test.d.ts +0 -5
  300. package/dist/tests/validate.test.d.ts.map +0 -1
  301. package/dist/tests/validate.test.js +0 -303
  302. package/dist/tests/validate.test.js.map +0 -1
  303. package/dist/tests/webhooks/proxy-trust.security.test.d.ts +0 -8
  304. package/dist/tests/webhooks/proxy-trust.security.test.d.ts.map +0 -1
  305. package/dist/tests/webhooks/proxy-trust.security.test.js +0 -145
  306. package/dist/tests/webhooks/proxy-trust.security.test.js.map +0 -1
  307. package/dist/tests/webhooks/rate-limiter.security.test.d.ts +0 -8
  308. package/dist/tests/webhooks/rate-limiter.security.test.d.ts.map +0 -1
  309. package/dist/tests/webhooks/rate-limiter.security.test.js +0 -122
  310. package/dist/tests/webhooks/rate-limiter.security.test.js.map +0 -1
  311. package/dist/vitest.config.d.ts +0 -6
  312. package/dist/vitest.config.d.ts.map +0 -1
  313. package/dist/vitest.config.js +0 -13
  314. package/dist/vitest.config.js.map +0 -1
@@ -1,294 +0,0 @@
1
- /**
2
- * SMI-1061: MCP Error Formatter for License Errors
3
- *
4
- * Formats license errors into MCP protocol-compliant error responses
5
- * with actionable information for clients.
6
- */
7
- // ============================================================================
8
- // Error Formatting
9
- // ============================================================================
10
- /**
11
- * Format a license error into an MCP-compliant error response
12
- *
13
- * @param error - The license error to format
14
- * @returns MCP-formatted error response
15
- *
16
- * @example
17
- * ```typescript
18
- * import { formatLicenseError } from './middleware/errorFormatter.js';
19
- *
20
- * try {
21
- * await checkFeature('audit_logging');
22
- * } catch (error) {
23
- * if (isLicenseError(error)) {
24
- * return formatLicenseError(error);
25
- * }
26
- * throw error;
27
- * }
28
- * ```
29
- */
30
- export function formatLicenseError(error) {
31
- const errorDetails = {
32
- code: error.code || 'LICENSE_ERROR',
33
- message: error.message,
34
- feature: error.feature,
35
- currentTier: error.currentTier,
36
- requiredTier: error.requiredTier,
37
- upgradeUrl: error.upgradeUrl || 'https://skillsmith.app/upgrade',
38
- timestamp: error.timestamp?.toISOString(),
39
- };
40
- // Build the error response structure matching MCP protocol
41
- const errorBody = {
42
- error: {
43
- code: errorDetails.code,
44
- message: errorDetails.message,
45
- details: {},
46
- },
47
- };
48
- // Add details if present
49
- const details = errorBody.error;
50
- if (errorDetails.feature) {
51
- details.details.feature = errorDetails.feature;
52
- }
53
- if (errorDetails.currentTier) {
54
- details.details.currentTier = errorDetails.currentTier;
55
- }
56
- if (errorDetails.requiredTier) {
57
- details.details.requiredTier = errorDetails.requiredTier;
58
- }
59
- if (errorDetails.upgradeUrl) {
60
- details.details.upgradeUrl = errorDetails.upgradeUrl;
61
- }
62
- // Remove empty details object
63
- if (Object.keys(details.details).length === 0) {
64
- delete errorBody.error.details;
65
- }
66
- return {
67
- content: [
68
- {
69
- type: 'text',
70
- text: JSON.stringify(errorBody, null, 2),
71
- },
72
- ],
73
- isError: true,
74
- _meta: {
75
- upgradeUrl: errorDetails.upgradeUrl,
76
- errorCode: errorDetails.code,
77
- recoverable: isRecoverableError(errorDetails.code),
78
- },
79
- };
80
- }
81
- /**
82
- * Check if an error code represents a recoverable error
83
- */
84
- function isRecoverableError(code) {
85
- // License not found and invalid are potentially recoverable
86
- // (by setting the license key or refreshing)
87
- const recoverableCodes = ['E002', 'E003', 'LICENSE_INVALID', 'LICENSE_NOT_FOUND'];
88
- return recoverableCodes.includes(code);
89
- }
90
- /**
91
- * Format a generic error for MCP response
92
- *
93
- * Use this for non-license errors that still need MCP formatting.
94
- */
95
- export function formatGenericError(error, code = 'INTERNAL_ERROR') {
96
- return {
97
- content: [
98
- {
99
- type: 'text',
100
- text: JSON.stringify({
101
- error: {
102
- code,
103
- message: error.message,
104
- },
105
- }, null, 2),
106
- },
107
- ],
108
- isError: true,
109
- };
110
- }
111
- // ============================================================================
112
- // Error Code Mapping
113
- // ============================================================================
114
- /**
115
- * Map internal license error codes to user-friendly messages
116
- */
117
- const ERROR_MESSAGES = {
118
- E001: 'Your license has expired. Please renew to continue using premium features.',
119
- E002: 'Your license key is invalid. Please verify the key format or contact support.',
120
- E003: 'No license key found. Set SKILLSMITH_LICENSE_KEY environment variable.',
121
- E004: 'This feature is not available in your current license tier.',
122
- E005: 'You have exceeded your license quota. Please upgrade or reduce usage.',
123
- LICENSE_EXPIRED: 'Your license has expired. Please renew to continue using premium features.',
124
- LICENSE_INVALID: 'Your license key is invalid. Please verify the key format or contact support.',
125
- LICENSE_NOT_FOUND: 'No license key found. Set SKILLSMITH_LICENSE_KEY environment variable.',
126
- FEATURE_NOT_AVAILABLE: 'This feature is not available in your current license tier.',
127
- QUOTA_EXCEEDED: 'You have exceeded your license quota. Please upgrade or reduce usage.',
128
- };
129
- /**
130
- * Get a user-friendly message for an error code
131
- */
132
- export function getUserFriendlyMessage(code) {
133
- return ERROR_MESSAGES[code] || 'An error occurred with your license. Please contact support.';
134
- }
135
- const DEFAULT_UPGRADE_URL_CONFIG = {
136
- baseUrl: 'https://skillsmith.app/upgrade',
137
- includeFeature: true,
138
- includeTiers: true,
139
- includeSource: true,
140
- };
141
- /**
142
- * Generate a customized upgrade URL with tracking parameters
143
- */
144
- export function generateUpgradeUrl(error, config = {}) {
145
- const fullConfig = { ...DEFAULT_UPGRADE_URL_CONFIG, ...config };
146
- const params = new URLSearchParams();
147
- if (fullConfig.includeFeature && error.feature) {
148
- params.set('feature', error.feature);
149
- }
150
- if (fullConfig.includeTiers) {
151
- if (error.currentTier) {
152
- params.set('from', error.currentTier);
153
- }
154
- if (error.requiredTier) {
155
- params.set('to', error.requiredTier);
156
- }
157
- }
158
- if (fullConfig.includeSource) {
159
- params.set('source', 'mcp-error');
160
- if (error.code) {
161
- params.set('error_code', error.code);
162
- }
163
- }
164
- const queryString = params.toString();
165
- return queryString ? `${fullConfig.baseUrl}?${queryString}` : fullConfig.baseUrl || '';
166
- }
167
- // ============================================================================
168
- // Response Builders
169
- // ============================================================================
170
- /**
171
- * Build an upgrade required response
172
- *
173
- * Use this when a feature requires an upgrade but isn't a full error.
174
- */
175
- export function buildUpgradeRequiredResponse(feature, currentTier, requiredTier) {
176
- const upgradeUrl = `https://skillsmith.app/upgrade?feature=${feature}&from=${currentTier}&to=${requiredTier}`;
177
- return {
178
- content: [
179
- {
180
- type: 'text',
181
- text: JSON.stringify({
182
- error: {
183
- code: 'E004',
184
- message: `${feature} requires ${requiredTier} tier`,
185
- details: {
186
- feature,
187
- currentTier,
188
- requiredTier,
189
- upgradeUrl,
190
- },
191
- },
192
- }, null, 2),
193
- },
194
- ],
195
- isError: true,
196
- _meta: {
197
- upgradeUrl,
198
- errorCode: 'E004',
199
- recoverable: false,
200
- },
201
- };
202
- }
203
- /**
204
- * Build a license expired response with renewal URL
205
- */
206
- export function buildLicenseExpiredResponse(expiredAt) {
207
- const renewUrl = 'https://skillsmith.app/renew';
208
- return {
209
- content: [
210
- {
211
- type: 'text',
212
- text: JSON.stringify({
213
- error: {
214
- code: 'E001',
215
- message: 'Your license has expired',
216
- details: {
217
- expiredAt: expiredAt?.toISOString(),
218
- renewUrl,
219
- },
220
- },
221
- }, null, 2),
222
- },
223
- ],
224
- isError: true,
225
- _meta: {
226
- upgradeUrl: renewUrl,
227
- errorCode: 'E001',
228
- recoverable: false,
229
- },
230
- };
231
- }
232
- /**
233
- * Build a quota exceeded response
234
- */
235
- export function buildQuotaExceededResponse(quotaType, current, max) {
236
- const upgradeUrl = `https://skillsmith.app/upgrade?quota=${quotaType}`;
237
- return {
238
- content: [
239
- {
240
- type: 'text',
241
- text: JSON.stringify({
242
- error: {
243
- code: 'E005',
244
- message: `${quotaType} quota exceeded`,
245
- details: {
246
- quotaType,
247
- current,
248
- max,
249
- upgradeUrl,
250
- },
251
- },
252
- }, null, 2),
253
- },
254
- ],
255
- isError: true,
256
- _meta: {
257
- upgradeUrl,
258
- errorCode: 'E005',
259
- recoverable: false,
260
- },
261
- };
262
- }
263
- // ============================================================================
264
- // Validation Helpers
265
- // ============================================================================
266
- /**
267
- * Check if an object looks like a license error
268
- */
269
- export function isLicenseErrorLike(error) {
270
- if (!error || typeof error !== 'object') {
271
- return false;
272
- }
273
- const e = error;
274
- // Must have a message
275
- if (typeof e.message !== 'string') {
276
- return false;
277
- }
278
- // Should have license-specific properties
279
- const hasLicenseProps = 'code' in e || 'feature' in e || 'currentTier' in e || 'requiredTier' in e || 'upgradeUrl' in e;
280
- return hasLicenseProps;
281
- }
282
- /**
283
- * Safely convert any error to MCP format
284
- */
285
- export function safeFormatError(error) {
286
- if (isLicenseErrorLike(error)) {
287
- return formatLicenseError(error);
288
- }
289
- if (error instanceof Error) {
290
- return formatGenericError(error);
291
- }
292
- return formatGenericError(new Error(String(error)));
293
- }
294
- //# sourceMappingURL=errorFormatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorFormatter.js","sourceRoot":"","sources":["../../../src/middleware/errorFormatter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwDH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM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AACxB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,kBAAkB,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * MCP Server Middleware
3
- *
4
- * Exports all middleware for the Skillsmith MCP server.
5
- */
6
- export { cspMiddleware, buildCspHeader, generateNonce, validateCspHeader, validateCspHeaderDetailed, getCspForEnvironment, DEFAULT_CSP_DIRECTIVES, STRICT_CSP_DIRECTIVES, type CspDirectives, type CspValidationResult, } from './csp.js';
7
- export { createLicenseMiddleware, requireFeature, isEnterpriseFeature, requiresLicense, getRequiredFeature, createLicenseErrorResponse, type LicenseMiddleware, type LicenseMiddlewareContext, type LicenseValidationResult, type LicenseInfo, type LicenseTier, type FeatureFlag, TOOL_FEATURES, FEATURE_DISPLAY_NAMES, FEATURE_TIERS, } from './license.js';
8
- export { createQuotaMiddleware, withQuotaEnforcement, isUnlimitedTier, getQuotaLimit, formatQuotaRemaining, type QuotaMiddleware, type QuotaMiddlewareOptions, type QuotaCheckResult, type QuotaMetadata, type QuotaStorage, } from './quota.js';
9
- export { createDegradationMiddleware, getTierComparisonMessage, consoleDegradationLogger, type DegradationMiddleware, type DegradationMiddlewareOptions, type DegradationLogger, type DegradationLogEvent, type McpToolRequest, type McpToolResponse, type ToolHandler, } from './degradation.js';
10
- export { formatLicenseError, formatGenericError, getUserFriendlyMessage, generateUpgradeUrl, buildUpgradeRequiredResponse, buildLicenseExpiredResponse, buildQuotaExceededResponse, isLicenseErrorLike, safeFormatError, type MCPErrorContent, type MCPErrorResponse, type LicenseErrorDetails as MCPLicenseErrorDetails, type LicenseErrorLike, type UpgradeUrlConfig, } from './errorFormatter.js';
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,aAAa,EACb,qBAAqB,EACrB,aAAa,GACd,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,IAAI,sBAAsB,EAClD,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAA"}
@@ -1,16 +0,0 @@
1
- /**
2
- * MCP Server Middleware
3
- *
4
- * Exports all middleware for the Skillsmith MCP server.
5
- */
6
- // CSP middleware
7
- export { cspMiddleware, buildCspHeader, generateNonce, validateCspHeader, validateCspHeaderDetailed, getCspForEnvironment, DEFAULT_CSP_DIRECTIVES, STRICT_CSP_DIRECTIVES, } from './csp.js';
8
- // License middleware
9
- export { createLicenseMiddleware, requireFeature, isEnterpriseFeature, requiresLicense, getRequiredFeature, createLicenseErrorResponse, TOOL_FEATURES, FEATURE_DISPLAY_NAMES, FEATURE_TIERS, } from './license.js';
10
- // Quota enforcement middleware (SMI-1091)
11
- export { createQuotaMiddleware, withQuotaEnforcement, isUnlimitedTier, getQuotaLimit, formatQuotaRemaining, } from './quota.js';
12
- // Degradation middleware (SMI-1060)
13
- export { createDegradationMiddleware, getTierComparisonMessage, consoleDegradationLogger, } from './degradation.js';
14
- // MCP Error Formatter (SMI-1061)
15
- export { formatLicenseError, formatGenericError, getUserFriendlyMessage, generateUpgradeUrl, buildUpgradeRequiredResponse, buildLicenseExpiredResponse, buildQuotaExceededResponse, isLicenseErrorLike, safeFormatError, } from './errorFormatter.js';
16
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,GAGtB,MAAM,UAAU,CAAA;AAEjB,qBAAqB;AACrB,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAO1B,aAAa,EACb,qBAAqB,EACrB,aAAa,GACd,MAAM,cAAc,CAAA;AAErB,0CAA0C;AAC1C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,oBAAoB,GAMrB,MAAM,YAAY,CAAA;AAEnB,oCAAoC;AACpC,OAAO,EACL,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,GAQzB,MAAM,kBAAkB,CAAA;AAEzB,iCAAiC;AACjC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,kBAAkB,EAClB,eAAe,GAMhB,MAAM,qBAAqB,CAAA"}
@@ -1,169 +0,0 @@
1
- /**
2
- * License validation middleware for MCP server
3
- *
4
- * Validates that the user has the required license features for enterprise tools.
5
- * Gracefully degrades if @skillsmith/enterprise is not installed.
6
- *
7
- * @see SMI-1055: Add license middleware to MCP server
8
- */
9
- import { type FeatureFlag } from './toolFeatureMapping.js';
10
- /**
11
- * License validation result
12
- */
13
- export interface LicenseValidationResult {
14
- valid: boolean;
15
- feature?: FeatureFlag;
16
- message?: string;
17
- upgradeUrl?: string;
18
- warning?: string;
19
- }
20
- /**
21
- * License tiers available in Skillsmith
22
- * - community: Free tier (1,000 API calls/month)
23
- * - individual: Solo developers ($9.99/mo, 10,000 API calls/month)
24
- * - team: Development teams ($25/user/mo, 100,000 API calls/month)
25
- * - enterprise: Full enterprise ($55/user/mo, unlimited)
26
- */
27
- export type LicenseTier = 'community' | 'individual' | 'team' | 'enterprise';
28
- /**
29
- * License information interface (mirrors @skillsmith/enterprise LicenseInfo)
30
- */
31
- export interface LicenseInfo {
32
- valid: boolean;
33
- tier: LicenseTier;
34
- features: FeatureFlag[];
35
- expiresAt?: Date;
36
- organizationId?: string;
37
- }
38
- /**
39
- * License from enterprise package validation
40
- */
41
- interface EnterpriseLicense {
42
- tier: LicenseTier;
43
- features: FeatureFlag[];
44
- customerId: string;
45
- issuedAt: Date;
46
- expiresAt: Date;
47
- }
48
- /**
49
- * Validation result from enterprise package
50
- */
51
- interface EnterpriseValidationResult {
52
- valid: boolean;
53
- license?: EnterpriseLicense;
54
- error?: {
55
- code: string;
56
- message: string;
57
- };
58
- }
59
- /**
60
- * License validator instance type from enterprise package
61
- * Uses duck typing to avoid interface drift with the actual implementation
62
- */
63
- type EnterpriseValidator = {
64
- validate(licenseKey: string): Promise<EnterpriseValidationResult>;
65
- };
66
- /**
67
- * Check if a tool name corresponds to an enterprise feature
68
- *
69
- * @param toolName - The name of the MCP tool
70
- * @returns true if the tool requires an enterprise license
71
- */
72
- export declare function isEnterpriseFeature(toolName: string): boolean;
73
- /**
74
- * Check if a tool name requires any license (team or enterprise)
75
- *
76
- * @param toolName - The name of the MCP tool
77
- * @returns true if the tool requires any license
78
- */
79
- export declare function requiresLicense(toolName: string): boolean;
80
- /**
81
- * Get the required feature for a tool
82
- *
83
- * @param toolName - The name of the MCP tool
84
- * @returns The feature flag required, or null if community tool
85
- */
86
- export declare function getRequiredFeature(toolName: string): FeatureFlag | null;
87
- /**
88
- * License middleware context
89
- */
90
- export interface LicenseMiddlewareContext {
91
- validator: EnterpriseValidator | null;
92
- licenseKey: string | undefined;
93
- cachedLicense: LicenseInfo | null;
94
- cacheExpiry: number;
95
- }
96
- /**
97
- * License middleware instance
98
- */
99
- export interface LicenseMiddleware {
100
- /**
101
- * Check if a specific feature is available
102
- */
103
- checkFeature(feature: FeatureFlag): Promise<LicenseValidationResult>;
104
- /**
105
- * Check if a tool can be executed
106
- */
107
- checkTool(toolName: string): Promise<LicenseValidationResult>;
108
- /**
109
- * Get the current license info
110
- */
111
- getLicenseInfo(): Promise<LicenseInfo | null>;
112
- /**
113
- * Invalidate the cached license
114
- */
115
- invalidateCache(): void;
116
- }
117
- /**
118
- * Create a license middleware factory
119
- *
120
- * This middleware reads the license key from environment variables and
121
- * validates tool access based on the license features.
122
- *
123
- * @param options - Optional configuration
124
- * @returns License middleware instance
125
- */
126
- export declare function createLicenseMiddleware(options?: {
127
- licenseKeyEnvVar?: string;
128
- cacheTtlMs?: number;
129
- }): LicenseMiddleware;
130
- /**
131
- * Higher-order function to create feature requirement middleware
132
- *
133
- * Use this to wrap tool handlers that require specific features.
134
- *
135
- * @param feature - The feature flag required
136
- * @returns Middleware function that checks the feature
137
- *
138
- * @example
139
- * ```typescript
140
- * const middleware = createLicenseMiddleware();
141
- * const requireAudit = requireFeature('audit_logging');
142
- *
143
- * // In tool handler:
144
- * const validation = await requireAudit(middleware);
145
- * if (!validation.valid) {
146
- * return { error: validation.message, upgradeUrl: validation.upgradeUrl };
147
- * }
148
- * ```
149
- */
150
- export declare function requireFeature(feature: FeatureFlag): (middleware: LicenseMiddleware) => Promise<LicenseValidationResult>;
151
- /**
152
- * Create an error response for license validation failures
153
- *
154
- * @param result - The license validation result
155
- * @returns MCP-formatted error response
156
- */
157
- export declare function createLicenseErrorResponse(result: LicenseValidationResult): {
158
- content: Array<{
159
- type: 'text';
160
- text: string;
161
- }>;
162
- isError: true;
163
- _meta?: {
164
- upgradeUrl: string;
165
- };
166
- };
167
- export type { FeatureFlag } from './toolFeatureMapping.js';
168
- export { TOOL_FEATURES, FEATURE_DISPLAY_NAMES, FEATURE_TIERS } from './toolFeatureMapping.js';
169
- //# sourceMappingURL=license.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"license.d.ts","sourceRoot":"","sources":["../../../src/middleware/license.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAA;AAOhC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MA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