@spacelr/mcp 0.0.10 → 0.0.11

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/dist/index.mjs CHANGED
@@ -1448,6 +1448,40 @@ function registerDatabaseTools(server, api) {
1448
1448
  }
1449
1449
  }
1450
1450
  );
1451
+ server.registerTool(
1452
+ "database_documents_search",
1453
+ {
1454
+ description: "Server-side substring search across named fields of a collection. The query is regex-escaped and case-insensitive. Uses unanchored MongoDB $regex per field \u2014 consider adding a filter to narrow the scan on large collections. Max 10 fields, max 100 results. Runs with admin privileges (bypasses .read rules); use the SDK search() for tenant-scoped rule-gated search.",
1455
+ inputSchema: {
1456
+ projectId: z4.string(),
1457
+ collectionName: z4.string(),
1458
+ query: z4.string().min(1).max(200),
1459
+ fields: z4.array(z4.string().regex(/^[a-zA-Z0-9_.]+$/).max(64)).min(1).max(10),
1460
+ filter: z4.record(z4.string(), z4.unknown()).optional(),
1461
+ sort: z4.record(z4.string(), z4.union([z4.literal(1), z4.literal(-1)])).optional(),
1462
+ limit: z4.number().int().min(1).max(100).optional(),
1463
+ offset: z4.number().int().min(0).optional(),
1464
+ select: z4.array(z4.string()).optional()
1465
+ }
1466
+ },
1467
+ async ({ projectId, collectionName, ...body }) => {
1468
+ try {
1469
+ const result = await api.post(
1470
+ `/databases/${encodeURIComponent(projectId)}/collections/${encodeURIComponent(collectionName)}/documents/search`,
1471
+ { body }
1472
+ );
1473
+ return {
1474
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
1475
+ };
1476
+ } catch (error) {
1477
+ const message = error instanceof Error ? error.message : String(error);
1478
+ return {
1479
+ content: [{ type: "text", text: `Failed to search documents: ${message}` }],
1480
+ isError: true
1481
+ };
1482
+ }
1483
+ }
1484
+ );
1451
1485
  server.registerTool(
1452
1486
  "database_documents_insert",
1453
1487
  {