json-object-editor 0.10.505 → 0.10.506
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/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/server/modules/MCP.js +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
- Extracted shared nav to /JsonObjectEditor/_www/mcp-nav.js and used across Test/Export/Privacy/Terms
|
|
35
35
|
- Nav now shows instance name/version/host and links to Privacy/Terms (named windows)
|
|
36
36
|
|
|
37
|
+
506 - Agent context + search count
|
|
38
|
+
- Added concise JOE context block for agent prompts (schema-first decisions, IDs, query strategy, writes, autonomy)
|
|
39
|
+
- search now supports { countOnly: true } to return only a count for large-result checks
|
|
40
|
+
|
|
37
41
|
### 0.10.500
|
|
38
42
|
500 - MCP integration (initial)
|
|
39
43
|
- MCP core module with JSON-RPC 2.0 endpoint (/mcp) protected by auth
|
package/package.json
CHANGED
package/server/modules/MCP.js
CHANGED
|
@@ -91,7 +91,7 @@ MCP.tools = {
|
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
93
|
// Unified search: defaults to cache; set source="storage" to query DB for a schema
|
|
94
|
-
search: async ({ schema, query = {}, ids, source = 'cache', limit = 50, flatten = false, depth = 1 }, _ctx) => {
|
|
94
|
+
search: async ({ schema, query = {}, ids, source = 'cache', limit = 50, flatten = false, depth = 1, countOnly = false }, _ctx) => {
|
|
95
95
|
const useCache = !source || source === 'cache';
|
|
96
96
|
const useStorage = source === 'storage';
|
|
97
97
|
|
|
@@ -113,6 +113,9 @@ MCP.tools = {
|
|
|
113
113
|
if (flatten && JOE && JOE.Utils && JOE.Utils.flattenObject) {
|
|
114
114
|
try { items = ids.map(id => JOE.Utils.flattenObject(id, { recursive: true, depth })); } catch (e) {}
|
|
115
115
|
}
|
|
116
|
+
if (countOnly) {
|
|
117
|
+
return { count: (items || []).length };
|
|
118
|
+
}
|
|
116
119
|
const sliced = (typeof limit === 'number' && limit > 0) ? items.slice(0, limit) : items;
|
|
117
120
|
return { items: sanitizeItems(sliced) };
|
|
118
121
|
}
|
|
@@ -122,6 +125,9 @@ MCP.tools = {
|
|
|
122
125
|
if (!JOE || !JOE.Cache || !JOE.Cache.search) throw new Error('Cache not initialized');
|
|
123
126
|
let results = JOE.Cache.search(query || {});
|
|
124
127
|
if (schema) results = (results || []).filter(i => i && i.itemtype === schema);
|
|
128
|
+
if (countOnly) {
|
|
129
|
+
return { count: (results || []).length };
|
|
130
|
+
}
|
|
125
131
|
const sliced = (typeof limit === 'number' && limit > 0) ? results.slice(0, limit) : results;
|
|
126
132
|
return { items: sanitizeItems(sliced) };
|
|
127
133
|
}
|
|
@@ -129,6 +135,9 @@ MCP.tools = {
|
|
|
129
135
|
if (useStorage) {
|
|
130
136
|
if (!schema) throw new Error("'schema' is required when source=storage");
|
|
131
137
|
const results = await loadFromStorage(schema, query || {});
|
|
138
|
+
if (countOnly) {
|
|
139
|
+
return { count: (results || []).length };
|
|
140
|
+
}
|
|
132
141
|
const sliced = (typeof limit === 'number' && limit > 0) ? (results || []).slice(0, limit) : (results || []);
|
|
133
142
|
if (flatten && JOE && JOE.Utils && JOE.Utils.flattenObject) {
|
|
134
143
|
try { return { items: sanitizeItems(sliced.map(it => JOE.Utils.flattenObject(it && it._id, { recursive: true, depth }))) }; } catch (e) {}
|
|
@@ -225,7 +234,8 @@ MCP.params = {
|
|
|
225
234
|
source: { type: "string", enum: ["cache","storage"] },
|
|
226
235
|
limit: { type: "integer" },
|
|
227
236
|
flatten: { type: "boolean" },
|
|
228
|
-
depth: { type: "integer" }
|
|
237
|
+
depth: { type: "integer" },
|
|
238
|
+
countOnly: { type: "boolean" }
|
|
229
239
|
},
|
|
230
240
|
required: []
|
|
231
241
|
},
|
|
@@ -255,6 +265,7 @@ MCP.returns = {
|
|
|
255
265
|
items: { type: "array", items: { type: "object" } }
|
|
256
266
|
}
|
|
257
267
|
},
|
|
268
|
+
// When countOnly is true, search returns { count }
|
|
258
269
|
saveObject: { type: "object" },
|
|
259
270
|
hydrate: { type: "object" }
|
|
260
271
|
};
|