@enfyra/mcp-server 0.1.63 → 0.1.65

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 (48) hide show
  1. package/README.md +1 -0
  2. package/dist/lib/dynamic-endpoint-contract.js +3 -0
  3. package/dist/lib/dynamic-endpoint-contract.js.map +1 -1
  4. package/dist/lib/extension-search-tools.js +2 -1
  5. package/dist/lib/extension-search-tools.js.map +1 -1
  6. package/dist/lib/extension-sfc-analyzer.d.ts +4 -0
  7. package/dist/lib/extension-sfc-analyzer.js +137 -0
  8. package/dist/lib/extension-sfc-analyzer.js.map +1 -0
  9. package/dist/lib/mcp-examples.js +2 -2
  10. package/dist/lib/mcp-instructions.js +5 -15
  11. package/dist/lib/mcp-instructions.js.map +1 -1
  12. package/dist/lib/mcp-usage-telemetry.js +4 -3
  13. package/dist/lib/mcp-usage-telemetry.js.map +1 -1
  14. package/dist/lib/mutation-guards.d.ts +1 -0
  15. package/dist/lib/mutation-guards.js +28 -0
  16. package/dist/lib/mutation-guards.js.map +1 -1
  17. package/dist/lib/platform-operation-tools.d.ts +159 -3
  18. package/dist/lib/platform-operation-tools.js +361 -78
  19. package/dist/lib/platform-operation-tools.js.map +1 -1
  20. package/dist/lib/required-knowledge.d.ts +10 -3
  21. package/dist/lib/required-knowledge.js +53 -17
  22. package/dist/lib/required-knowledge.js.map +1 -1
  23. package/dist/lib/response-format.js +39 -25
  24. package/dist/lib/response-format.js.map +1 -1
  25. package/dist/lib/runtime-zone-tools.d.ts +14 -0
  26. package/dist/lib/runtime-zone-tools.js +54 -16
  27. package/dist/lib/runtime-zone-tools.js.map +1 -1
  28. package/dist/lib/session-safety.d.ts +9 -0
  29. package/dist/lib/session-safety.js +89 -0
  30. package/dist/lib/session-safety.js.map +1 -0
  31. package/dist/lib/source-artifacts.js +3 -1
  32. package/dist/lib/source-artifacts.js.map +1 -1
  33. package/dist/lib/table-tools.d.ts +5 -0
  34. package/dist/lib/table-tools.js +46 -5
  35. package/dist/lib/table-tools.js.map +1 -1
  36. package/dist/lib/tool-input-normalization.d.ts +4 -0
  37. package/dist/lib/tool-input-normalization.js +35 -0
  38. package/dist/lib/tool-input-normalization.js.map +1 -0
  39. package/dist/lib/tool-routing.d.ts +6 -2
  40. package/dist/lib/tool-routing.js +33 -8
  41. package/dist/lib/tool-routing.js.map +1 -1
  42. package/dist/lib/toolset-filter.d.ts +7 -3
  43. package/dist/lib/toolset-filter.js +144 -86
  44. package/dist/lib/toolset-filter.js.map +1 -1
  45. package/dist/lib/types.d.ts +20 -0
  46. package/dist/mcp-server-entry.js +52 -21
  47. package/dist/mcp-server-entry.js.map +1 -1
  48. package/package.json +4 -1
@@ -1,6 +1,13 @@
1
- export declare const GLOBAL_RULES_ACK_KEY = "EFYRA::GLOBAL-RULES::RUNTIME-ZONES::SCHEMA-DESIGN-CONTEXT::RECORD-BATCH::20260704H";
2
- export declare const DYNAMIC_CODE_KNOWLEDGE_ACK_KEY = "EFYRA::DYNAMIC-REPOSITORY-CONTRACT::RUNTIME-SURFACE-CONTRACTS::20260716D";
3
- export declare const EXTENSION_KNOWLEDGE_ACK_KEY = "EFYRA::EXTENSION-APP-COMPOSABLE-CONTRACT::20260708A";
1
+ export declare const GLOBAL_RULES_ACK_KEY = "EFYRA::GLOBAL-RULES::RUNTIME-ZONE-INVENTORY::SCHEMA-DESIGN-CONTEXT::20260717I";
2
+ export declare const DYNAMIC_CODE_KNOWLEDGE_ACK_KEY = "EFYRA::DYNAMIC-REPOSITORY-CONTRACT::LOCATOR-FIRST::ASYNC-HELPER-BRIDGE::20260717B";
3
+ export declare const EXTENSION_KNOWLEDGE_ACK_KEY = "EFYRA::EXTENSION-APP-COMPOSABLE-CONTRACT::20260716B";
4
+ export declare function resetRequiredKnowledgeSession(): void;
5
+ export declare function getRequiredKnowledgeSessionState(): {
6
+ acknowledgedDomains: string[];
7
+ };
8
+ export declare function acknowledgeRequiredKnowledge(scope?: string): {
9
+ acknowledgedDomains: string[];
10
+ };
4
11
  export declare function globalRulesAckParam(z: any): any;
5
12
  export declare function dynamicCodeKnowledgeAckParam(z: any): any;
6
13
  export declare function extensionKnowledgeAckParam(z: any): any;
