@enfyra/mcp-server 0.1.69 → 0.1.71

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 (248) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/config-local-adapters.d.ts +18 -0
  3. package/dist/lib/config-local-adapters.js +271 -0
  4. package/dist/lib/config-local-adapters.js.map +1 -0
  5. package/dist/lib/config-local-contracts.d.ts +28 -0
  6. package/dist/lib/config-local-contracts.js +200 -0
  7. package/dist/lib/config-local-contracts.js.map +1 -0
  8. package/dist/lib/config-local-prompts.d.ts +10 -0
  9. package/dist/lib/config-local-prompts.js +185 -0
  10. package/dist/lib/config-local-prompts.js.map +1 -0
  11. package/dist/lib/config-local-types.d.ts +23 -0
  12. package/dist/lib/config-local-types.js +2 -0
  13. package/dist/lib/config-local-types.js.map +1 -0
  14. package/dist/lib/config-local.js +3 -649
  15. package/dist/lib/config-local.js.map +1 -1
  16. package/dist/lib/discovery-tools.d.ts +4 -0
  17. package/dist/lib/discovery-tools.js +546 -0
  18. package/dist/lib/discovery-tools.js.map +1 -0
  19. package/dist/lib/dynamic-repository-builder.d.ts +1 -1
  20. package/dist/lib/dynamic-script-context-contract.d.ts +100 -0
  21. package/dist/lib/dynamic-script-context-contract.js +163 -0
  22. package/dist/lib/dynamic-script-context-contract.js.map +1 -0
  23. package/dist/lib/enfyra-mcp-server.d.ts +3 -0
  24. package/dist/lib/enfyra-mcp-server.js +79 -0
  25. package/dist/lib/enfyra-mcp-server.js.map +1 -0
  26. package/dist/lib/enfyra-tool-logic.d.ts +7 -0
  27. package/dist/lib/enfyra-tool-logic.js +8 -0
  28. package/dist/lib/enfyra-tool-logic.js.map +1 -0
  29. package/dist/lib/enfyra-tool-types.d.ts +27 -0
  30. package/dist/lib/enfyra-tool-types.js +2 -0
  31. package/dist/lib/enfyra-tool-types.js.map +1 -0
  32. package/dist/lib/extension-api-builders.d.ts +17 -0
  33. package/dist/lib/extension-api-builders.js +235 -0
  34. package/dist/lib/extension-api-builders.js.map +1 -0
  35. package/dist/lib/extension-component-builders.d.ts +87 -0
  36. package/dist/lib/extension-component-builders.js +623 -0
  37. package/dist/lib/extension-component-builders.js.map +1 -0
  38. package/dist/lib/extension-contract-review.d.ts +26 -0
  39. package/dist/lib/extension-contract-review.js +187 -0
  40. package/dist/lib/extension-contract-review.js.map +1 -0
  41. package/dist/lib/extension-theme-contract.d.ts +63 -0
  42. package/dist/lib/extension-theme-contract.js +417 -0
  43. package/dist/lib/extension-theme-contract.js.map +1 -0
  44. package/dist/lib/identity-tools.d.ts +4 -0
  45. package/dist/lib/identity-tools.js +46 -0
  46. package/dist/lib/identity-tools.js.map +1 -0
  47. package/dist/lib/log-tools.d.ts +4 -0
  48. package/dist/lib/log-tools.js +65 -0
  49. package/dist/lib/log-tools.js.map +1 -0
  50. package/dist/lib/mcp-example-connect.d.ts +9 -0
  51. package/dist/lib/mcp-example-connect.js +442 -0
  52. package/dist/lib/mcp-example-connect.js.map +1 -0
  53. package/dist/lib/mcp-example-extensions.d.ts +9 -0
  54. package/dist/lib/mcp-example-extensions.js +729 -0
  55. package/dist/lib/mcp-example-extensions.js.map +1 -0
  56. package/dist/lib/mcp-example-files.d.ts +9 -0
  57. package/dist/lib/mcp-example-files.js +51 -0
  58. package/dist/lib/mcp-example-files.js.map +1 -0
  59. package/dist/lib/mcp-example-flows.d.ts +9 -0
  60. package/dist/lib/mcp-example-flows.js +76 -0
  61. package/dist/lib/mcp-example-flows.js.map +1 -0
  62. package/dist/lib/mcp-example-graphql.d.ts +9 -0
  63. package/dist/lib/mcp-example-graphql.js +57 -0
  64. package/dist/lib/mcp-example-graphql.js.map +1 -0
  65. package/dist/lib/mcp-example-handlers-hooks.d.ts +9 -0
  66. package/dist/lib/mcp-example-handlers-hooks.js +328 -0
  67. package/dist/lib/mcp-example-handlers-hooks.js.map +1 -0
  68. package/dist/lib/mcp-example-oauth-setup.d.ts +9 -0
  69. package/dist/lib/mcp-example-oauth-setup.js +41 -0
  70. package/dist/lib/mcp-example-oauth-setup.js.map +1 -0
  71. package/dist/lib/mcp-example-permissions-rls.d.ts +9 -0
  72. package/dist/lib/mcp-example-permissions-rls.js +210 -0
  73. package/dist/lib/mcp-example-permissions-rls.js.map +1 -0
  74. package/dist/lib/mcp-example-queries-deep.d.ts +9 -0
  75. package/dist/lib/mcp-example-queries-deep.js +220 -0
  76. package/dist/lib/mcp-example-queries-deep.js.map +1 -0
  77. package/dist/lib/mcp-example-schema-relations.d.ts +9 -0
  78. package/dist/lib/mcp-example-schema-relations.js +148 -0
  79. package/dist/lib/mcp-example-schema-relations.js.map +1 -0
  80. package/dist/lib/mcp-example-websocket.d.ts +9 -0
  81. package/dist/lib/mcp-example-websocket.js +103 -0
  82. package/dist/lib/mcp-example-websocket.js.map +1 -0
  83. package/dist/lib/mcp-examples.d.ts +5 -5
  84. package/dist/lib/mcp-examples.js +22 -2394
  85. package/dist/lib/mcp-examples.js.map +1 -1
  86. package/dist/lib/method-tools.d.ts +4 -0
  87. package/dist/lib/method-tools.js +217 -0
  88. package/dist/lib/method-tools.js.map +1 -0
  89. package/dist/lib/package-tools.d.ts +4 -0
  90. package/dist/lib/package-tools.js +98 -0
  91. package/dist/lib/package-tools.js.map +1 -0
  92. package/dist/lib/platform-data-operations.d.ts +24 -0
  93. package/dist/lib/platform-data-operations.js +71 -0
  94. package/dist/lib/platform-data-operations.js.map +1 -0
  95. package/dist/lib/platform-endpoint-workflow.d.ts +42 -0
  96. package/dist/lib/platform-endpoint-workflow.js +382 -0
  97. package/dist/lib/platform-endpoint-workflow.js.map +1 -0
  98. package/dist/lib/platform-extension-source.d.ts +487 -0
  99. package/dist/lib/platform-extension-source.js +524 -0
  100. package/dist/lib/platform-extension-source.js.map +1 -0
  101. package/dist/lib/platform-extension-tools.d.ts +1 -0
  102. package/dist/lib/platform-extension-tools.js +416 -0
  103. package/dist/lib/platform-extension-tools.js.map +1 -0
  104. package/dist/lib/platform-extension-ui.d.ts +4 -0
  105. package/dist/lib/platform-extension-ui.js +5 -0
  106. package/dist/lib/platform-extension-ui.js.map +1 -0
  107. package/dist/lib/platform-extension-workflow.d.ts +54 -0
  108. package/dist/lib/platform-extension-workflow.js +194 -0
  109. package/dist/lib/platform-extension-workflow.js.map +1 -0
  110. package/dist/lib/platform-flow-operations.d.ts +554 -0
  111. package/dist/lib/platform-flow-operations.js +317 -0
  112. package/dist/lib/platform-flow-operations.js.map +1 -0
  113. package/dist/lib/platform-flow-tools.d.ts +1 -0
  114. package/dist/lib/platform-flow-tools.js +248 -0
  115. package/dist/lib/platform-flow-tools.js.map +1 -0
  116. package/dist/lib/platform-operation-logic.d.ts +10 -0
  117. package/dist/lib/platform-operation-logic.js +11 -0
  118. package/dist/lib/platform-operation-logic.js.map +1 -0
  119. package/dist/lib/platform-operation-tools.d.ts +1 -324
  120. package/dist/lib/platform-operation-tools.js +13 -4620
  121. package/dist/lib/platform-operation-tools.js.map +1 -1
  122. package/dist/lib/platform-operation-types.d.ts +46 -0
  123. package/dist/lib/platform-operation-types.js +2 -0
  124. package/dist/lib/platform-operation-types.js.map +1 -0
  125. package/dist/lib/platform-policy-tools.d.ts +1 -0
  126. package/dist/lib/platform-policy-tools.js +248 -0
  127. package/dist/lib/platform-policy-tools.js.map +1 -0
  128. package/dist/lib/platform-resource-operations.d.ts +124 -0
  129. package/dist/lib/platform-resource-operations.js +109 -0
  130. package/dist/lib/platform-resource-operations.js.map +1 -0
  131. package/dist/lib/platform-resource-tools.d.ts +1 -0
  132. package/dist/lib/platform-resource-tools.js +70 -0
  133. package/dist/lib/platform-resource-tools.js.map +1 -0
  134. package/dist/lib/platform-route-operations.d.ts +222 -0
  135. package/dist/lib/platform-route-operations.js +290 -0
  136. package/dist/lib/platform-route-operations.js.map +1 -0
  137. package/dist/lib/platform-route-tools.d.ts +1 -0
  138. package/dist/lib/platform-route-tools.js +307 -0
  139. package/dist/lib/platform-route-tools.js.map +1 -0
  140. package/dist/lib/platform-shared-operations.d.ts +7 -0
  141. package/dist/lib/platform-shared-operations.js +4 -0
  142. package/dist/lib/platform-shared-operations.js.map +1 -0
  143. package/dist/lib/platform-websocket-tools.d.ts +1 -0
  144. package/dist/lib/platform-websocket-tools.js +70 -0
  145. package/dist/lib/platform-websocket-tools.js.map +1 -0
  146. package/dist/lib/record-tools.d.ts +4 -0
  147. package/dist/lib/record-tools.js +418 -0
  148. package/dist/lib/record-tools.js.map +1 -0
  149. package/dist/lib/required-knowledge.d.ts +1 -1
  150. package/dist/lib/required-knowledge.js +3 -2
  151. package/dist/lib/required-knowledge.js.map +1 -1
  152. package/dist/lib/route-access-tools.d.ts +4 -0
  153. package/dist/lib/route-access-tools.js +172 -0
  154. package/dist/lib/route-access-tools.js.map +1 -0
  155. package/dist/lib/route-definition-tools.d.ts +4 -0
  156. package/dist/lib/route-definition-tools.js +285 -0
  157. package/dist/lib/route-definition-tools.js.map +1 -0
  158. package/dist/lib/route-inspection-tools.d.ts +4 -0
  159. package/dist/lib/route-inspection-tools.js +319 -0
  160. package/dist/lib/route-inspection-tools.js.map +1 -0
  161. package/dist/lib/route-tools.d.ts +1 -0
  162. package/dist/lib/route-tools.js +9 -0
  163. package/dist/lib/route-tools.js.map +1 -0
  164. package/dist/lib/runtime-zone-registry.d.ts +27 -0
  165. package/dist/lib/runtime-zone-registry.js +81 -0
  166. package/dist/lib/runtime-zone-registry.js.map +1 -0
  167. package/dist/lib/runtime-zone-search.d.ts +303 -0
  168. package/dist/lib/runtime-zone-search.js +596 -0
  169. package/dist/lib/runtime-zone-search.js.map +1 -0
  170. package/dist/lib/runtime-zone-tools.d.ts +2 -307
  171. package/dist/lib/runtime-zone-tools.js +2 -674
  172. package/dist/lib/runtime-zone-tools.js.map +1 -1
  173. package/dist/lib/schema-column-tools.d.ts +3 -0
  174. package/dist/lib/schema-column-tools.js +80 -0
  175. package/dist/lib/schema-column-tools.js.map +1 -0
  176. package/dist/lib/schema-mutation-coordinator.d.ts +28 -0
  177. package/dist/lib/schema-mutation-coordinator.js +154 -0
  178. package/dist/lib/schema-mutation-coordinator.js.map +1 -0
  179. package/dist/lib/schema-relation-contracts.d.ts +39 -0
  180. package/dist/lib/schema-relation-contracts.js +160 -0
  181. package/dist/lib/schema-relation-contracts.js.map +1 -0
  182. package/dist/lib/schema-relation-tools.d.ts +3 -0
  183. package/dist/lib/schema-relation-tools.js +61 -0
  184. package/dist/lib/schema-relation-tools.js.map +1 -0
  185. package/dist/lib/schema-table-contracts.d.ts +28 -0
  186. package/dist/lib/schema-table-contracts.js +263 -0
  187. package/dist/lib/schema-table-contracts.js.map +1 -0
  188. package/dist/lib/schema-table-tools.d.ts +3 -0
  189. package/dist/lib/schema-table-tools.js +297 -0
  190. package/dist/lib/schema-table-tools.js.map +1 -0
  191. package/dist/lib/schema-tool-operations.d.ts +150 -0
  192. package/dist/lib/schema-tool-operations.js +468 -0
  193. package/dist/lib/schema-tool-operations.js.map +1 -0
  194. package/dist/lib/schema-tool-types.d.ts +38 -0
  195. package/dist/lib/schema-tool-types.js +2 -0
  196. package/dist/lib/schema-tool-types.js.map +1 -0
  197. package/dist/lib/schema-verification.d.ts +14 -0
  198. package/dist/lib/schema-verification.js +105 -0
  199. package/dist/lib/schema-verification.js.map +1 -0
  200. package/dist/lib/script-tools.d.ts +4 -0
  201. package/dist/lib/script-tools.js +127 -0
  202. package/dist/lib/script-tools.js.map +1 -0
  203. package/dist/lib/system-tools.d.ts +4 -0
  204. package/dist/lib/system-tools.js +41 -0
  205. package/dist/lib/system-tools.js.map +1 -0
  206. package/dist/lib/table-tool-logic.d.ts +5 -0
  207. package/dist/lib/table-tool-logic.js +6 -0
  208. package/dist/lib/table-tool-logic.js.map +1 -0
  209. package/dist/lib/table-tools.d.ts +1 -84
  210. package/dist/lib/table-tools.js +7 -1522
  211. package/dist/lib/table-tools.js.map +1 -1
  212. package/dist/lib/tool-catalog.d.ts +2 -1
  213. package/dist/lib/tool-catalog.js +23 -2
  214. package/dist/lib/tool-catalog.js.map +1 -1
  215. package/dist/lib/tool-metadata-operations.d.ts +27 -0
  216. package/dist/lib/tool-metadata-operations.js +93 -0
  217. package/dist/lib/tool-metadata-operations.js.map +1 -0
  218. package/dist/lib/tool-permission-profile.d.ts +37 -0
  219. package/dist/lib/tool-permission-profile.js +106 -0
  220. package/dist/lib/tool-permission-profile.js.map +1 -0
  221. package/dist/lib/tool-record-operations.d.ts +102 -0
  222. package/dist/lib/tool-record-operations.js +260 -0
  223. package/dist/lib/tool-record-operations.js.map +1 -0
  224. package/dist/lib/tool-route-inspection.d.ts +47 -0
  225. package/dist/lib/tool-route-inspection.js +168 -0
  226. package/dist/lib/tool-route-inspection.js.map +1 -0
  227. package/dist/lib/tool-routing.d.ts +3 -417
  228. package/dist/lib/tool-routing.js +3 -1038
  229. package/dist/lib/tool-routing.js.map +1 -1
  230. package/dist/lib/tool-runtime-config.d.ts +33 -0
  231. package/dist/lib/tool-runtime-config.js +237 -0
  232. package/dist/lib/tool-runtime-config.js.map +1 -0
  233. package/dist/lib/tool-script-operations.d.ts +34 -0
  234. package/dist/lib/tool-script-operations.js +153 -0
  235. package/dist/lib/tool-script-operations.js.map +1 -0
  236. package/dist/lib/workflow-definitions.d.ts +366 -0
  237. package/dist/lib/workflow-definitions.js +703 -0
  238. package/dist/lib/workflow-definitions.js.map +1 -0
  239. package/dist/lib/workflow-planner.d.ts +45 -0
  240. package/dist/lib/workflow-planner.js +338 -0
  241. package/dist/lib/workflow-planner.js.map +1 -0
  242. package/dist/lib/workflow-types.d.ts +39 -0
  243. package/dist/lib/workflow-types.js +2 -0
  244. package/dist/lib/workflow-types.js.map +1 -0
  245. package/dist/mcp-server-entry.d.ts +0 -3
  246. package/dist/mcp-server-entry.js +2 -3249
  247. package/dist/mcp-server-entry.js.map +1 -1
  248. package/package.json +1 -1
