Refine MCP skills: align search-assets/sdk-reference with assets.list overload; drop webhooks#3
Refine MCP skills: align search-assets/sdk-reference with assets.list overload; drop webhooks#3imagekitio wants to merge 9 commits into
Conversation
… and imagekit-plugin chore(mcp): fix API URL in mcp configuration docs(README): add imagekit-sdk-reference skill to documentation chore(skills): include imagekit-sdk-reference in skills list
…e type gotchas - Add search-assets skill: searchQuery filter syntax, operators, and field reference for client.assets.list() - Add imagekit-integrations skill: index of ImageKit SDKs, plugins, and integrations - Register both new skills under the General grouping in skills.sh.json - imagekit-sdk-reference: add TypeScript Gotchas section explaining why .filter() with `item is File` fails in MCP/Deno (global File shadows SDK File); recommend for...of + if narrowing; document nullable props, .find() undefined, and webhook discrimination - mcp-preflight: clarify execute tool description and upload routing wording
…ebhooks from MCP skill
…atch only to branch + re-throw)
…archQuery), not 'always searchQuery'
| ``` | ||
|
|
||
| This returns the configured fields with their `name`, `type`, and any allowed values — use it to build a valid `searchQuery` (see the `search-assets` skill). | ||
|
|
There was a problem hiding this comment.
ye pura section search se related hai, why is it here in general preflight skill and not search-asset skill. Also pls avoid making direct changes here. just leave comment.
There was a problem hiding this comment.
Okay I will leave comment.
This is here because MCP sometimes skips search assets skills when using cheap models! Adding this section at least gives some context to the agent to make correct call in first attempt as this skill is always loaded.
| ``` | ||
|
|
||
| --- | ||
|
|
There was a problem hiding this comment.
Parallel Execution for Bulk File Operations
When you have a list of files to operate on, never await in a loop. Chunk into batches of 100 and run each batch concurrently with Promise.allSettled().
// ✅ files is any array of { fileId, name } — from assets.list(), a prior search, etc.
const CHUNK = 100;
const chunks = [];
for (let i = 0; i < files.length; i += CHUNK) chunks.push(files.slice(i, i + CHUNK));
for (const chunk of chunks) {
await Promise.allSettled(
chunk.map(({ fileId, name }) =>
client.files.update(fileId, { tags: ['promo'] })
.then(() => ({ fileId, name, status: 'ok' }))
.catch((err: unknown) => ({ fileId, name, status: 'error', error: String(err) }))
)
);
}Same pattern applies for files.delete(fileId), files.copy({...}), and files.move({...}).
For delete / addTags / removeTags, prefer the bulk endpoints (max 50 IDs each) — chunk IDs and run chunks in parallel:
const CHUNK = 50;
const chunks = [];
for (let i = 0; i < allFileIds.length; i += CHUNK) chunks.push(allFileIds.slice(i, i + CHUNK));
await Promise.allSettled(chunks.map(ids => client.files.bulk.delete({ fileIds: ids })));There was a problem hiding this comment.
we can have a section for parallel execution



Summary
Builds on #2 and refines the two skills that interact most with TypeScript typing, so the agent gets correct results even when a skill isn't loaded. Pairs with companion SDK changes in
imagekit-nodejs(an honestassets.listoverload + an expandedexecutetool prompt).search-assetsassets.listoverload behavior:searchQuery→ pass{ type: 'file' }/{ type: 'folder' }for a typedFile[]/Folder[](no narrowing).searchQuery→ the API ignores thetype/tags/nameparams, so the result stays(File | Folder)[]; puttype = "file"inside the query and narrow withfor...of+if.client.customMetadataFields.list()to get valid field names/types before building"customMetadata.<field>"queries (operators depend on the field type).searchQueryoverrides the top-leveltype/tags/nameparams.imagekit-sdk-referenceassets.listnarrowing guidance to reflect the overload (narrowing only required for the union /searchQuerycases).executecode; when branching on failure, duck-type the error instead ofinstanceof ImageKit.APIError(a value import of the SDK crashes at runtime in the Deno sandbox).executesandbox.Companion SDK changes (separate
imagekit-nodejsPR)Companion PR - imagekit-developer/imagekit-nodejs#163
assets.listoverloads gated onsearchQuery?: undefinedso the typedFile[]/Folder[]return is only produced when there's nosearchQuery(no more type lie).executetool prompt expanded with list/search + pagination + nullable-field + custom-metadata-discovery guidance.