Skip to main content
Glama

upload_video

Upload an ad video from a public URL to obtain a video ID for use in ad creatives.

Instructions

Upload an ad video from a public URL. Returns video ID for use in ad creatives.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_urlYesPublic URL of the video to upload
titleNoVideo title
descriptionNoVideo description

Implementation Reference

  • The 'upload_video' tool handler function. Uses AdsClient.post to POST file_url (with optional title/description) to `${client.accountPath}/advideos` (i.e., /act_{ACCOUNT_ID}/advideos). Returns the API response data with rate limit info, or an error message.
    // ─── upload_video ──────────────────────────────────────────
    server.tool(
      "upload_video",
      "Upload an ad video from a public URL. Returns video ID for use in ad creatives.",
      {
        file_url: z.string().describe("Public URL of the video to upload"),
        title: z.string().optional().describe("Video title"),
        description: z.string().optional().describe("Video description"),
      },
      async ({ file_url, title, description }) => {
        try {
          const params: Record<string, unknown> = { file_url };
          if (title) params.title = title;
          if (description) params.description = description;
          const { data, rateLimit } = await client.post(`${client.accountPath}/advideos`, params);
          return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Zod input schema for 'upload_video': file_url (required string), title (optional string), description (optional string).
    {
      file_url: z.string().describe("Public URL of the video to upload"),
      title: z.string().optional().describe("Video title"),
      description: z.string().optional().describe("Video description"),
    },
  • The 'registerVideoTools' function registers all video tools (including upload_video) on the MCP server via server.tool().
    export function registerVideoTools(server: McpServer, client: AdsClient): void {
      // ─── list_videos ───────────────────────────────────────────
      server.tool(
        "list_videos",
        "List ad videos uploaded to the ad account.",
        {
          fields: z.string().optional().describe("Comma-separated fields to return"),
          limit: z.number().optional().default(25).describe("Number of results (default 25)"),
          after: z.string().optional().describe("Pagination cursor for next page"),
        },
        async ({ fields, limit, after }) => {
          try {
            const params: Record<string, unknown> = {};
            if (fields) params.fields = fields;
            if (limit) params.limit = limit;
            if (after) params.after = after;
            const { data, rateLimit } = await client.get(`${client.accountPath}/advideos`, params);
            return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
          } catch (error) {
            return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
          }
        }
      );
    
      // ─── upload_video ──────────────────────────────────────────
      server.tool(
        "upload_video",
        "Upload an ad video from a public URL. Returns video ID for use in ad creatives.",
        {
          file_url: z.string().describe("Public URL of the video to upload"),
          title: z.string().optional().describe("Video title"),
          description: z.string().optional().describe("Video description"),
        },
        async ({ file_url, title, description }) => {
          try {
            const params: Record<string, unknown> = { file_url };
            if (title) params.title = title;
            if (description) params.description = description;
            const { data, rateLimit } = await client.post(`${client.accountPath}/advideos`, params);
            return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
          } catch (error) {
            return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
          }
        }
      );
    
      // ─── get_video ─────────────────────────────────────────────
      server.tool(
        "get_video",
        "Get details of a specific ad video by ID.",
        {
          video_id: z.string().describe("Video ID"),
          fields: z.string().optional().describe("Comma-separated fields to return"),
  • src/index.ts:15-58 (registration)
    Import and call to registerVideoTools(server, client) which registers upload_video on the MCP server.
    import { registerVideoTools } from "./tools/videos.js";
    import { registerCanvasTools } from "./tools/canvas.js";
    import { registerAudienceTools } from "./tools/audiences.js";
    import { registerTargetingTools } from "./tools/targeting.js";
    import { registerInsightTools } from "./tools/insights.js";
    import { registerLeadTools } from "./tools/leads.js";
    import { registerCatalogTools } from "./tools/catalogs.js";
    import { registerFeedTools } from "./tools/feeds.js";
    import { registerRuleTools } from "./tools/rules.js";
    import { registerExperimentTools } from "./tools/experiments.js";
    import { registerConversionTools } from "./tools/conversions.js";
    import { registerBudgetTools } from "./tools/budget.js";
    import { registerReachFrequencyTools } from "./tools/reach_frequency.js";
    import { registerBrandSafetyTools } from "./tools/brand_safety.js";
    import { registerAccountTools } from "./tools/account.js";
    import { registerBusinessTools } from "./tools/business.js";
    import { registerAuthTools } from "./tools/auth.js";
    import { registerAdLibraryTools } from "./tools/ad_library.js";
    
    // --- Resources & Prompts ---
    import { registerResources } from "./resources/account.js";
    import { registerPrompts } from "./prompts/index.js";
    
    const require = createRequire(import.meta.url);
    const { version } = require("../package.json");
    
    const server = new McpServer({
      name: "meta-ads-mcp",
      version,
    });
    
    const config = loadConfig();
    const client = new AdsClient(config);
    
    // --- Campaign Management ---
    registerCampaignTools(server, client);
    registerAdsetTools(server, client);
    registerAdTools(server, client);
    registerCreativeTools(server, client);
    
    // --- Assets ---
    registerImageTools(server, client);
    registerVideoTools(server, client);
    registerCanvasTools(server, client);
  • The AdsClient.post() method (called by the handler) which sends a POST request to the Meta Graph API with JSON body containing access_token and params.
    async post(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("POST", path, params);
    }
    
    async delete(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("DELETE", path, params);
    }
    
    // --- Upload (URL-based) ---
    
    async upload(
      path: string,
      fileUrl: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.post(path, { ...params, url: fileUrl });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It only mentions the source (public URL) and return value, but omits important details like file size limits, supported formats, authentication needs, or whether the upload is synchronous or asynchronous.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence that conveys the essential information without unnecessary words. It is front-loaded with the main action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is adequate for basic use, specifying input (public URL) and output (video ID). However, it lacks details on error conditions, prerequisites, or processing behavior. Given the complexity (3 params, no output schema), more completeness would be beneficial.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds context by specifying 'public URL' for file_url and mentioning the return value, but does not elaborate on title and description semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'upload', the resource 'ad video', the source 'public URL', and the return value 'video ID for use in ad creatives'. It is specific and distinguishes from sibling tools like upload_image and delete_video.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description specifies 'from a public URL' but does not provide guidance on when to use this tool versus alternatives (e.g., upload_image) or any prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/mikusnuz/meta-ads-mcp'

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