Skip to content

Commit cab79c7

Browse files
committed
Enhance: query_component with returnProperties (#8326)
1 parent 224fcc7 commit cab79c7

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

ai/mcp/server/neural-link/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,11 @@ components:
12881288
rootId:
12891289
type: string
12901290
description: Optional ID of a component to search within (scoped search).
1291+
returnProperties:
1292+
type: array
1293+
items:
1294+
type: string
1295+
description: "Optional list of properties to return. If provided, returns a lean response (id, className, properties) instead of the full component serialization."
12911296
sessionId:
12921297
type: string
12931298
description: The target App Worker Session ID

src/ai/client/ComponentService.mjs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ class ComponentService extends Service {
154154
* @param {Object} params
155155
* @param {String} [params.rootId]
156156
* @param {Object} params.selector
157+
* @param {String[]} [params.returnProperties]
157158
* @returns {Object}
158159
*/
159-
queryComponent({rootId, selector}) {
160+
queryComponent({rootId, selector, returnProperties}) {
160161
let matches = [];
161162

162163
if (rootId) {
@@ -171,9 +172,24 @@ class ComponentService extends Service {
171172
matches = matches ? [matches] : []
172173
}
173174

174-
return {
175-
components: matches.map(c => c.toJSON())
176-
}
175+
const components = matches.map(c => {
176+
if (returnProperties && Array.isArray(returnProperties) && returnProperties.length > 0) {
177+
const props = {};
178+
returnProperties.forEach(prop => {
179+
props[prop] = this.safeSerialize(c[prop])
180+
});
181+
182+
return {
183+
className : c.className,
184+
id : c.id,
185+
properties: props
186+
}
187+
}
188+
189+
return c.toJSON()
190+
});
191+
192+
return {components}
177193
}
178194

179195
/**

0 commit comments

Comments
 (0)