@@ -1,18 +1,42 @@
1
- export const GLOBAL_RULES_ACK_KEY = 'EFYRA::GLOBAL-RULES::RUNTIME-ZONES::SCHEMA-DESIGN-CONTEXT::RECORD-BATCH::20260704H';
2
- export const DYNAMIC_CODE_KNOWLEDGE_ACK_KEY = 'EFYRA::DYNAMIC-REPOSITORY-CONTRACT::RUNTIME-SURFACE-CONTRACTS::20260716D';
3
- export const EXTENSION_KNOWLEDGE_ACK_KEY = 'EFYRA::EXTENSION-APP-COMPOSABLE-CONTRACT::20260708A';
4
- const REQUIRED_KNOWLEDGE_VERSION = '2026-07-16.runtime-surface-contracts';
1
+ export const GLOBAL_RULES_ACK_KEY = 'EFYRA::GLOBAL-RULES::RUNTIME-ZONE-INVENTORY::SCHEMA-DESIGN-CONTEXT::20260717I';
2
+ export const DYNAMIC_CODE_KNOWLEDGE_ACK_KEY = 'EFYRA::DYNAMIC-REPOSITORY-CONTRACT::LOCATOR-FIRST::ASYNC-HELPER-BRIDGE::20260717B';
3
+ export const EXTENSION_KNOWLEDGE_ACK_KEY = 'EFYRA::EXTENSION-APP-COMPOSABLE-CONTRACT::20260716B';
4
+ const REQUIRED_KNOWLEDGE_VERSION = '2026-07-17.runtime-zone-inventory-locator-first';
5
+ const acknowledgedDomains = new Set();
6
+ function hasExplicitAckKey(key) {
7
+ return key !== undefined && key !== null;
8
+ }
9
+ export function resetRequiredKnowledgeSession() {
10
+ acknowledgedDomains.clear();
11
+ }
12
+ export function getRequiredKnowledgeSessionState() {
13
+ return {
14
+ acknowledgedDomains: ['globalRules', 'dynamicServerCode', 'extensions']
15
+ .filter((domain) => acknowledgedDomains.has(domain)),
16
+ };
17
+ }
18
+ export function acknowledgeRequiredKnowledge(scope = 'full') {
19
+ const resolvedScope = requireScope(scope);
20
+ acknowledgedDomains.add('globalRules');
21
+ if (resolvedScope === 'full' || resolvedScope === 'dynamic-code' || resolvedScope === 'flow') {
22
+ acknowledgedDomains.add('dynamicServerCode');
23
+ }
24
+ if (resolvedScope === 'full' || resolvedScope === 'extension') {
25
+ acknowledgedDomains.add('extensions');
26
+ }
27
+ return getRequiredKnowledgeSessionState();
28
+ }
5
29
  export function globalRulesAckParam(z) {
6
- return z.string().describe('Required global-rules acknowledgement key from get_enfyra_required_knowledge. Call that tool, read the global Enfyra MCP rules, then pass globalRulesAckKey exactly.');
30
+ return z.string().optional().describe('Backward-compatible explicit acknowledgement key. Omit after get_enfyra_required_knowledge has loaded global rules in this MCP process session.');
7
31
  }
8
32
  export function dynamicCodeKnowledgeAckParam(z) {
9
- return z.string().describe('Required dynamic-code acknowledgement key from get_enfyra_required_knowledge. Call that tool, read the dynamic server code knowledge, then pass dynamicCodeAckKey exactly.');
33
+ return z.string().optional().describe('Backward-compatible explicit acknowledgement key. Omit after get_enfyra_required_knowledge has loaded dynamic-code or flow rules in this MCP process session.');
10
34
  }
11
35
  export function extensionKnowledgeAckParam(z) {
12
- return z.string().describe('Required extension acknowledgement key from get_enfyra_required_knowledge. Call that tool, read the extension/theme knowledge, then pass extensionAckKey exactly.');
36
+ return z.string().optional().describe('Backward-compatible explicit acknowledgement key. Omit after get_enfyra_required_knowledge has loaded extension rules in this MCP process session.');
13
37
  }
