update_media
Modify the URL of a registered media asset to point to a new location for the original file, such as after re-hosting.
Instructions
Update a registered media asset. Currently supports updating the original media URL (e.g., after re-hosting the original file).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_id | Yes | UUID of the media asset to update | |
| original_media_url | Yes | New URL for the original (unprotected) media file |
Implementation Reference
- src/tools/update-media.ts:17-39 (handler)The async handler function that executes the update_media tool logic. It makes a PATCH API call to update a media asset's original_media_url and returns the result or error.
async ({ media_id, original_media_url }) => { try { const result = await api.patch( `/api/v1/media/${encodeURIComponent(media_id)}`, { original_media_url }, ); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true as const, }; } }, - src/tools/update-media.ts:10-16 (schema)Zod schema definition for the update_media tool parameters, validating media_id (UUID string) and original_media_url (valid URL string).
{ media_id: z.string().describe("UUID of the media asset to update"), original_media_url: z .string() .url() .describe("New URL for the original (unprotected) media file"), }, - src/tools/update-media.ts:5-41 (registration)The register function that registers the update_media tool with the MCP server, including the tool name, description, schema, and handler.
export function register(server: McpServer, api: ApiClient): void { server.tool( "update_media", "Update a registered media asset. Currently supports updating the original " + "media URL (e.g., after re-hosting the original file).", { media_id: z.string().describe("UUID of the media asset to update"), original_media_url: z .string() .url() .describe("New URL for the original (unprotected) media file"), }, async ({ media_id, original_media_url }) => { try { const result = await api.patch( `/api/v1/media/${encodeURIComponent(media_id)}`, { original_media_url }, ); return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2) }, ], }; } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true as const, }; } }, ); } - src/index.ts:18-18 (registration)Import statement for the update_media register function from tools/update-media.js
import { register as updateMedia } from "./tools/update-media.js"; - src/index.ts:62-62 (registration)Registration call that activates the update_media tool with the MCP server and API client
updateMedia(server, api);