Get Asset
get_assetRetrieve assets from ElmapiCMS using UUID or filename to access media files and documents stored in the content management system.
Instructions
Get an asset by its UUID or by filename
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes | Asset UUID or filename | |
| by_name | No | If true, looks up by filename instead of UUID |
Implementation Reference
- src/tools/assets.ts:60-80 (handler)The complete registration and handler implementation of get_asset tool. It registers the tool with title, description, input schema, and an async handler that fetches assets by UUID or filename using client.get()
server.registerTool("get_asset", { title: "Get Asset", description: "Get an asset by its UUID or by filename", inputSchema: { identifier: z .string() .describe("Asset UUID or filename"), by_name: z .boolean() .optional() .describe("If true, looks up by filename instead of UUID"), }, }, async ({ identifier, by_name }) => { const path = by_name ? `/files/name/${identifier}` : `/files/${identifier}`; const result = await client.get(path); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }); - src/tools/assets.ts:63-71 (schema)Input schema definition for get_asset tool with 'identifier' (string - Asset UUID or filename) and optional 'by_name' (boolean - if true, looks up by filename instead of UUID) parameters
inputSchema: { identifier: z .string() .describe("Asset UUID or filename"), by_name: z .boolean() .optional() .describe("If true, looks up by filename instead of UUID"), }, - src/index.ts:39-39 (registration)Registration point where registerAssetTools function is called to register the get_asset tool along with other asset tools
registerAssetTools(server, client); - src/client.ts:94-112 (helper)The get() helper method used by get_asset handler. Constructs URL with base URL and optional query parameters, makes authenticated GET request with proper headers, and handles response parsing
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); }