@enfyra/mcp-server 0.0.88 → 0.0.89

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.
package/README.md CHANGED
@@ -216,7 +216,7 @@ The MCP server includes safety guards for LLM callers:
216
216
 
217
217
  ## Query Notes
218
218
 
219
- Use explicit `fields` in read tools. Include mode is the default, such as `fields=id,email`. Any excluded field switches that scope to exclude mode: `fields=-compiledCode` returns all readable fields except `compiledCode`, and `fields=id,-compiledCode` still means all except `compiledCode`. Dotted exclusions such as `fields=-owner.avatar` work for relation fields when the relation exists in metadata.
219
+ Use explicit `fields` in read tools. Include mode is the default, such as `fields=id,email`. Any excluded field switches that scope to exclude mode: `fields=-compiledCode` returns all readable fields except `compiledCode`, and `fields=id,-compiledCode` still means all except `compiledCode`. Dotted exclusions such as `fields=-owner.avatar` work for relation fields when the relation exists in metadata. Every list/query call must pass either `limit` for a bounded page or `all: true` for a complete list. When a caller needs every matching row, pass `all: true` to `query_table` or `get_all_routes`; the tool sends REST `limit=0` instead of making the model choose an arbitrary page size like 30 or 50.
220
220
 
221
221
  ## Enfyra URL Pattern
222
222
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enfyra/mcp-server",
3
- "version": "0.0.88",
3
+ "version": "0.0.89",
4
4
  "description": "MCP server for Enfyra - manage Enfyra instances from MCP-compatible coding tools",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -375,15 +375,20 @@ create_column({
375
375
  'Always pass fields when you need more than ids; query_table without fields intentionally returns only the primary key.',
376
376
  'Use inspect_table first when you do not know valid column names or relation propertyName values.',
377
377
  'Use count_records when only the count is needed.',
378
+ 'When the user asks for all matching rows, pass all: true instead of choosing an arbitrary page size such as 30 or 50.',
378
379
  ],
379
380
  },
380
381
  {
381
382
  name: 'List current user conversations through RLS',
382
- code: `GET /enfyra/chat_conversation?fields=id,kind,title,lastMessage.id,lastMessage.text,lastMessage.createdAt&limit=0`,
383
+ code: `query_table({
384
+ tableName: "chat_conversation",
385
+ fields: ["id", "kind", "title", "lastMessage.id", "lastMessage.text", "lastMessage.createdAt"],
386
+ all: true
387
+ })`,
383
388
  notes: [
384
389
  'Use a conversation read pre-hook/RLS boundary so the route only returns conversations visible to @USER.',
385
390
  'lastMessage is a relation to chat_message; do not duplicate preview fields on chat_conversation.',
386
- 'limit=0 means load all matching conversation rows.',
391
+ 'all: true tells MCP to send REST limit=0 and load all matching conversation rows.',
387
392
  'Do not fetch messages for every conversation on initial list load; load messages after selecting a conversation.',
388
393
  ],
389
394
  },