14
38
  export function assertGlobalRulesAck(key) {
15
- if (key !== GLOBAL_RULES_ACK_KEY) {
39
+ if (!acknowledgedDomains.has('globalRules') && (!hasExplicitAckKey(key) || key !== GLOBAL_RULES_ACK_KEY)) {
16
40
  throw new Error('Missing or invalid global-rules acknowledgement. Call get_enfyra_required_knowledge, read the global Enfyra MCP rules, then pass globalRulesAckKey as globalRulesAckKey.');
17
41
  }
18
42
  }
@@ -21,7 +45,7 @@ export function assertGlobalRulesAckIf(condition, key) {
21
45
  assertGlobalRulesAck(key);
22
46
  }
23
47
  export function assertDynamicCodeKnowledgeAck(key) {
24
- if (key !== DYNAMIC_CODE_KNOWLEDGE_ACK_KEY) {
48
+ if (!acknowledgedDomains.has('dynamicServerCode') && (!hasExplicitAckKey(key) || key !== DYNAMIC_CODE_KNOWLEDGE_ACK_KEY)) {
25
49
  throw new Error('Missing or invalid dynamic-code knowledge acknowledgement. Call get_enfyra_required_knowledge, read the dynamic server code contracts, then pass dynamicCodeAckKey as knowledgeAckKey.');
26
50
  }
27
51
  }
@@ -30,7 +54,7 @@ export function assertDynamicCodeKnowledgeAckIf(condition, key) {
30
54
  assertDynamicCodeKnowledgeAck(key);
31
55
  }
32
56
  export function assertExtensionKnowledgeAck(key) {
33
- if (key !== EXTENSION_KNOWLEDGE_ACK_KEY) {
57
+ if (!acknowledgedDomains.has('extensions') && (!hasExplicitAckKey(key) || key !== EXTENSION_KNOWLEDGE_ACK_KEY)) {
34
58
  throw new Error('Missing or invalid extension knowledge acknowledgement. Call get_enfyra_required_knowledge, read the extension/theme contracts, then pass extensionAckKey as extensionKnowledgeAckKey.');
35
59
  }
36
60
  }
@@ -69,6 +93,7 @@ const GLOBAL_RULES_SECTIONS = [
69
93
  rules: [
70
94
  'Use search_admin_extensions for menu + extension UI: page extensions, widget extensions, global shell extensions, menu chips, account panel entries, visible buttons, labels, icons, tabs, and blocks.',
71
95
  'Use search_runtime_zone as the zone search/inspect tool for non-admin-UI DB-backed artifacts.',
96
+ 'If the correct zone is unclear, call search_runtime_zone once without zone to receive the compact zone catalog. With a selected zone, omit query/path only for a bounded inventory; add query/path for ranked matching.',
72
97
  'Search first, then inspect with nextInspect.input before editing.',
73
98
  'Use search_runtime_zone with zone=api_runtime for routes, handlers, pre-hooks, post-hooks, guards, guard rules, and route permissions.',
74
99
  'Use search_runtime_zone with zone=flow_runtime for flows and flow steps.',
@@ -85,8 +110,9 @@ const GLOBAL_RULES_SECTIONS = [
85
110
  {
86
111
  id: 'mutations-are-intentional',
87
112
  rules: [
113
+ 'Call get_enfyra_api_context before the first mutation in each MCP process and verify the connected API base. The MCP rejects writes until this target confirmation succeeds.',
88
114
  'Prefer business operation tools over generic CRUD when a specific tool exists.',
89
- 'Destructive operations are preview-first; pass confirm=true only after explicit user approval.',
115
+ 'Destructive operations are preview-first. A confirmed delete must match a successful preview from the same MCP process session; pass confirm=true only after inspecting that preview and receiving explicit user approval.',
90
116
  'Do not manually reload caches unless natural partial reload is proven stale or a concrete reload error requires it.',
91
117
  'Never fabricate ids, field names, relation names, paths, package names, or permission scopes.',
92
118
  ],
@@ -98,6 +124,7 @@ const GLOBAL_RULES_SECTIONS = [
98
124
  'Then call get_enfyra_examples with category=schema-relations only for reasoning patterns, not for domain-specific table names.',
99
125
  'Use plural mutation tools for writes: create_tables/update_tables/delete_tables, create_columns/update_columns/delete_columns, create_relations/delete_relations, and create_records/update_records/delete_records. Pass native JSON arrays; use one item in the array for a single mutation.',
100
126
  'Create entity tables with scalar columns first, then add relations once target tables exist. create_tables defers relation creation until all tables in the same batch exist.',
127
+ 'Enfyra table names are lowercase. create_tables lowercases names and matching same-batch relation targets before writing and reports the normalization; use aliases for human-facing labels.',
101
128
  'Do not declare id, _id, createdAt, or updatedAt columns; Enfyra manages them automatically.',
102
129
  'For one-pass relation-based unique/index constraints, declare the owning relations in the same create_tables item as the constraints. If relations already exist or will be created separately, add those constraints afterward with update_tables.',
103
130
  'Use live Enfyra column types, not SQL dialect names. Common safe choices: varchar for short text, text/richtext for long prose, float for price/amount/rating/decimal-like values, int/bigint for counts, boolean, date/datetime/timestamp, enum, simple-json for structured objects/arrays when listed by live metadata, and code for source fields.',
@@ -106,6 +133,7 @@ const GLOBAL_RULES_SECTIONS = [
106
133
  'If the app must deep-read a parent with child collections, create the child owning relation with inversePropertyName from the start; otherwise parent.deepChild queries will fail until an inverse relation is added.',
107
134
  'When inserting/updating records with relations, use relation propertyName values in the body, not hidden physical FK columns. Inspect the table to learn propertyName values.',
108
135
  'For record writes, always use create_records/update_records/delete_records with native array inputs; these tools validate every item against live metadata before posting/patching/deleting sequentially.',
136
+ 'Generic record CRUD cannot mutate domain-owned structure rows in enfyra_table, enfyra_column, enfyra_relation, or enfyra_route. Use the table/column/relation tools or API endpoint/route tools so physical changes, dependencies, reloads, and previews stay correct.',
109
137
  'For reads, query_table accepts native object filter/deep/aggregate values. Deep keys are relation names; query_table auto-adds missing top-level deep relation keys to fields so nested records can appear. Inside deep, use fields/filter/sort/limit/page/deep; never use _fields.',
110
138
  'Filters use Enfyra operators, not SQL operators. Use _contains, _starts_with, or _ends_with for text matching; do not use _like.',
111
139
  'This auto-add behavior is MCP query_table only. Inside dynamic server scripts, repository find({ deep }) requires the relation property to also be present in top-level fields, otherwise row.<relation> may be undefined.',
@@ -174,6 +202,7 @@ const DYNAMIC_CODE_SECTIONS = [
174
202
  id: 'dynamic-script-shape',
175
203
  rules: [
176
204
  'Use sourceCode and scriptLanguage; never send compiledCode.',
205
+ 'Locate script-backed records with search_runtime_zone and inspect the returned nextInspect.input before source reads. Inspection already returns exact source artifacts; never guess or probe ids with get_script_source.',
177
206
  'Prefer macros such as @BODY, @QUERY, @PARAMS, @USER, @REQ, @RES, @REPOS, @HELPERS, @STORAGE, @SOCKET, and @THROW* when available.',
178
207
  'Call build_dynamic_repository_usage for list, find-one, create, update, or delete code instead of composing secure/trusted repository syntax and result shapes from memory.',
179
208
  'An enfyra_oauth_config sourceCode script runs before a new OAuth user insert, has no authenticated @USER, and must return a plain object of additional user fields. Provider identity fields are merged afterward and take precedence.',
@@ -184,10 +213,13 @@ const DYNAMIC_CODE_SECTIONS = [
184
213
  'Use @REPOS.main for the route main table and #secure.table_name or @REPOS.secure.table_name for explicit user-facing table access. Reserve #table_name/@REPOS.table_name for trusted internal work that intentionally bypasses field permissions.',
185
214
  'When using repository find({ deep }) in handlers/hooks/flows, include each deep relation name in top-level fields, then choose nested fields under deep.<relation>.fields.',
186
215
  'Repository calls are async. Always await secure and trusted repository find/create/update/delete/exists calls; reads return { data: [...], meta? }.',
216
+ 'Every @HELPERS method call crosses the async executor bridge and must be awaited before property access, string interpolation, concatenation, or persistence. Example: const id = await @HELPERS.$crypto.randomUUID().',
187
217
  'Create/update repository calls return collection-shaped data arrays; read result.data?.[0] for a single row.',
188
218
  '@LOGS is a callable function: use @LOGS(message, details?). It has no .info/.warn/.error/.debug methods.',
189
219
  '@SOCKET has no generic emit() method. Bound websocket scripts use reply, emitToCurrentRoom, or broadcastToRoom; global HTTP/flow scripts use emitToGateway, emitToRoom, emitToUser, or broadcast.',
190
220
  'ESV fixed flow step configs are static host-side objects. Do not put @FLOW_PAYLOAD, @FLOW_LAST, or @FLOW inside query/create/update/delete/http/sleep/trigger/log config; use a focused script step when runtime values are required.',
221
+ 'trigger_flow only executes enabled flows. Verify a disabled flow with test_flow_step; enable it explicitly before testing the real queue/runtime trigger path.',
222
+ 'For test_flow_step, pass runtime @FLOW_PAYLOAD values through the payload object. mockFlow is only for advanced $last/$meta flow context.',
191
223
  'For intentional HTTP errors, numeric helpers are raw HTTP message helpers: @THROW400(message), @THROW404(message), @THROW409(message), @THROW422(message, detailsObject?), @THROW500(message).',
192
224
  'When numeric helpers include details, pass an object or array such as @THROW404("Project not found", { id }); do not use @THROW404("Project", id) as a semantic shortcut.',
193
225
  'Use @THROW.http(status, message, details?) for dynamic status codes. Use @THROW.notFound(resource, id?) and @THROW.duplicate(resource, field, value) only when you intentionally want Enfyra-formatted semantic messages.',
@@ -223,14 +255,18 @@ const EXTENSION_SECTIONS = [
223
255
  'Do not call resolveComponent() in extension SFCs. Use auto-injected components such as <UButton>, <UBadge>, <PermissionGate>, and <Widget> directly in the template so the app/compiler resolves them correctly.',
224
256
  'Load app packages with getPackages(["package-name"]) inside extension runtime code.',
225
257
  'For generated high-contract UI in guided mode, call build_extension_ui with the matching kind after reading this acknowledgement; it lazy-dispatches drawer, modal, page shell, permission gate, empty state, resource list, resource grid, form editor, widget, menu notification, account panel item, tabs, upload modal, notify, confirm, runtime review, theme classes, theme review, or full review contracts without loading every builder tool at startup.',
226
- 'For extension useApi code, call build_extension_api_usage with operation=list, find_one, create, update, delete, batch_update, or batch_delete. Do not write useApi path/id/body shapes from memory.',
258
+ 'For extension useApi code in guided mode, call build_extension_ui kind=api_usage with operation=list, find_one, create, update, delete, batch_update, or batch_delete. Do not write useApi path/id/body shapes from memory.',
227
259
  'For an ordinary destructive action, call build_extension_ui kind=confirm. It generates useConfirm() -> accepted mutation -> refresh; do not use window.confirm, window.alert, alert, or prompt. Use CommonModal directly only for richer confirmation content or form fields.',
228
260
  'CommonResourceListFrame is supported in extension runtime and renders its default slot when loading is false and hasItems is true. Do not remove it to speculate about swallowed slots; inspect the source artifact, hasItems/items expressions, and API response shape first.',
229
261
  'Use build_extension_ui kind=resource_grid for workboards, catalogs, dashboards, and card collections. It owns eapp-page-constrained-wide, CommonResourceListFrame variant="plain", one/two/three-column responsive breakpoints, semantic card surfaces, and list loading/empty behavior; use resource_list for dense operational rows.',
262
+ 'For ordinary operator inventories, use build_extension_ui kind=resource_list and review/save with uiPattern="resource_list". Keep search/filter controls in a separate compact surface, constrain the inventory with eapp-page-constrained-wide, and let CommonResourceListFrame own loading, empty, total, and pagination state.',
263
+ 'Use disabled buttons for temporarily unavailable actions, not completed terminal states. Render completed/granted/handled state as a badge or metadata and omit the unavailable action.',
230
264
  'Dynamic extension templates expose the app empty-state component as <EmptyState>, not <CommonEmptyState>. Prefer the empty_state, resource_list, or resource_grid builder instead of writing either tag from memory.',
231
265
  'For theme choices, call build_extension_ui kind=theme_classes with an intent such as neutral_surface, primary_identity, primary_soft_icon_tile, status_success, primary_action, secondary_action, divider, or text instead of inventing classes from memory.',
232
266
  'Use build_extension_ui kind=runtime_review, theme_review, or review before saving generated snippets that include useApi, useNotify, theme classes, drawers, modals, fields, lists, tabs, upload modals, shell registry code, or native buttons.',
233
267
  'For same-version edits to an existing extension, inspect the extension first and use the generated /tmp/enfyra-mcp-sources artifact when snippets are not enough. Edit that artifact and apply its contents with update_extension_code, or use patch_extension_code for a focused exact patch. Do not regenerate the full Vue SFC for a small bug fix, styling adjustment, or contract correction unless the user explicitly asks for a rewrite or version-changing redesign.',
268
+ 'patch_extension_code apply=true requires expectedSha256 and writes a bounded .diff artifact. update_extension_code accepts expectedSha256 for stale full-replacement protection.',
269
+ 'ensure_*_extension, update_extension_code, and patch_extension_code apply=true automatically re-read and verify the exact saved source, expected hash, server compilation, static UI/theme/runtime contracts, and page menu wiring. Use verify_extension_runtime for an additional independent recheck. browserRender=not_run means signed-in browser QA is still required for component execution, live data shape, console errors, and responsive layout.',
234
270
  'Extension validation rejects UInput/UTextarea/USelect/USelectMenu/UInputMenu/UInputNumber/UInputTags/UInputTime/UInputDate without class="w-full" unless the field is explicitly marked data-compact or data-inline.',
235
271
  'PermissionGate is operator UX only; backend route permissions and owner checks remain authoritative.',
236
272
  ],
@@ -239,7 +275,7 @@ const EXTENSION_SECTIONS = [
239
275
  id: 'extension-app-composables',
240
276
  rules: [
241
277
  '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.',
242
- 'Do not write useApi shapes from memory. Call build_extension_api_usage for known-good list/find_one/create/update/delete/batch snippets.',
278
+ 'Do not write useApi shapes from memory. Call build_extension_ui kind=api_usage for known-good list/find_one/create/update/delete/batch snippets.',
243
279
  'Do not write useNotify shapes from memory. Call build_extension_ui kind=notify for known-good notification snippets.',
244
280
  'Call build_extension_ui kind=runtime_review or kind=review before saving extension code that includes useApi, useNotify, getPackages, or package loading.',
245
281
  'Extension validation rejects static imports, useToast/useNotify.add misuse, JSON.stringify useApi options, unused execute aliases, incorrect modal v-model bindings, unavailable runtime aliases, and script-block callbacks that reassign const refs instead of mutating ref.value. Template expressions remain Vue-auto-unwrapped.',
@@ -264,22 +300,22 @@ export function buildRequiredKnowledgePayload(scope = 'full') {
264
300
  purpose: SCOPED_PURPOSES[resolvedScope],
265
301
  includedDomains: ['globalRules', ...(includeDynamic ? ['dynamicServerCode'] : []), ...(includeExtensions ? ['extensions'] : [])],
266
302
  excludedDomains: [...(!includeDynamic ? ['dynamicServerCode'] : []), ...(!includeExtensions ? ['extensions'] : [])],
267
- note: 'Ack keys (globalRulesAckKey, dynamicCodeAckKey, extensionAckKey) are always returned so you can use them when needed. Only domains listed in includedDomains have rules loaded. Domains in excludedDomains have NO rules in this response.',
303
+ note: 'Reading this response acknowledges included domains for the current MCP process session. Write tools accept the returned keys for backward compatibility, but callers may omit them for acknowledged domains. Only includedDomains rules are loaded.',
268
304
  globalRulesAckKey: GLOBAL_RULES_ACK_KEY,
269
305
  dynamicCodeAckKey: DYNAMIC_CODE_KNOWLEDGE_ACK_KEY,
270
306
  extensionAckKey: EXTENSION_KNOWLEDGE_ACK_KEY,
271
307
  usage: [
272
- 'Pass globalRulesAckKey exactly as globalRulesAckKey when calling MCP tools that mutate Enfyra metadata, schema, routes, permissions, menus, packages, cache state, dynamic code, or extension UI.',
308
+ 'After this response, omit globalRulesAckKey in the same MCP process session or pass it explicitly for backward compatibility.',
273
309
  ],
274
310
  globalRules: includeGlobal ? GLOBAL_RULES_SECTIONS : undefined,
275
311
  dynamicServerCode: includeDynamic ? DYNAMIC_CODE_SECTIONS : undefined,
276
312
  extensions: includeExtensions ? EXTENSION_SECTIONS : undefined,
277
313
  };
278
314
  if (includeDynamic) {
279
- payload.usage.push('Pass dynamicCodeAckKey exactly as knowledgeAckKey when calling MCP tools that create or update dynamic server code.');
315
+ payload.usage.push('After this response, omit knowledgeAckKey in the same MCP process session or pass dynamicCodeAckKey explicitly for backward compatibility.');
280
316
  }
281
317
  if (includeExtensions) {
282
- payload.usage.push('Pass extensionAckKey exactly as extensionKnowledgeAckKey when calling MCP tools that create or update Enfyra extension code.');
318
+ payload.usage.push('After this response, omit extensionKnowledgeAckKey in the same MCP process session or pass extensionAckKey explicitly for backward compatibility.');
283
319
  }
284
320
  // Strip undefined keys
285
321
  Object.keys(payload).forEach((k) => {
@@ -1 +1 @@
1
- {"version":3,"file":"required-knowledge.js","sourceRoot":"","sources":["../../src/lib/required-knowledge.ts"],"names":[],"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CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACnH,IAAI,EAAE,sPAAsP;QAC5P,iBAAiB,EAAE,oBAAoB;QACvC,iBAAiB,EAAE,8BAA8B;QACjD,eAAe,EAAE,2BAA2B;QAC5C,KAAK,EAAE;YACL,+HAA+H;SAChI;QACD,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS;QAC9D,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS;QACrE,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS;KAC/D,CAAC;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,4IAA4I,CAAC,CAAC;IACnK,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,mJAAmJ,CAAC,CAAC;IAC1K,CAAC;IAED,uBAAuB;IACvB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACjC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { recordMcpToolUsage } from './mcp-usage-telemetry.js';
2
+ import { afterMcpToolExecution, beforeMcpToolExecution } from './session-safety.js';
2
3
  const RESPONSE_FORMAT = 'json+columnar-v1';
3
4
  const COLUMNAR_FORMAT = 'columnar-v1';
4
5
  const COMPRESSION_STATS_FIELD = 'compressionStats';
@@ -88,19 +89,6 @@ function buildCompressionStats(originalPayload, candidatePayload, selectedPayloa
88
89
  candidateSavedPercent,
89
90
  };
90
91
  }
91
- function attachCompressionStats(originalPayload, candidatePayload, selectedPayload, applied) {
92
- if (!applied)
93
- return selectedPayload;
94
- if (isPlainObject(selectedPayload)
95
- && selectedPayload.responseFormat === RESPONSE_FORMAT
96
- && selectedPayload[COMPRESSION_STATS_FIELD]) {
97
- return selectedPayload;
98
- }
99
- return {
100
- ...selectedPayload,
101
- [COMPRESSION_STATS_FIELD]: buildCompressionStats(originalPayload, candidatePayload, selectedPayload, applied),
102
- };
103
- }
104
92
  function wrapPayload(payload) {
105
93
  if (!isPlainObject(payload)) {
106
94
  return {
@@ -113,11 +101,17 @@ function wrapPayload(payload) {
113
101
  ...payload,
114
102
  };
115
103
  }
116
- export function formatJsonPayload(payload) {
117
- if (isPlainObject(payload)
118
- && payload.responseFormat === RESPONSE_FORMAT
119
- && payload[COMPRESSION_STATS_FIELD]) {
120
- return payload;
104
+ function formatJsonPayloadDetailed(payload) {
105
+ if (isPlainObject(payload) && payload.responseFormat === RESPONSE_FORMAT) {
106
+ const compressionStats = isPlainObject(payload[COMPRESSION_STATS_FIELD])
107
+ ? payload[COMPRESSION_STATS_FIELD]
108
+ : undefined;
109
+ if (compressionStats) {
110
+ const output = { ...payload };
111
+ delete output[COMPRESSION_STATS_FIELD];
112
+ return { payload: output, compressionStats };
113
+ }
114
+ return { payload, compressionStats: undefined };
121
115
  }
122
116
  const originalPayload = wrapPayload(payload);
123
117
  const columnarPayload = wrapPayload(toColumnar(payload));
@@ -125,14 +119,24 @@ export function formatJsonPayload(payload) {
125
119
  const candidateTokens = estimateTokens(safeJsonStringify(columnarPayload));
126
120
  const shouldApplyColumnar = candidateTokens < originalTokens;
127
121
  const selectedPayload = shouldApplyColumnar ? columnarPayload : originalPayload;
128
- return attachCompressionStats(originalPayload, columnarPayload, selectedPayload, shouldApplyColumnar);
122
+ return {
123
+ payload: selectedPayload,
124
+ compressionStats: shouldApplyColumnar
125
+ ? buildCompressionStats(originalPayload, columnarPayload, selectedPayload, true)
126
+ : undefined,
127
+ };
128
+ }
129
+ export function formatJsonPayload(payload) {
130
+ return formatJsonPayloadDetailed(payload).payload;
129
131
  }
130
132
  export function jsonContent(payload, { pretty = false } = {}) {
133
+ const formatted = formatJsonPayloadDetailed(payload);
131
134
  return {
132
135
  content: [{
133
136
  type: 'text',
134
- text: JSON.stringify(formatJsonPayload(payload), null, pretty ? 2 : 0),
137
+ text: JSON.stringify(formatted.payload, null, pretty ? 2 : 0),
135
138
  }],
139
+ ...(formatted.compressionStats ? { _meta: { enfyraCompression: formatted.compressionStats } } : {}),
136
140
  };
137
141
  }
138
142
  function tryParseJson(text) {
@@ -150,21 +154,29 @@ function tryParseJson(text) {
150
154
  }
151
155
  function formatContentItem(item) {
152
156
  if (!item || item.type !== 'text')
153
- return item;
157
+ return { item, compressionStats: undefined };
154
158
  const parsed = tryParseJson(item.text);
155
159
  if (!parsed)
156
- return item;
160
+ return { item, compressionStats: undefined };
161
+ const formatted = formatJsonPayloadDetailed(parsed);
157
162
  return {
158
- ...item,
159
- text: JSON.stringify(formatJsonPayload(parsed)),
163
+ item: {
164
+ ...item,
165
+ text: JSON.stringify(formatted.payload),
166
+ },
167
+ compressionStats: formatted.compressionStats,
160
168
  };
161
169
  }
162
170
  export function formatToolResult(result) {
163
171
  if (!result || !Array.isArray(result.content))
164
172
  return result;
173
+ const formattedItems = result.content.map(formatContentItem);
174
+ const compressionStats = result?._meta?.enfyraCompression
175
+ || formattedItems.find((entry) => entry.compressionStats)?.compressionStats;
165
176
  return {
166
177
  ...result,
167
- content: result.content.map(formatContentItem),
178
+ content: formattedItems.map((entry) => entry.item),
179
+ ...(compressionStats ? { _meta: { ...(result._meta || {}), enfyraCompression: compressionStats } } : {}),
168
180
  };
169
181
  }
170
182
  export function installColumnarToolFormatter(server) {
@@ -176,7 +188,9 @@ export function installColumnarToolFormatter(server) {
176
188
  return registerTool(name, description, schema, async (...args) => {
177
189
  const startedAt = Date.now();
178
190
  try {
191
+ beforeMcpToolExecution(name, args[0]);
179
192
  const result = await handler(...args);
193
+ afterMcpToolExecution(name, args[0]);
180
194
  const formatted = formatToolResult(result);
181
195
  recordMcpToolUsage(name, startedAt, args, formatted);
182
196
  return formatted;
@@ -1 +1 @@
1
- {"version":3,"file":"response-format.js","sourceRoot":"","sources":["../../src/lib/response-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAEnD,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,SAAS,cAAc,CAAC,MAAqB,EAAE,MAAc;IAC3D,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACtF,CAAC;AAED,SAAS,cAAc,CAAC,OAAwB;IAC9C,MAAM,OAAO,GAAG,EAAE,CAAC;IACnB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACtC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACd,OAAO,CAAC,IAA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,CAAC,CAAC,CAAC;gBACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;gBACtC,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBACrC,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAC3C,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;gBACrD,OAAO,SAAS,CAAC;YACnB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBAC5D,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -3,6 +3,20 @@ type RuntimeZone = typeof RUNTIME_ZONES[number];
3
3
  type RuntimeRecord = Record<string, any>;
4
4
  export declare const RUNTIME_ZONE_DESCRIPTIONS: Record<RuntimeZone, string>;
5
5
  export declare function searchRuntimeZone(apiUrl: string, input: any): Promise<{
6
+ action: string;
7
+ zones: {
8
+ name: "admin_ui" | "api_runtime" | "flow_runtime" | "websocket_runtime" | "graphql_runtime" | "schema_data" | "package_runtime" | "storage_file" | "auth_security";
9
+ description: string;
10
+ nextSearch: {
11
+ tool: string;
12
+ input: {
13
+ mode: string;
14
+ zone: "admin_ui" | "api_runtime" | "flow_runtime" | "websocket_runtime" | "graphql_runtime" | "schema_data" | "package_runtime" | "storage_file" | "auth_security";
15
+ };
16
+ };
17
+ }[];
18
+ guidance: string[];
19
+ } | {
6
20
  action: string;
7
21
  zone: string;
8
22
  zoneDescription: string;
@@ -4,6 +4,7 @@ import { fetchMetadataTables, fetchTableCatalog, fetchTableMetadata, fetchTableM
4
4
  import { jsonContent } from './response-format.js';
5
5
  import { writeSourceArtifact } from './source-artifacts.js';
6
6
  import { inspectExtensionLocation, searchExtensions } from './extension-search-tools.js';
7
+ import { normalizeSnippetChars } from './tool-input-normalization.js';
7
8
  const RUNTIME_ZONES = [
8
9
  'admin_ui',
9
10
  'api_runtime',
@@ -67,6 +68,23 @@ export const RUNTIME_ZONE_DESCRIPTIONS = {
67
68
  storage_file: 'Storage configs, folders, files, public file state, and file permissions.',
68
69
  auth_security: 'Users, roles, route/field permissions, guards, OAuth provider provisioning, and linked OAuth accounts.',
69
70
  };
71
+ function buildRuntimeZoneCatalog() {
72
+ return {
73
+ action: 'runtime_zone_catalog',
74
+ zones: RUNTIME_ZONES.map((name) => ({
75
+ name,
76
+ description: RUNTIME_ZONE_DESCRIPTIONS[name],
77
+ nextSearch: {
78
+ tool: 'search_runtime_zone',
79
+ input: { mode: 'search', zone: name },
80
+ },
81
+ })),
82
+ guidance: [
83
+ 'Choose one returned zone and call its nextSearch input.',
84
+ 'Add query or path when you know a target. Keep them omitted for a bounded zone inventory.',
85
+ ],
86
+ };
87
+ }
70
88
  function getId(record) {
71
89
  return record?.id ?? record?._id ?? null;
72
90
  }
@@ -266,11 +284,24 @@ function summarizeGenericRecord(zone, table, record, matches, includeSourceArtif
266
284
  async function searchSchemaZone(apiUrl, input) {
267
285
  const query = String(input.query ?? '').trim();
268
286
  const normalizedQuery = normalizeText(query);
287
+ const inventory = !normalizedQuery;
269
288
  const maxResults = Math.min(Math.max(Number(input.maxResults ?? 8), 1), 25);
270
289
  const catalog = await fetchTableCatalog(apiUrl);
271
290
  const tables = await fetchMetadataTables(apiUrl, catalog);
272
291
  const results = [];
273
292
  for (const table of tables) {
293
+ if (inventory) {
294
+ results.push({
295
+ zone: 'schema_data',
296
+ tableName: table.name,
297
+ id: getId(table),
298
+ alias: table.alias,
299
+ score: 0,
300
+ matches: [],
301
+ nextInspect: { tool: 'search_runtime_zone', input: { mode: 'inspect', zone: 'schema_data', tableName: table.name } },
302
+ });
303
+ continue;
304
+ }
274
305
  const tableMatches = [];
275
306
  for (const field of ['name', 'alias', 'description']) {
276
307
  const raw = flattenValue(table?.[field]);
@@ -304,7 +335,7 @@ async function searchSchemaZone(apiUrl, input) {
304
335
  }
305
336
  results.sort((a, b) => b.score - a.score || String(a.tableName).localeCompare(String(b.tableName)));
306
337
  return {
307
- action: 'runtime_zone_searched',
338
+ action: inventory ? 'runtime_zone_inventory' : 'runtime_zone_searched',
308
339
  zone: 'schema_data',
309
340
  zoneDescription: RUNTIME_ZONE_DESCRIPTIONS.schema_data,
310
341
  query,
@@ -314,12 +345,15 @@ async function searchSchemaZone(apiUrl, input) {
314
345
  };
315
346
  }
316
347
  export async function searchRuntimeZone(apiUrl, input) {
348
+ const zone = input.zone;
349
+ if (!zone)
350
+ return buildRuntimeZoneCatalog();
317
351
  if ((input.mode ?? 'search') === 'inspect')
318
352
  return inspectRuntimeZoneLocation(apiUrl, input);
319
- const zone = input.zone;
320
353
  if (!RUNTIME_ZONES.includes(zone))
321
354
  throw new Error(`Unsupported runtime zone: ${zone}`);
322
355
  if (zone === 'admin_ui') {
356
+ const inventory = !String(input.query ?? '').trim() && !String(input.path ?? '').trim();
323
357
  const adminResult = await searchExtensions(apiUrl, {
324
358
  query: input.query,
325
359
  path: input.path,
@@ -328,11 +362,11 @@ export async function searchRuntimeZone(apiUrl, input) {
328
362
  maxResults: input.maxResults,
329
363
  snippetChars: input.snippetChars,
330
364
  maxMatchesPerExtension: input.maxMatchesPerRecord,
331
- includeSourceArtifact: input.includeSourceArtifact,
365
+ includeSourceArtifact: inventory ? false : input.includeSourceArtifact,
332
366
  });
333
367
  return {
334
368
  ...adminResult,
335
- action: 'runtime_zone_searched',
369
+ action: inventory ? 'runtime_zone_inventory' : 'runtime_zone_searched',
336
370
  zone,
337
371
  zoneDescription: RUNTIME_ZONE_DESCRIPTIONS.admin_ui,
338
372
  results: (adminResult.results ?? []).map((item) => ({
@@ -348,12 +382,11 @@ export async function searchRuntimeZone(apiUrl, input) {
348
382
  if (zone === 'schema_data')
349
383
  return searchSchemaZone(apiUrl, input);
350
384
  const query = String(input.query ?? input.path ?? '').trim();
351
- if (!query)
352
- throw new Error('query or path is required for this runtime zone.');
353
385
  const path = input.path ? String(input.path).trim() : '';
386
+ const inventory = !query && !path;
354
387
  const maxResults = Math.min(Math.max(Number(input.maxResults ?? 8), 1), 25);
355
- const snippetChars = Math.min(Math.max(Number(input.snippetChars ?? 180), 120), 600);
356
- const includeSourceArtifact = Boolean(input.includeSourceArtifact);
388
+ const snippetChars = normalizeSnippetChars(input.snippetChars);
389
+ const includeSourceArtifact = inventory ? false : Boolean(input.includeSourceArtifact);
357
390
  const tables = ZONE_TABLES[zone];
358
391
  const allResults = [];
359
392
  const errors = [];
@@ -364,6 +397,10 @@ export async function searchRuntimeZone(apiUrl, input) {
364
397
  continue;
365
398
  }
366
399
  for (const record of records) {
400
+ if (inventory) {
401
+ allResults.push(summarizeGenericRecord(zone, table, record, [], false));
402
+ continue;
403
+ }
367
404
  if (path) {
368
405
  const pathHit = (table.pathFields ?? []).some((field) => flattenValue(valueAt(record, field)) === path);
369
406
  if (!pathHit)
@@ -381,7 +418,7 @@ export async function searchRuntimeZone(apiUrl, input) {
381
418
  allResults.sort((a, b) => b.score - a.score || String(a.tableName).localeCompare(String(b.tableName)));
382
419
  const results = allResults.slice(0, maxResults);
383
420
  return {
384
- action: 'runtime_zone_searched',
421
+ action: inventory ? 'runtime_zone_inventory' : 'runtime_zone_searched',
385
422
  zone,
386
423
  zoneDescription: RUNTIME_ZONE_DESCRIPTIONS[zone],
387
424
  query: query || null,
@@ -396,6 +433,7 @@ export async function searchRuntimeZone(apiUrl, input) {
396
433
  },
397
434
  guidance: [
398
435
  'Use the returned nextInspect input on search_runtime_zone(mode=inspect) for the best candidate before editing.',
436
+ ...(inventory ? ['This is a bounded inventory. Add query or path when you need ranked matching.'] : []),
399
437
  'Use source artifacts only for the selected candidate when snippets are insufficient.',
400
438
  'Use zone-specific write tools after inspection instead of generic CRUD when a business operation tool exists.',
401
439
  ],
@@ -560,7 +598,7 @@ export async function inspectRuntimeZoneLocation(apiUrl, input) {
560
598
  sources,
561
599
  nextSteps: [
562
600
  'Use zone-specific edit tools where available.',
563
- 'For source edits, use get_script_source/patch_script_source/update_script_source when the table is script-backed.',
601
+ 'When sources are returned, use those exact artifacts. Call get_script_source only with this concrete record id when a fresh source artifact is needed.',
564
602
  'Re-run search_runtime_zone or the specific inspector after mutation.',
565
603
  ],
566
604
  };
@@ -578,7 +616,7 @@ export function registerRuntimeZoneTools(server, ENFYRA_API_URL) {
578
616
  type: z.enum(['page', 'widget', 'global']).optional().describe('Narrows extension type.'),
579
617
  includeDisabled: z.boolean().optional().default(true),
580
618
  maxResults: z.number().int().min(1).max(25).optional().default(8),
581
- snippetChars: z.number().int().min(120).max(600).optional().default(180),
619
+ snippetChars: z.number().int().optional().default(180).transform(normalizeSnippetChars).describe('Approximate snippet characters per match. Values outside 120-600 are clamped.'),
582
620
  includeSourceArtifact: z.boolean().optional().default(false),
583
621
  }, async (input) => jsonContent(await searchAdminExtensions(ENFYRA_API_URL, input)));
584
622
  server.tool('debug_field_exposure', [
@@ -597,11 +635,11 @@ export function registerRuntimeZoneTools(server, ENFYRA_API_URL) {
597
635
  server.tool('search_runtime_zone', [
598
636
  'Single zone-scoped search/inspect tool for DB-backed Enfyra runtime artifacts.',
599
637
  'Use this before editing anything that lives in the database rather than repo files.',
600
- 'Choose a zone first so the output stays precise and token-bounded. Use mode=search first, then call this same tool with mode=inspect using nextInspect.input.',
638
+ 'Omit zone once when the correct zone is unclear; the tool returns a compact zone catalog. With a zone, omit query/path for bounded inventory or provide either value for ranked matching. Then call mode=inspect using nextInspect.input.',
601
639
  ].join(' '), {
602
- mode: z.enum(['search', 'inspect']).optional().default('search').describe('search returns ranked matches. inspect opens one result using tableName/id or admin UI name/path/query.'),
603
- zone: z.enum(RUNTIME_ZONES).describe('DB-backed runtime zone to search. admin_ui=menu/extensions, api_runtime=routes/handlers/hooks/guards, flow_runtime=flows, websocket_runtime=socket gateways/events, graphql_runtime=GraphQL, schema_data=tables/fields/relations, package_runtime=packages, storage_file=storage/files, auth_security=access/auth.'),
604
- query: z.string().optional().describe('Visible label, path, event name, flow step key, route path, source-code term, field name, package name, or config keyword.'),
640
+ mode: z.enum(['search', 'inspect']).optional().default('search').describe('search returns a zone catalog, bounded inventory, or ranked matches. inspect opens one result using nextInspect.input.'),
641
+ zone: z.enum(RUNTIME_ZONES).optional().describe('DB-backed runtime zone. Omit only when the correct zone is unclear; the result returns the zone catalog. admin_ui=menu/extensions, api_runtime=routes/handlers/hooks/guards, flow_runtime=flows, websocket_runtime=socket gateways/events, graphql_runtime=GraphQL, schema_data=tables/fields/relations, package_runtime=packages, storage_file=storage/files, auth_security=access/auth.'),
642
+ query: z.string().optional().describe('Visible label, path, event name, flow step key, route path, source-code term, field name, package name, or config keyword. Omit with a selected zone for bounded inventory.'),
605
643
  path: z.string().optional().describe('Exact route/gateway/menu/file path where the zone supports path lookup.'),
606
644
  tableName: z.string().optional().describe('Required for mode=inspect on non-admin zones; use nextInspect.input from search results.'),
607
645
  id: z.union([z.string(), z.number()]).optional().describe('Record id for mode=inspect; use nextInspect.input from search results.'),
@@ -609,7 +647,7 @@ export function registerRuntimeZoneTools(server, ENFYRA_API_URL) {
609
647
  extensionType: z.enum(['page', 'widget', 'global']).optional().describe('Only for admin_ui zone. Narrows extension type.'),
610
648
  includeDisabled: z.boolean().optional().default(true).describe('Only for admin_ui zone. Include disabled extensions.'),
611
649
  maxResults: z.number().int().min(1).max(25).optional().default(8).describe('Maximum ranked results.'),
612
- snippetChars: z.number().int().min(120).max(600).optional().default(180).describe('Approximate snippet characters per match.'),
650
+ snippetChars: z.number().int().optional().default(180).transform(normalizeSnippetChars).describe('Approximate snippet characters per match. Values outside 120-600 are clamped.'),
613
651
  maxMatchesPerRecord: z.number().int().min(1).max(8).optional().default(2).describe('Only for admin_ui zone. Maximum source matches per extension.'),
614
652
  includeSourceArtifact: z.boolean().optional().default(false).describe('Write matched source to /tmp and return compact source artifact metadata. Prefer false unless snippets are insufficient.'),
615
653
  }, async (input) => jsonContent(await searchRuntimeZone(ENFYRA_API_URL, input)));