@enfyra/mcp-server 0.0.64 → 0.0.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.
package/package.json
CHANGED
package/src/lib/mcp-examples.js
CHANGED
|
@@ -445,6 +445,39 @@ GET /enfyra/post?filter={"<primaryKeyFromMetadata>":{"_eq":123}}&limit=1`,
|
|
|
445
445
|
'Do not invent deep keys like members unless members is a relation on that table.',
|
|
446
446
|
],
|
|
447
447
|
},
|
|
448
|
+
{
|
|
449
|
+
name: 'Sort parent rows by child relation aggregates',
|
|
450
|
+
code: `query_table({
|
|
451
|
+
tableName: "cloud_support_tickets",
|
|
452
|
+
fields: [
|
|
453
|
+
"id",
|
|
454
|
+
"subject",
|
|
455
|
+
"status",
|
|
456
|
+
"project.id",
|
|
457
|
+
"project.name"
|
|
458
|
+
],
|
|
459
|
+
sort: "-_max(messages.createdAt),-createdAt",
|
|
460
|
+
limit: 25,
|
|
461
|
+
deep: JSON.stringify({
|
|
462
|
+
messages: {
|
|
463
|
+
fields: "id,authorKind,body,createdAt",
|
|
464
|
+
sort: "-createdAt",
|
|
465
|
+
limit: 3
|
|
466
|
+
}
|
|
467
|
+
})
|
|
468
|
+
})
|
|
469
|
+
|
|
470
|
+
// Other parent aggregate sorts:
|
|
471
|
+
// sort=-_count(messages)
|
|
472
|
+
// sort=_min(messages.createdAt)`,
|
|
473
|
+
notes: [
|
|
474
|
+
'Use _max(relation.field) for latest-child ordering, _min(relation.field) for earliest-child ordering, and _count(relation) for child-count ordering.',
|
|
475
|
+
'Aggregate sort helpers only work on direct one-to-many or many-to-many list relations.',
|
|
476
|
+
'The aggregate field must be a real non-encrypted scalar field on the related table.',
|
|
477
|
+
'Do not use raw sort=-messages.createdAt for parent ordering; it is ambiguous and rejected.',
|
|
478
|
+
'deep.messages.sort only orders the loaded message rows inside each ticket, so keep parent sort and child pagination as separate concerns.',
|
|
479
|
+
],
|
|
480
|
+
},
|
|
448
481
|
{
|
|
449
482
|
name: 'Encrypted fields are not lookup fields',
|
|
450
483
|
code: `// Bad: api_token is isEncrypted=true, so filter/sort cannot use it.
|
|
@@ -241,6 +241,8 @@ export function buildMcpServerInstructions(apiBaseUrl) {
|
|
|
241
241
|
'- Use **`discover_query_capabilities`** before building non-trivial filters/deep queries. It returns supported filter operators, field-permission condition operators, deep shape/rules, table columns/relations, table primary key, route paths, and examples.',
|
|
242
242
|
'- Full filter operators: `_eq`, `_neq`, `_gt`, `_gte`, `_lt`, `_lte`, `_in`, `_not_in`, `_nin`, `_contains`, `_starts_with`, `_ends_with`, `_between`, `_is_null`, `_is_not_null`, `_and`, `_or`, `_not`.',
|
|
243
243
|
'- Field permission condition DSL is narrower and does not support `_contains`, `_starts_with`, `_ends_with`, or `_between`.',
|
|
244
|
+
'- Root `sort` accepts local fields such as `-createdAt` plus direct list-relation aggregate helpers: `_count(relationName)`, `_max(relationName.fieldName)`, and `_min(relationName.fieldName)`. Use `-_max(messages.createdAt)` to order parent rows by the latest child row. The relation must be direct `one-to-many` or `many-to-many`, and the aggregate field must be a non-encrypted scalar field on the related table.',
|
|
245
|
+
'- Raw dotted to-many sort such as `messages.createdAt` is invalid for parent ordering. `deep: { messages: { sort: "-createdAt" } }` sorts the loaded child rows inside each parent only; it does not sort the parent list.',
|
|
244
246
|
'- Deep shape: `{ relationName: { fields?, filter?, sort?, limit?, page?, deep? } }`. Relation keys are relation `propertyName`, not physical FK columns.',
|
|
245
247
|
'- Use dotted relation fields such as `owner.email` or `lastMessage.text` when the caller only needs basic related record fields. Use `deep` when relation loading needs query options such as `filter`, `sort`, `limit`, `page`, or nested `deep`. Do not use `deep` for simple relation-id filters, one-row lookup, counts, or large child collections that should be loaded separately with pagination.',
|
|
246
248
|
'- Deep validation rejects unknown relation keys, unknown subkeys, `limit` on many-to-one/one-to-one, and invalid dotted sort through many-side relations.',
|
package/src/mcp-server-entry.mjs
CHANGED
|
@@ -654,7 +654,7 @@ server.tool(
|
|
|
654
654
|
queryParams: {
|
|
655
655
|
fields: 'Comma-separated scalar/relation fields. Relations use relation propertyName, not physical FK column names.',
|
|
656
656
|
filter: 'JSON object using operators above. Relation filters use nested relation propertyName objects.',
|
|
657
|
-
sort: '
|
|
657
|
+
sort: 'Local field or -field. For direct one-to-many/many-to-many parent ordering, use _count(relation), _max(relation.field), or _min(relation.field); raw dotted to-many sort is invalid.',
|
|
658
658
|
page: '1-based page.',
|
|
659
659
|
limit: 'Page size.',
|
|
660
660
|
meta: 'Request metadata/counts where supported.',
|
|
@@ -668,6 +668,7 @@ server.tool(
|
|
|
668
668
|
'Unknown deep entry keys are invalid.',
|
|
669
669
|
'limit on many-to-one/one-to-one relations is invalid.',
|
|
670
670
|
'Dotted sort through one-to-many/many-to-many is invalid.',
|
|
671
|
+
'Deep sort orders rows inside the related collection only; use root aggregate sort helpers when parent rows must be ordered by child values.',
|
|
671
672
|
'Nested deep is recursively validated.',
|
|
672
673
|
'Field permissions may rewrite filters/sorts and sanitize post-query results.',
|
|
673
674
|
],
|