@@ -38,7 +38,7 @@ export function buildMcpServerInstructions(apiBaseUrl) {
38
38
  '- If generating concrete code, schema payloads, SSR app config, OAuth wiring, Socket.IO clients/events, flows, files, extensions, or permission/RLS examples, call **`get_enfyra_examples`** for the matching category before writing the final answer. Examples are grouped by category and are intentionally more concrete than these global rules.',
39
39
  '- Treat hardcoded instructions as operating rules, but use live discovery as the final check for this running instance. Do not infer missing capabilities from a narrow tool schema; check metadata/routes or the relevant specialized tool first.',
40
40
  '- If there is no dedicated MCP tool for a subsystem, use the route-backed metadata table with `query_table` / `create_record` / `update_record` / `delete_record`, after confirming that table has a route. If the table is no-route, use the canonical specialized tool or parent table workflow instead.',
41
- '- MCP read tools are intentionally **minimal by default**. `query_table` without `fields` returns only the table primary key with a small hint. Always pass explicit `fields` when you need details, and use `inspect_table` / `inspect_route` before guessing field names.',
41
+ '- MCP read tools are intentionally **minimal by default**. `query_table` without `fields` returns only the table primary key with a small hint. Always pass explicit `fields` when you need details, and use `inspect_table` / `inspect_route` before guessing field names. Every list/query call must explicitly pass either `limit` for a bounded page or `all: true` for a complete list. When the user asks for all matching rows, pass `all: true` instead of inventing arbitrary limits such as 30 or 50.',
42
42
  '- MCP mutation tools return only ids/status by default. If you need the saved row, immediately call `find_one_record` or `query_table` with explicit `fields`; do not expect create/update tools to echo full records.',
43
43
  '- **Operator posture:** act from the Enfyra contracts encoded here and in live metadata. Do not turn normal implementation details into speculative warnings. Ask the user only when a new design/product decision is needed, when metadata is genuinely ambiguous, or when a tool/runtime result proves a concrete problem. If a behavior is expected by contract, state it as expected behavior or omit it; do not present it as an audit finding.',
44
44
  '',
@@ -1012,17 +1012,24 @@ server.tool(
1012
1012
  },
1013
1013
  );
1014
1014
 
