Skip to main content
Glama

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
NameRequiredDescriptionDefault
media_idYesUUID of the media asset to update
original_media_urlYesNew URL for the original (unprotected) media file

Implementation Reference

  • 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,
        };
      }
    },
  • 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"),
    },
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sidearmDRM/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server