@@ -0,0 +1,417 @@
1
+ import { buildExtensionAccountPanelSnippet, buildExtensionDrawerSnippet, buildExtensionEmptyStateSnippet, buildExtensionFormEditorSnippet, buildExtensionMenuNotificationSnippet, buildExtensionModalSnippet, buildExtensionPageShellSnippet, buildExtensionPermissionGateSnippet, buildExtensionResourceGridSnippet, buildExtensionResourceListSnippet, buildExtensionTabsSnippet, buildExtensionUploadModalSnippet, buildExtensionWidgetSnippet, } from './extension-component-builders.js';
2
+ import { buildExtensionApiUsageSnippet, buildExtensionConfirmSnippet, buildExtensionNotifySnippet, } from './extension-api-builders.js';
3
+ import { reviewExtensionRuntimeContract, reviewExtensionUiContract, } from './extension-contract-review.js';
4
+ const THEME_CLASS_INTENTS = {
5
+ neutral_surface: {
6
+ classes: 'eapp-surface-card eapp-radius-panel border eapp-divider',
7
+ use: 'Ordinary cards, panels, KPI containers, list containers, detail blocks, and status blocks that should stay neutral.',
8
+ },
9
+ muted_surface: {
10
+ classes: 'eapp-surface-muted eapp-radius-panel',
11
+ use: 'Recessed areas, tracks, secondary panels, or subdued containers.',
12
+ },
13
+ flat_surface: {
14
+ classes: 'eapp-surface-flat',
15
+ use: 'Flush content areas that should follow the app surface without card chrome.',
16
+ },
17
+ hover_row: {
18
+ classes: 'eapp-surface-hover eapp-divider',
19
+ use: 'Clickable rows inside lists or tables.',
20
+ },
21
+ primary_identity: {
22
+ classes: 'eapp-primary-surface eapp-radius-panel border',
23
+ use: 'A selected/current entity, active plan, active package, or the single larger block representing current identity.',
24
+ },
25
+ primary_soft_icon_tile: {
26
+ classes: 'eapp-primary-soft eapp-icon-tile',
27
+ childClasses: 'eapp-primary-text',
28
+ use: 'Compact runtime-primary icon tiles, selected chips, and small identity accents.',
29
+ },
30
+ primary_progress: {
31
+ trackClasses: 'eapp-surface-muted eapp-radius-pill',
32
+ fillClasses: 'eapp-primary-solid',
33
+ use: 'Progress or meter fill controlled by the runtime primary color.',
34
+ },
35
+ status_success: {
36
+ classes: 'eapp-status-success-soft eapp-status-success-text eapp-status-success-border',
37
+ nuxtUi: { color: 'success', variant: 'soft' },
38
+ use: 'Small success/healthy badges, chips, or icons only.',
39
+ },
40
+ status_warning: {
41
+ classes: 'eapp-status-warning-soft eapp-status-warning-text eapp-status-warning-border',
42
+ nuxtUi: { color: 'warning', variant: 'soft' },
43
+ use: 'Small warning/attention badges, chips, or icons only.',
44
+ },
45
+ status_danger: {
46
+ classes: 'eapp-status-danger-soft eapp-status-danger-text eapp-status-danger-border',
47
+ nuxtUi: { color: 'error', variant: 'soft' },
48
+ use: 'Small danger/error/destructive badges, chips, or icons only.',
49
+ },
50
+ status_info: {
51
+ classes: 'eapp-status-info-soft eapp-status-info-text eapp-status-info-border',
52
+ nuxtUi: { color: 'info', variant: 'soft' },
53
+ use: 'Small informational badges, chips, or icons only.',
54
+ },
55
+ primary_action: {
56
+ nuxtUi: { color: 'primary', variant: 'solid' },
57
+ use: 'The single main action for the current scope.',
58
+ },
59
+ secondary_action: {
60
+ nuxtUi: { color: 'neutral', variant: 'outline' },
61
+ use: 'Visible secondary actions, refresh, filters, cancel, and navigation alternatives.',
62
+ },
63
+ ghost_navigation_action: {
64
+ nuxtUi: { color: 'neutral', variant: 'ghost' },
65
+ use: 'Back/navigation/icon actions that should not compete with the primary action.',
66
+ },
67
+ danger_action: {
68
+ nuxtUi: { color: 'error', variant: 'solid' },
69
+ use: 'Final destructive actions such as Delete or Remove.',
70
+ },
71
+ divider: {
72
+ classes: 'eapp-divider',
73
+ listClasses: 'eapp-divide-y',
74
+ use: 'Borders and row separators in extension UI.',
75
+ },
76
+ text: {
77
+ primary: 'eapp-text-primary',
78
+ secondary: 'eapp-text-secondary',
79
+ tertiary: 'eapp-text-tertiary',
80
+ quaternary: 'eapp-text-quaternary',
81
+ use: 'Copy hierarchy in extension UI.',
82
+ },
83
+ };
84
+ function buildExtensionThemeClasses(input = {}) {
85
+ const intent = String(input.intent || '').trim();
86
+ if (!intent || !(intent in THEME_CLASS_INTENTS)) {
87
+ return {
88
+ action: 'extension_theme_classes_listed',
89
+ validIntents: Object.keys(THEME_CLASS_INTENTS),
90
+ note: 'Call again with one intent to get the exact classes/props for that theme contract.',
91
+ };
92
+ }
93
+ const contract = THEME_CLASS_INTENTS[intent];
94
+ return {
95
+ action: 'extension_theme_classes_built',
96
+ intent,
97
+ contract,
98
+ hardRules: [
99
+ 'Do not use raw CSS variable utilities such as text-[var(...)], bg-[var(...)], or border-[var(...)] in extension templates.',
100
+ 'Do not use hardcoded Tailwind palettes such as bg-violet-*, text-cyan-*, bg-green-*, dark:bg-zinc-*, or hex/rgb/hsl colors.',
101
+ 'Use status classes only for compact badges/icons/short text; keep large panels neutral.',
102
+ ],
103
+ };
104
+ }
105
+ function collectExtensionThemeIssues(code) {
106
+ const source = String(code || '');
107
+ const issues = [];
108
+ const push = (severity, rule, message, suggestion) => issues.push({ severity, rule, message, suggestion });
109
+ const concretePalettes = [
110
+ 'slate', 'gray', 'zinc', 'neutral', 'stone',
111
+ 'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo',
112
+ 'violet', 'purple', 'fuchsia', 'pink', 'rose',
113
+ ].join('|');
114
+ const paletteClassPattern = new RegExp(`(?:^|[\\s"'])(?:dark:)?(?:bg|text|border|ring|divide|from|via|to)-(${concretePalettes})-(?:\\d{2,3}|950)(?:\\/\\d+)?`, 'i');
115
+ const rawCssVarPattern = /\b(?:bg|text|border|ring|divide|from|via|to)-\[\s*var\(--/i;
116
+ const neutralSemanticClassPattern = /\b(?:bg-default|bg-muted|border-default|divide-default|text-muted|text-dimmed)\b/;
117
+ const concreteNuxtUiColors = [
118
+ 'slate', 'gray', 'zinc', 'stone',
119
+ 'red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo',
120
+ 'violet', 'purple', 'fuchsia', 'pink', 'rose',
121
+ ].join('|');
122
+ const concreteNuxtColorPattern = new RegExp(`\\bcolor\\s*=\\s*["'](${concreteNuxtUiColors})["']`, 'i');
123
+ if (rawCssVarPattern.test(source)) {
124
+ push('error', 'raw-css-var-utility', 'Raw CSS variable utility classes are not allowed in generated extension templates.', 'Use eapp-* class tokens or Nuxt UI semantic color props by intent.');
125
+ }
126
+ if (paletteClassPattern.test(source)) {
127
+ push('error', 'hardcoded-tailwind-palette', 'Hardcoded Tailwind palette classes are not allowed in themeable extension UI.', 'Use eapp-surface-*, eapp-primary-*, eapp-status-*, or Nuxt UI semantic colors.');
128
+ }
129
+ if (neutralSemanticClassPattern.test(source)) {
130
+ push('error', 'nuxt-neutral-class', 'Nuxt UI neutral shortcut classes are not part of the extension theme contract.', 'Use eapp-surface-* and eapp-text-* classes instead.');
131
+ }
132
+ if (concreteNuxtColorPattern.test(source)) {
133
+ push('error', 'concrete-nuxt-color', 'Concrete Nuxt UI palette colors are not allowed in generated extension UI.', 'Use color="primary|neutral|success|warning|error|info" by semantic intent.');
134
+ }
135
+ if (/#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})\b/i.test(source) || /\b(?:rgba?|hsla?|oklch|lab|lch)\s*\(/i.test(source)) {
136
+ push('error', 'hardcoded-color-value', 'Hardcoded color values are not allowed in extension UI.', 'Use the Enfyra theme class contract instead of hex/rgb/hsl/oklch/lab/lch values.');
137
+ }
138
+ if (/\bstyle\s*=\s*["'][^"']*(?:color|background(?:-color)?|border-color)\s*:/i.test(source)) {
139
+ push('error', 'inline-color-style', 'Inline color styles bypass the app theme contract.', 'Use eapp-* classes or Nuxt UI semantic props instead of inline color/background/border-color.');
140
+ }
141
+ if (/\bgradient\s*:\s*['"](?!none['"])[^'"]+['"]/.test(source) || /\bgradient\s*=\s*['"](?!none['"])[^'"]+['"]/.test(source)) {
142
+ push('error', 'page-header-gradient', 'Generated operational extension pages must use PageHeader gradient "none" unless the user explicitly requests decoration.', 'Set gradient: "none" in usePageHeaderRegistry or omit decorative gradients.');
143
+ }
144
+ if (/<(?:article|section|div)\b[^>]*class=["'][^"']*(?:eapp-status-(?:success|warning|danger|info)-soft|bg-(?:success|warning|error|info)(?:\b|\/))/i.test(source)) {
145
+ push('warning', 'large-status-surface', 'Status color appears on a large container.', 'Keep large panels neutral and put status color on a compact UBadge/icon/short text inside.');
146
+ }
147
+ const primaryActionCount = (source.match(/\bcolor\s*=\s*["']primary["']/g) || []).length;
148
+ if (primaryActionCount > 2) {
149
+ push('warning', 'primary-overuse', 'Many primary-colored controls were found.', 'Use primary only for the main action or identity accent; use neutral variants for secondary actions.');
150
+ }
151
+ const primarySurfaceCount = (source.match(/\beapp-primary-surface\b/g) || []).length;
152
+ if (primarySurfaceCount > 3) {
153
+ push('warning', 'primary-surface-overuse', 'eapp-primary-surface appears many times.', 'Use eapp-primary-surface only for selected/current identity blocks, not every card in a list/grid.');
154
+ }
155
+ if (/<(?:article|section|div)\b[^>]*class=["'][^"']*\bborder\b(?![^"']*\beapp-divider\b)/i.test(source)) {
156
+ push('warning', 'bare-border-token', 'A bordered panel is missing eapp-divider.', 'Pair intentional borders with eapp-divider so borders follow the app theme contract.');
157
+ }
158
+ return issues;
159
+ }
160
+ export function reviewExtensionThemeContract(code) {
161
+ const issues = collectExtensionThemeIssues(code);
162
+ return {
163
+ action: 'extension_theme_contract_reviewed',
164
+ valid: issues.every((issue) => issue.severity !== 'error'),
165
+ issueCount: issues.length,
166
+ issues,
167
+ nextSteps: issues.length
168
+ ? ['Use build_extension_ui kind=theme_classes to choose classes/props by intent, then patch/update the extension.']
169
+ : ['Snippet matches the checked theme contract rules. Still validate the final SFC before saving.'],
170
+ };
171
+ }
172
+ export function buildExtensionUiSnippet(kind, input = {}) {
173
+ let result;
174
+ switch (kind) {
175
+ case 'drawer':
176
+ result = buildExtensionDrawerSnippet(input);
177
+ break;
178
+ case 'modal':
179
+ result = buildExtensionModalSnippet(input);
180
+ break;
181
+ case 'page_shell':
182
+ result = buildExtensionPageShellSnippet(input);
183
+ break;
184
+ case 'permission_gate':
185
+ result = buildExtensionPermissionGateSnippet(input);
186
+ break;
187
+ case 'empty_state':
188
+ result = buildExtensionEmptyStateSnippet(input);
189
+ break;
190
+ case 'resource_list':
191
+ result = buildExtensionResourceListSnippet(input);
192
+ break;
193
+ case 'resource_grid':
194
+ result = buildExtensionResourceGridSnippet(input);
195
+ break;
196
+ case 'form_editor':
197
+ result = buildExtensionFormEditorSnippet(input);
198
+ break;
199
+ case 'widget':
200
+ result = buildExtensionWidgetSnippet(input);
201
+ break;
202
+ case 'menu_notification':
203
+ result = buildExtensionMenuNotificationSnippet(input);
204
+ break;
205
+ case 'account_panel_item':
206
+ result = buildExtensionAccountPanelSnippet(input);
207
+ break;
208
+ case 'tabs':
209
+ result = buildExtensionTabsSnippet(input);
210
+ break;
211
+ case 'upload_modal':
212
+ result = buildExtensionUploadModalSnippet(input);
213
+ break;
214
+ case 'api_usage':
215
+ result = buildExtensionApiUsageSnippet(input);
216
+ break;
217
+ case 'notify':
218
+ result = buildExtensionNotifySnippet(input);
219
+ break;
220
+ case 'confirm':
221
+ result = buildExtensionConfirmSnippet(input);
222
+ break;
223
+ case 'runtime_review':
224
+ if (!input?.code) {
225
+ throw new Error('build_extension_ui kind=runtime_review requires input.code.');
226
+ }
227
+ result = reviewExtensionRuntimeContract(input.code);
228
+ break;
229
+ case 'theme_classes':
230
+ result = buildExtensionThemeClasses(input);
231
+ break;
232
+ case 'theme_review':
233
+ if (!input?.code) {
234
+ throw new Error('build_extension_ui kind=theme_review requires input.code.');
235
+ }
236
+ result = reviewExtensionThemeContract(input.code);
237
+ break;
238
+ case 'review':
239
+ if (!input?.code) {
240
+ throw new Error('build_extension_ui kind=review requires input.code.');
241
+ }
242
+ const uiReview = reviewExtensionUiContract(input.code, { pattern: input.pattern });
243
+ const themeReview = reviewExtensionThemeContract(input.code);
244
+ const runtimeReview = reviewExtensionRuntimeContract(input.code);
245
+ result = {
246
+ action: 'extension_ui_theme_runtime_contract_reviewed',
247
+ valid: uiReview.valid && themeReview.valid && runtimeReview.valid,
248
+ issueCount: uiReview.issueCount + themeReview.issueCount + runtimeReview.issueCount,
249
+ ui: uiReview,
250
+ theme: themeReview,
251
+ runtime: runtimeReview,
252
+ };
253
+ break;
254
+ default:
255
+ throw new Error(`Unsupported extension UI builder kind: ${kind}`);
256
+ }
257
+ return {
258
+ gateway: 'build_extension_ui',
259
+ kind,
260
+ ...result,
261
+ };
262
+ }
263
+ export function getExtensionThemeContract() {
264
+ return {
265
+ action: 'extension_theme_contract',
266
+ useBefore: [
267
+ 'Call this before writing or reviewing Enfyra admin page, widget, or global extension UI.',
268
+ 'Then call validate_extension_code or an ensure_*_extension tool before saving.',
269
+ ],
270
+ layout: [
271
+ 'The extension is already mounted inside the Enfyra app shell. Do not add a duplicate page header, centered page wrapper, or root-level page padding.',
272
+ 'Page extensions should be full-bleed, responsive, and split large operations into focused pages or UTabs.',
273
+ 'Use usePageHeaderRegistry for the shell title and useHeaderActionRegistry/useSubHeaderActionRegistry for page actions.',
274
+ 'Register dynamic extension header actions inside onMounted after setup refs and handlers exist; build_extension_ui kind=page_shell generates this lifecycle shape.',
275
+ 'Use build_extension_ui kind=menu_notification for sidebar menu notification registration snippets.',
276
+ 'For shell menu notifications, first decide the signal source. Use a count only when the source already owns an exact count, such as a notification summary endpoint or bounded unread-notification query. Use a dot when a realtime event only proves that something new exists. Do not poll a domain list such as messages, tickets, orders, or jobs solely to decorate the menu; the destination page owns domain fetching.',
277
+ 'Use build_extension_ui kind=account_panel_item for account panel row registration snippets.',
278
+ 'For detail/form workflows that should stay left-aligned with empty space on the right, wrap the body in eapp-page-constrained; use eapp-page-constrained-wide only when the workflow genuinely needs more width.',
279
+ 'Card/list grids inside the default shell must account for the 280px desktop sidebar. Do not switch general card grids to three columns at lg; use md:grid-cols-2 xl:grid-cols-3 unless a local container proves three columns have enough width.',
280
+ ],
281
+ theme: [
282
+ 'Do not choose theme classes from memory. Decide the UI intent, then call build_extension_ui kind=theme_classes with that intent to receive the exact class/prop contract.',
283
+ 'Call build_extension_ui kind=theme_review or kind=review before saving extension UI; validate_extension_code and extension write tools also reject hard theme violations.',
284
+ 'Never fix one extension by injecting global CSS, redefining the app palette, or adding theme guards.',
285
+ 'Use get_theme_class_reference only when debugging theme internals or when the user explicitly asks for the full theme/class map.',
286
+ ],
287
+ themeIntents: [
288
+ 'neutral_surface',
289
+ 'muted_surface',
290
+ 'flat_surface',
291
+ 'hover_row',
292
+ 'primary_identity',
293
+ 'primary_soft_icon_tile',
294
+ 'primary_progress',
295
+ 'status_success',
296
+ 'status_warning',
297
+ 'status_danger',
298
+ 'status_info',
299
+ 'primary_action',
300
+ 'secondary_action',
301
+ 'ghost_navigation_action',
302
+ 'danger_action',
303
+ 'divider',
304
+ 'text',
305
+ ],
306
+ components: [
307
+ 'Use Nuxt UI/eApp components for normal controls: UButton, UInput, UTextarea, USelectMenu/USelect, USwitch, UCheckbox, UTabs, UBadge, UModal, and CommonDrawer when available.',
308
+ 'Use auto-injected components directly in the template with PascalCase names. Do not call resolveComponent() to manually resolve Nuxt UI/eApp components inside extension SFCs; it can compile but render unresolved lowercase DOM tags such as <ubutton>.',
309
+ 'Buttons should have stable geometry: hover may change color, border, or shadow but must not move the button or resize its content. Disabled buttons keep disabled cursor/visual state.',
310
+ 'Inputs and textareas should not add hover movement or decorative hover states; focus, invalid, disabled, and loading states must be explicit.',
311
+ 'For drawers, modals, page shell headers/actions, permission gates, empty states, resource lists, resource grids, form editors, widgets, menu/account panel registries, tabs, upload modals, api_usage, notify, and runtime/theming reviews, call build_extension_ui with the matching kind after extension acknowledgement before patching raw Vue.',
312
+ 'Use build_extension_ui kind=theme_classes for theme classes by intent, and kind=runtime_review, theme_review, or review before saving generated snippets that include composables, theme classes, high-contract UI, or native buttons.',
313
+ 'Use build_extension_ui kind=resource_grid for workboards, dashboards, catalogs, and responsive card collections instead of placing UCard children directly into a full-width list frame.',
314
+ 'Use the EmptyState runtime alias returned by build_extension_ui kind=empty_state; CommonEmptyState is not registered as a dynamic extension tag.',
315
+ 'Extension validation rejects UInput, UTextarea, USelect, USelectMenu, UInputMenu, UInputNumber, UInputTags, UInputTime, and UInputDate without class="w-full" unless marked data-compact or data-inline.',
316
+ 'Use UBadge or token-backed badge spans for status. Keep badges legible in both themes with tokenized background, text, and border.',
317
+ ],
318
+ appComposables: [
319
+ 'Call useApi() as a top-level setup composable. It returns data/error/pending/status refs plus execute/refresh; call or await execute()/refresh() from onMounted, watchers, or user actions when the request should run.',
320
+ 'Do not write useNotify shapes from memory. Use build_extension_ui kind=notify for known-good notification snippets. Use build_extension_ui kind=api_usage only when a generated fetch/mutation scaffold is useful.',
321
+ 'Use build_extension_ui kind=runtime_review or kind=review before saving extension code that includes useApi, useNotify, getPackages, or package loading.',
322
+ 'validate_extension_code and extension write tools reject static imports, useToast/useNotify.add misuse, and JSON.stringify useApi options.',
323
+ ],
324
+ shellComponentContracts: {
325
+ CommonDrawer: [
326
+ 'Use build_extension_ui kind=drawer for generated drawer/editing snippets.',
327
+ 'The builder owns slots, managed footer actions, full-width fields, native button types, and loading/error/body structure. CommonDrawer disables drag dismissal globally; do not add handle-only, drag handlers, or swipe-to-close behavior.',
328
+ ],
329
+ CommonModal: [
330
+ 'Use build_extension_ui kind=modal for generated modal/confirmation snippets.',
331
+ 'The builder owns UModal/CommonModal aliasing, slots, managed footer actions, full-width fields, native button types, and modal surface constraints.',
332
+ ],
333
+ PermissionGate: [
334
+ 'Use build_extension_ui kind=permission_gate for generated permission wrapper snippets.',
335
+ 'UI gates are operator UX only; backend route permissions and handler/hook owner checks remain authoritative.',
336
+ ],
337
+ Widget: [
338
+ 'Use build_extension_ui kind=widget for generated widget include snippets.',
339
+ 'The builder owns numeric id usage, reactive prop/event wiring, and page/widget ownership warnings.',
340
+ ],
341
+ actionButtons: [
342
+ 'Use build_extension_ui kind=review for generated snippets with native buttons or theme classes.',
343
+ 'Validation/review catches missing type="button" and high-contract component mistakes before saving.',
344
+ ],
345
+ },
346
+ loadingAndLists: [
347
+ 'For first load of card/list pages, render calm skeleton cards with a slow pulse. Use USkeleton or shared loading components so the app-owned skeleton theme controls contrast and accent matching. For subsequent pagination/filter refreshes, keep the card shells mounted and skeletonize card content until the new list is ready.',
348
+ 'Keep pagination inside the same transition/loading branch as the list. Do not show pagination before the list content has left loading.',
349
+ 'Use bounded pagination for operational lists. Do not replace pagination with arbitrary fixed caps such as 30 or 50.',
350
+ 'Empty states should use an app-matched card surface with compact icon tile, title, and description; do not use huge blank white panels or naked UEmpty chrome on page surfaces.',
351
+ ],
352
+ interaction: [
353
+ 'Every mutating button needs pending/disabled state, success/error feedback, and must close or update its modal when the operation completes.',
354
+ 'Do not refetch broad lists after selecting one row. Keep local selection state and fetch only the detail or mutation result needed.',
355
+ 'Customer-facing toasts must describe the operation. Do not surface raw job ids, flow ids, or worker ids.',
356
+ ],
357
+ security: [
358
+ 'Decide route permission, owner scope, and field exposure before writing UI or backend logic.',
359
+ 'UI checks are only guidance; handlers/hooks must independently enforce owner/root-admin authorization.',
360
+ 'Use the most specific business route or MCP tool. Do not write directly to raw tables when a domain route exists.',
361
+ ],
362
+ shellNotificationContract: {
363
+ menu: 'useMenuNotificationRegistry().register({ id, target: { id?, path?, route? }, value?, color?, title?, order? }). value renders a count/chip; omitting value renders a dot. Parent menus sum numeric child values.',
364
+ accountPanel: 'useAccountPanelRegistry().register({ id, label, description, icon, count?, badge?, badgeColor?, expanded?, onToggle?, contentComponent? }). count is preferred over badge and the account trigger sums numeric visible item counts, capped at 99+.',
365
+ lifecycle: 'Register from global extensions for app-wide notification state; stable ids replace previous registrations and component-owned registrations are removed on unmount.',
366
+ reasoning: 'Counts and dots are different promises. A count says the shell knows an exact or bounded number from an appropriate notification/summary source. A dot says the shell only knows that new attention exists. Avoid fetching the destination domain list just to make a menu badge more precise.',
367
+ },
368
+ };
369
+ }
370
+ export function getThemeClassReference() {
371
+ return {
372
+ action: 'theme_class_reference',
373
+ authority: 'Authoritative Enfyra theme & color contract. Source of truth: documents/app/theme-color-contract.md. App owns color via theme.css + main.css + app.config.ts only; pages/extensions consume classes and Nuxt UI props.',
374
+ baseLayers: {
375
+ material: '--md-* (runtime primary picker, HCT/Material You). Drives identity/brand. Never read directly in templates.',
376
+ status: '--st-success/--st-warning/--st-error/--st-info. Fixed semantic palette. Never read directly in templates.',
377
+ },
378
+ nuxtUiColors: {
379
+ primary: 'runtime --md-primary (main brand action/identity). NEVER substitute a concrete palette.',
380
+ secondary: 'runtime --md-tertiary (intentional secondary accent only).',
381
+ success: '--st-success (healthy/success).',
382
+ warning: '--st-warning (pending/attention).',
383
+ error: 'single --danger-* lane from Material error roles (destructive/error). Ghost danger text uses --danger-on-surface; danger fills use --danger-surface.',
384
+ info: '--st-info (informational).',
385
+ neutral: 'neutral surfaces (secondary chrome, non-actions).',
386
+ },
387
+ classes: [
388
+ { group: 'Surfaces (large ordinary - keep neutral)', classes: 'eapp-surface-card, eapp-surface-muted, eapp-surface-flat, eapp-surface-hover' },
389
+ { group: 'Text', classes: 'eapp-text-primary, eapp-text-secondary, eapp-text-tertiary, eapp-text-quaternary' },
390
+ { group: 'Runtime primary identity', classes: 'eapp-primary-solid, eapp-primary-text, eapp-primary-soft(+hover), eapp-primary-subtle, eapp-primary-surface(+hover), eapp-primary-border, eapp-primary-ring' },
391
+ { group: 'Status (badges/small icons/short text only)', classes: 'eapp-status-{success|warning|danger|info|neutral}-{soft|text|border}' },
392
+ { group: 'Radius', classes: 'eapp-radius-card, eapp-radius-panel, eapp-radius-control, eapp-radius-subcontrol, eapp-radius-pill' },
393
+ { group: 'Icon tile geometry', classes: 'eapp-icon-tile, eapp-icon-tile-sm, eapp-icon-tile-lg' },
394
+ { group: 'Dividers', classes: 'eapp-divider, eapp-divide-y' },
395
+ { group: 'Modal', classes: 'eapp-modal-surface (never surface-card as modal ui.content)' },
396
+ ],
397
+ forbidden: [
398
+ 'Raw CSS variables in templates: text-[var(--*)], bg-[var(--*)], border-[var(--*)].',
399
+ 'Tailwind palette accents: from-cyan-*, text-violet-*, bg-green-*, bg-emerald-*, text-gray-*, bg-slate-*, dark:bg-zinc-950.',
400
+ 'Concrete palette substitution (color="violet"/"cyan"/..., from-cyan-*, text-violet-*, bg-green-*, bg-emerald-*, dark:bg-zinc-950).',
401
+ 'Hardcoded hex colors or inline style="color:#..." for theme-driven surfaces.',
402
+ 'Reading --md-* / --st-* / --badge-* base variables directly from extension templates.',
403
+ ],
404
+ allowedShortUtilities: [
405
+ 'Tailwind v4 short utilities ARE canonical and preferred: bg-primary, text-primary, border-primary, ring-primary, bg-success, text-error, bg-warning, text-info, bg-secondary.',
406
+ 'Opacity modifiers work natively via v4 color-mix: bg-primary/10, ring-primary/20, text-primary/70, bg-success/15.',
407
+ 'Use eapp-* classes only for intent surfaces with no Tailwind equivalent (eapp-primary-surface/solid/soft/subtle, eapp-surface-card/muted/flat/hover, eapp-divider/divide-y, eapp-radius-*, eapp-modal-surface).',
408
+ ],
409
+ chooseByIntent: [
410
+ 'Normal accent / active tab / progress / primary CTA -> primary (eapp-primary-* or color="primary").',
411
+ 'True semantic state -> status (eapp-status-* or color="success|warning|error|info").',
412
+ 'Large ordinary surface -> eapp-surface-*; put a small status badge inside.',
413
+ 'Whole block is active identity -> eapp-primary-surface (+hover), subtle only.',
414
+ ],
415
+ };
416
+ }
417
+ //# sourceMappingURL=extension-theme-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension-theme-contract.js","sourceRoot":"","sources":["../../src/lib/extension-theme-contract.ts"],"names":[],"mappings":"AAqCA,OAAO,EACL,iCAAiC,EACjC,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,EAC/B,qCAAqC,EACrC,0BAA0B,EAC1B,8BAA8B,EAC9B,mCAAmC,EACnC,iCAAiC,EACjC,iCAAiC,EACjC,yBAAyB,EACzB,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AAExC,MAAM,mBAAmB,GAAG;IAC1B,eAAe,EAAE;QACf,OAAO,EAAE,yDA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AAE,sEAAsE,EAAE;YACzI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,oGAAoG,EAAE;YAClI,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,sDAAsD,EAAE;YAChG,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,6BAA6B,EAAE;YAC7D,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,6DAA6D,EAAE;SAC3F;QACD,SAAS,EAAE;YACT,oFAAoF;YACpF,4HAA4H;YAC5H,oIAAoI;YACpI,8EAA8E;YAC9E,uFAAuF;SACxF;QACD,qBAAqB,EAAE;YACrB,+KAA+K;YAC/K,mHAAmH;YACnH,iNAAiN;SAClN;QACD,cAAc,EAAE;YACd,qGAAqG;YACrG,sFAAsF;YACtF,4EAA4E;YAC5E,+EAA+E;SAChF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Enfyra MCP — stdio server (loaded by index.ts / dist/index.js).
3
+ */
4
+ export declare function registerIdentityTools(server: any, ENFYRA_API_URL: any): void;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Enfyra MCP — stdio server (loaded by index.ts / dist/index.js).
3
+ */
4
+ import { z } from 'zod';
5
+ // Import modules
6
+ import { exchangeApiToken, getTokenExpiry, initAuth } from './auth.js';
7
+ import { fetchAPI } from './fetch.js';
8
+ import { jsonContent } from './response-format.js';
9
+ import { DEFAULT_ME_PERMISSION_FIELDS, ENFYRA_API_TOKEN, firstDataRecord, summarizePermissionProfile, } from './enfyra-tool-logic.js';
10
+ export function registerIdentityTools(server, ENFYRA_API_URL) {
11
+ // ============================================================================
12
+ // AUTH & USER TOOLS
13
+ // ============================================================================
14
+ server.tool('get_current_user', 'Get current authenticated user info', {}, async () => {
15
+ const result = await fetchAPI(ENFYRA_API_URL, '/me');
16
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
17
+ });
18
+ server.tool('get_permission_profile', [
19
+ 'Inspect the current token permission profile using the same route-permission model as Enfyra admin UI usePermissions().',
20
+ 'Use this before debugging 403s or before relying on admin helper tools with a non-root API token.',
21
+ 'Reports which MCP tool groups need route permissions such as /admin/script/validate, /admin/test/run, /admin/flow/trigger/:id, and reload endpoints.',
22
+ ].join(' '), {}, async () => {
23
+ const fields = DEFAULT_ME_PERMISSION_FIELDS.join(',');
24
+ const result = await fetchAPI(ENFYRA_API_URL, `/me?fields=${encodeURIComponent(fields)}`);
25
+ const user = firstDataRecord(result);
26
+ return jsonContent(summarizePermissionProfile(user));
27
+ });
28
+ server.tool('get_all_roles', 'Get all role definitions', {}, async () => {
29
+ const result = await fetchAPI(ENFYRA_API_URL, '/enfyra_role?limit=100');
30
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
31
+ });
32
+ server.tool('login', 'Force authentication to Enfyra and get a new access token', {
33
+ apiToken: z.string().optional().describe('API token for MCP and automation'),
34
+ }, async ({ apiToken }) => {
35
+ const token = apiToken || ENFYRA_API_TOKEN;
36
+ if (token) {
37
+ initAuth(ENFYRA_API_URL, token);
38
+ await exchangeApiToken(ENFYRA_API_URL, token);
39
+ const expiry = getTokenExpiry();
40
+ const expiryLabel = expiry === Infinity ? 'no expiration' : new Date(expiry).toISOString();
41
+ return { content: [{ type: 'text', text: `Authenticated with API token.\nToken expires: ${expiryLabel}` }] };
42
+ }
43
+ throw new Error('ENFYRA_API_TOKEN required');
44
+ });
45
+ }
46
+ //# sourceMappingURL=identity-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-tools.js","sourceRoot":"","sources":["../../src/lib/identity-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iBAAiB;AACjB,OAAO,EAAE,gBAAgB,EAAkD,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvH,OAAO,EAAE,QAAQ,EAAqC,MAAM,YAAY,CAAC;AAgCzE,OA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,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,2DAA2D,EAAE;QAChF,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;KAC7E,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,QAAQ,IAAI,gBAAgB,CAAC;QAC3C,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAChC,MAAM,gBAAgB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;YAChC,MAAM,WAAW,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;YAC3F,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iDAAiD,WAAW,EAAE,EAAE,CAAC,EAAE,CAAC;QAC/G,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Enfyra MCP — stdio server (loaded by index.ts / dist/index.js).
3
+ */
4
+ export declare function registerLogTools(server: any, ENFYRA_API_URL: any): void;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Enfyra MCP — stdio server (loaded by index.ts / dist/index.js).
3
+ */
4
+ import { z } from 'zod';
5
+ import { fetchAPI } from './fetch.js';
6
+ export function registerLogTools(server, ENFYRA_API_URL) {
7
+ // ============================================================================
8
+ // LOGS TOOLS
9
+ // ============================================================================
10
+ server.tool('get_log_files', 'List available log files and stats', {}, async () => {
11
+ const result = await fetchAPI(ENFYRA_API_URL, '/logs');
12
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
13
+ });
14
+ server.tool('get_log_content', 'Get content of a specific log file', {
15
+ filename: z.string().describe('Log file name'),
16
+ page: z.number().optional().default(1).describe('Page number'),
17
+ pageSize: z.number().optional().default(100).describe('Lines per page'),
18
+ filter: z.string().optional().describe('Text filter'),
19
+ level: z.string().optional().describe('Log level filter (INFO, WARN, ERROR)'),
20
+ }, async ({ filename, page, pageSize, filter, level }) => {
21
+ const queryParams = new URLSearchParams();
22
+ if (page)
23
+ queryParams.set('page', String(page));
24
+ if (pageSize)
25
+ queryParams.set('pageSize', String(pageSize));
26
+ if (filter)
27
+ queryParams.set('filter', filter);
28
+ if (level)
29
+ queryParams.set('level', level);
30
+ const result = await fetchAPI(ENFYRA_API_URL, `/logs/${filename}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`);
31
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
32
+ });
33
+ server.tool('tail_log', 'Get last N lines from a log file', {
34
+ filename: z.string().describe('Log file name'),
35
+ lines: z.number().optional().default(50).describe('Number of lines to retrieve'),
36
+ }, async ({ filename, lines }) => {
37
+ const result = await fetchAPI(ENFYRA_API_URL, `/logs/${filename}/tail?lines=${lines}`);
38
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
39
+ });
40
+ server.tool('search_logs', 'Search for ERROR or WARN logs across recent log files', {
41
+ level: z.enum(['ERROR', 'WARN', 'INFO']).optional().default('ERROR').describe('Log level'),
42
+ keyword: z.string().optional().describe('Keyword to filter logs'),
43
+ limit: z.number().optional().default(50).describe('Max results per level'),
44
+ }, async ({ level, keyword, limit }) => {
45
+ const logFilesResult = await fetchAPI(ENFYRA_API_URL, '/logs');
46
+ const logFiles = logFilesResult.files || [];
47
+ const recentFiles = logFiles.filter((file) => {
48
+ const name = file?.name || '';
49
+ return /^app[.-]/.test(name) || /^error[.-]/.test(name);
50
+ });
51
+ const results = [];
52
+ for (const file of recentFiles.slice(0, 3)) {
53
+ try {
54
+ const contentResult = await fetchAPI(ENFYRA_API_URL, `/logs/${file.name}?level=${level}&pageSize=${limit}`);
55
+ const lines = contentResult.lines || contentResult.data || [];
56
+ const filteredLines = keyword ? lines.filter(l => JSON.stringify(l).toLowerCase().includes(keyword.toLowerCase())) : lines;
57
+ if (filteredLines.length > 0)
58
+ results.push({ file: file.name, level, logs: filteredLines });
59
+ }
60
+ catch (e) { /* skip */ }
61
+ }
62
+ return { content: [{ type: 'text', text: `Found ${results.length} files:\n${JSON.stringify(results, null, 2)}` }] };
63
+ });
64
+ }
65
+ //# sourceMappingURL=log-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-tools.js","sourceRoot":"","sources":["../../src/lib/log-tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,QAAQ,EAAqC,MAAM,YAAY,CAAC;AAsDzE,MAAM,UAAU,gBAAgB,CAAC,MAAM,EAAE,cAAc;IACrD,+EAA+E;IAC/E,aAAa;IACb,+EAA+E;IAE/E,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,oCAAoC,EAAE,EAAE,EAAE,KAAK,IAAI,EAAE;QAChF,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QACvD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,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