1015
- server.tool('query_table', 'Query any route-backed table. Default response is minimal; pass fields explicitly for detail.', {
1015
+ server.tool('query_table', 'Query any route-backed table. Response is minimal unless fields is explicit. Every call must pass either limit or all=true.', {
1016
1016
  tableName: z.string().describe('Table name to query'),
1017
1017
  filter: z.string().optional().describe('Filter object as JSON string. Examples: \'{"status": {"_eq": "active"}}\''),
1018
1018
  sort: z.string().optional().describe('Sort field. Prefix with - for descending (e.g., "createdAt", "-id")'),
1019
1019
  page: z.number().optional().describe('Page number (default: 1)'),
1020
- limit: z.number().optional().describe('Items per page. Default: 10. Use count_records for counts.'),
1020
+ limit: z.number().int().min(0).optional().describe('Items per page. Required unless all=true. Do not invent arbitrary limits for "all"; use all=true instead. Use count_records for counts.'),
1021
+ all: z.boolean().optional().default(false).describe('Return all matching rows by sending REST limit=0. Use this when the user asks for all rows or a complete list.'),
1021
1022
  fields: z.array(z.string()).optional().describe('Fields to select. If omitted, MCP selects only the table primary key to avoid oversized responses.'),
1022
1023
  meta: z.string().optional().describe('Optional REST meta request, e.g. "totalCount", "filterCount", or aggregate modes supported by the route. Use count_records for simple counts.'),
1023
1024
  deep: z.string().optional().describe('Optional deep relation fetch object as JSON string. Keys must be relation propertyName values.'),
1024
1025
  aggregate: z.string().optional().describe('Optional aggregate object as JSON string, keyed by real fields/relations. Results are returned in response.meta.aggregate when supported.'),
1025
- }, async ({ tableName, filter, sort, page, limit, fields, meta, deep, aggregate }) => {
1026
+ }, async ({ tableName, filter, sort, page, limit, all, fields, meta, deep, aggregate }) => {
1027
+ if (!all && limit === undefined) {
1028
+ throw new Error('query_table requires either limit or all=true. Do not rely on implicit default page sizes.');
1029
+ }
1030
+ if (all && limit !== undefined) {
1031
+ throw new Error('query_table accepts either all=true or limit, not both.');
1032
+ }
1026
1033
  validateTableName(tableName);
1027
1034
  validateFilter(filter);
1028
1035
  parseJsonArg(deep, undefined);
@@ -1036,7 +1043,8 @@ server.tool('query_table', 'Query any route-backed table. Default response is mi
1036
1043
  if (meta) queryParams.set('meta', meta);
1037
1044
  if (deep) queryParams.set('deep', deep);
1038
1045
  if (aggregate) queryParams.set('aggregate', aggregate);
1039
- queryParams.set('limit', String(limit || 10));
1046
+ const effectiveLimit = all ? 0 : limit;
1047
+ queryParams.set('limit', String(effectiveLimit));
1040
1048
  queryParams.set('fields', selectedFields.join(','));
1041
1049
 
1042
1050
  const query = queryParams.toString();
@@ -1046,7 +1054,8 @@ server.tool('query_table', 'Query any route-backed table. Default response is mi
1046
1054
  success: result?.success,
1047
1055
  tableName,
1048
1056
  fields: selectedFields,
1049
- limit: limit || 10,
1057
+ limit: effectiveLimit,
1058
+ all: !!all,
1050
1059
  queryOptions: {
1051
1060
  meta: meta || null,
1052
1061
  deep: deep ? parseJsonArg(deep, null) : null,
@@ -2014,11 +2023,18 @@ server.tool(
2014
2023
  },
2015
2024
  );
2016
2025
 
2017
- server.tool('get_all_routes', 'List route definitions with minimal fields. Call inspect_route for handlers/hooks/permissions detail.', {
2026
+ server.tool('get_all_routes', 'List route definitions with minimal fields. Every call must pass either limit or all=true. Call inspect_route for handlers/hooks/permissions detail.', {
2018
2027
  includeDisabled: z.boolean().optional().default(false).describe('Include disabled routes'),
2019
2028
  search: z.string().optional().describe('Optional path or table substring filter. Use this before creating a route to check duplicates.'),
2020
- limit: z.number().optional().describe('Maximum routes returned after search. Default 50 to keep response small.'),
2021
- }, async ({ includeDisabled, search, limit }) => {
2029
+ limit: z.number().int().positive().optional().describe('Maximum routes returned after search. Required unless all=true. Do not invent arbitrary limits for "all"; use all=true instead.'),
2030
+ all: z.boolean().optional().default(false).describe('Return all matched routes. Use this when the user asks for all routes or a complete route list.'),
2031
+ }, async ({ includeDisabled, search, limit, all }) => {
2032
+ if (!all && limit === undefined) {
2033
+ throw new Error('get_all_routes requires either limit or all=true. Do not rely on implicit default page sizes.');
2034
+ }
2035
+ if (all && limit !== undefined) {
2036
+ throw new Error('get_all_routes accepts either all=true or limit, not both.');
2037
+ }
2022
2038
  const filter = includeDisabled ? {} : { isEnabled: { _eq: true } };
2023
2039
  const queryParams = new URLSearchParams({
2024
2040
  filter: JSON.stringify(filter),
@@ -2026,7 +2042,6 @@ server.tool('get_all_routes', 'List route definitions with minimal fields. Call
2026
2042
  limit: '1000',
2027
2043
  });
2028
2044
  const result = await fetchAPI(ENFYRA_API_URL, `/enfyra_route?${queryParams.toString()}`);
2029
- const routeLimit = limit || 50;
2030
2045
  const q = search ? search.toLowerCase() : null;
2031
2046
  const allRoutes = summarizeRoutes(result);
2032
2047
  const matchedRoutes = q
@@ -2035,12 +2050,14 @@ server.tool('get_all_routes', 'List route definitions with minimal fields. Call
2035
2050
  mainTable: route.mainTable,
2036
2051
  }).toLowerCase().includes(q))
2037
2052
  : allRoutes;
2053
+ const routeLimit = all ? matchedRoutes.length : limit;
2038
2054
  const payload = {
2039
2055
  statusCode: result?.statusCode,
2040
2056
  success: result?.success,
2041
2057
  totalRouteCount: allRoutes.length,
2042
2058
  matchedRouteCount: matchedRoutes.length,
2043
2059
  returnedRouteCount: Math.min(matchedRoutes.length, routeLimit),
2060
+ all: !!all,
2044
2061
  search: search || null,
2045
2062
  routes: matchedRoutes.slice(0, routeLimit),
2046
2063
  detailHint: matchedRoutes.length > routeLimit