Get Asset
get_assetRetrieve an asset by its UUID or filename from ElmapiCMS. Use by_name flag to look up by filename instead.
Instructions
Get an asset by its UUID or by filename
Input 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 (registration)Registration of the 'get_asset' tool with name, description, input schema (identifier + optional by_name flag), and the async handler function.
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:72-80 (handler)Handler logic for 'get_asset': constructs the API path based on whether 'by_name' is true (/files/name/:identifier) or false (/files/:identifier), then fetches via client.get and returns the result as JSON text.
}, 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 for 'get_asset' using Zod: 'identifier' (required string for UUID or filename) and 'by_name' (optional boolean flag to switch between UUID and filename lookup).
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/client.ts:94-112 (helper)The client.get() method used by the handler to make a GET request to the ElmapiCMS API with optional query parameters.
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); } - src/index.ts:39-39 (helper)Registration call: registerAssetTools(server, client) which wires the tool into the MCP server.
registerAssetTools(server, client);