List Assets
list_assetsList assets in your project with pagination to browse and manage media files.
Instructions
List assets in the project with optional pagination
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number | |
| per_page | No | Items per page |
Implementation Reference
- src/tools/assets.ts:41-57 (handler)Handler function for the list_assets tool. Accepts optional page/per_page pagination params, makes a GET request to /files via the ElmapiClient, and returns the result as JSON text.
server.registerTool("list_assets", { title: "List Assets", description: "List assets in the project with optional pagination", inputSchema: { page: z.number().optional().describe("Page number"), per_page: z.number().optional().describe("Items per page"), }, }, async ({ page, per_page }) => { const params: Record<string, string> = {}; if (page) params.page = String(page); if (per_page) params.per_page = String(per_page); const result = await client.get("/files", params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/tools/assets.ts:44-47 (schema)Input schema for list_assets using Zod: optional page and per_page number fields.
inputSchema: { page: z.number().optional().describe("Page number"), per_page: z.number().optional().describe("Items per page"), }, - src/tools/assets.ts:41-57 (registration)Registration of the list_assets tool via server.registerTool() within the registerAssetTools function.
server.registerTool("list_assets", { title: "List Assets", description: "List assets in the project with optional pagination", inputSchema: { page: z.number().optional().describe("Page number"), per_page: z.number().optional().describe("Items per page"), }, }, async ({ page, per_page }) => { const params: Record<string, string> = {}; if (page) params.page = String(page); if (per_page) params.per_page = String(per_page); const result = await client.get("/files", params); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/index.ts:39-39 (registration)Top-level registration call that wires up all asset tools including list_assets.
registerAssetTools(server, client); - src/client.ts:94-112 (helper)ElmapiClient.get() helper used by list_assets to perform the GET request to /files with pagination params.
async get( path: string, params?: Record<string, unknown> ): Promise<unknown> { const url = new URL(`${this.baseUrl}${path}`); if (params) { const flatPairs = this.flattenParams(params); for (const [key, value] of flatPairs) { url.searchParams.append(key, value); } } const response = await fetch(url.toString(), { method: "GET", headers: this.headers(), }); return this.handleResponse(response); }