Get a media attachment metadata
getMediaFetch metadata for a media attachment by its ID. Works with images, audio, and files.
Instructions
Fetch metadata for a media attachment (image, audio, file) by id.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mediaId | Yes |
Implementation Reference
- src/tools.ts:376-377 (handler)Handler function for getMedia tool - makes GET request to /api/public/media/{mediaId} to fetch media attachment metadata
async ({ mediaId }) => asJson(await client.get(`/api/public/media/${enc(mediaId)}`)), ); - src/tools.ts:374-374 (schema)Input schema for getMedia, requiring a mediaId string with min length 1
inputSchema: { mediaId: z.string().min(1) }, - src/tools.ts:369-377 (registration)Registration of getMedia tool via server.registerTool with title, description, inputSchema, and handler
server.registerTool( "getMedia", { title: "Get a media attachment metadata", description: "Fetch metadata for a media attachment (image, audio, file) by id.", inputSchema: { mediaId: z.string().min(1) }, }, async ({ mediaId }) => asJson(await client.get(`/api/public/media/${enc(mediaId)}`)), ); - src/tools.ts:418-420 (registration)getMedia included in the TOOL_NAMES exported const array
"getMedia", "getHealth", ] as const; - src/client.ts:27-65 (helper)The LangfuseClient.get method used by the handler to make authenticated API requests
async get(path: string, params: QueryParams = {}): Promise<unknown> { const url = new URL(`${this.baseUrl}${path}`); for (const [key, value] of Object.entries(params)) { if (value === undefined || value === null || value === "") continue; if (Array.isArray(value)) { for (const item of value) url.searchParams.append(key, String(item)); } else { url.searchParams.set(key, String(value)); } } const response = await fetch(url, { headers: { Authorization: this.authHeader, Accept: "application/json", }, }); const text = await response.text(); if (!response.ok) { throw new LangfuseError( `Langfuse API ${response.status} ${response.statusText}: ${text.slice(0, 500)}`, response.status, text, ); } try { return JSON.parse(text) as unknown; } catch { throw new LangfuseError( `Langfuse API returned non-JSON response from ${url.pathname}: ${text.slice(0, 200)}`, response.status, text, ); } }