Skip to main content
Glama

get_campaign

Retrieve details of a specific ad campaign using its ID. Optionally specify which fields to return.

Instructions

Get details of a specific campaign by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYesCampaign ID
fieldsNoComma-separated fields to return

Implementation Reference

  • The get_campaign tool handler. It accepts a campaign_id and optional fields, calls client.get(`/${campaign_id}`) to fetch campaign details from Meta Ads API, and returns the result as JSON text.
    server.tool(
      "get_campaign",
      "Get details of a specific campaign by ID.",
      {
        campaign_id: z.string().describe("Campaign ID"),
        fields: z.string().optional().describe("Comma-separated fields to return"),
      },
      async ({ campaign_id, fields }) => {
        try {
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          const { data, rateLimit } = await client.get(`/${campaign_id}`, 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 };
        }
      }
    );
  • Input schema for get_campaign: requires campaign_id (string), with optional fields (string).
    {
      campaign_id: z.string().describe("Campaign ID"),
      fields: z.string().optional().describe("Comma-separated fields to return"),
    },
  • Registration of get_campaign via server.tool() inside registerCampaignTools(). The function registerCampaignTools is exported and called from src/index.ts (lines 50 and 130).
    server.tool(
      "get_campaign",
      "Get details of a specific campaign by ID.",
      {
        campaign_id: z.string().describe("Campaign ID"),
        fields: z.string().optional().describe("Comma-separated fields to return"),
      },
      async ({ campaign_id, fields }) => {
        try {
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          const { data, rateLimit } = await client.get(`/${campaign_id}`, 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 };
        }
      }
    );
  • The AdsClient.get() method used by the get_campaign handler. It delegates to the private request() method which makes HTTP GET calls to the Meta Ads Graph API with proper authentication and error handling.
    async get(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("GET", path, 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);
    }
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral context. It lacks details on what 'details' entails, whether it returns all fields by default, rate limits, or side effects. The description is too minimal to inform the agent about beyond-schema behavior.

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

Conciseness4/5

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

A single sentence is very concise and to the point. While it could include more context, it is efficient and not verbose. No waste, but could be slightly more informative.

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?

Given no output schema, the description should explain return values but only says 'details'. With many sibling tools for fetching various campaign aspects, it would benefit from specifying what fields are returned by default or any pagination. Adequate but incomplete.

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% with both parameters (campaign_id and fields) described. The description adds no extra meaning beyond the schema, simply restating that it gets details by ID. Baseline 3 is appropriate as the schema already does the work.

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 'Get details of a specific campaign by ID.' clearly states the verb (get), the resource (details of a specific campaign), and the key identifier (ID). It effectively distinguishes from sibling tools like 'get_campaign_ads' or 'get_campaign_insights' by focusing on the campaign itself.

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 implies when to use (when you have a campaign ID and want its details) but provides no explicit guidance on when not to use or alternatives. For example, it doesn't mention that for a list of campaigns, you should use 'list_campaigns' instead.

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