Skip to main content
Glama
AlexandreCalvet

Ogury MCP Server

get_campaigns_report

Retrieve campaign performance reports from Ogury's API with date ranges and filtering options to analyze advertising effectiveness.

Instructions

Get campaign performance report with flexible filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdNoAccount IDs (comma-separated)
brandIdNoBrand ID
campaignIdNoCampaign ID
endDateYesEnd date in YYYY-MM-DD format (required)
identifier1NoExternal identifier 1
identifier2NoExternal identifier 2
identifier3NoExternal identifier 3
startDateYesStart date in YYYY-MM-DD format (required)

Implementation Reference

  • The core handler function for the 'get_campaigns_report' tool. It authenticates via getAccessToken, constructs query params from input args, fetches data from the Ogury API endpoint /v1/reporting/campaigns, handles single or array response, formats numbers/percentages, builds a text report summarizing campaigns, and returns MCP-formatted content.
      private async getCampaignsReport(args: {
        startDate: string;
        endDate: string;
        accountId?: string;
        brandId?: string;
        campaignId?: number;
        identifier1?: string;
        identifier2?: string;
        identifier3?: string;
      }) {
        const token = await this.getAccessToken();
        
        const params = new URLSearchParams({
          startDate: args.startDate,
          endDate: args.endDate,
        });
    
        if (args.accountId) params.append('accountId', args.accountId);
        if (args.brandId) params.append('brandId', args.brandId);
        if (args.campaignId) params.append('campaignId', args.campaignId.toString());
        if (args.identifier1) params.append('identifier1', args.identifier1);
        if (args.identifier2) params.append('identifier2', args.identifier2);
        if (args.identifier3) params.append('identifier3', args.identifier3);
    
        try {
          const response = await fetch(`${this.baseUrl}/v1/reporting/campaigns?${params}`, {
            method: 'GET',
            headers: {
              'Authorization': `Bearer ${token}`,
              'Accept': 'application/json',
            },
          });
    
          if (!response.ok) {
            throw new Error(`API request failed: ${response.status} ${response.statusText}`);
          }
    
          const campaignData: CampaignReport | CampaignReport[] = await response.json();
          const campaigns = Array.isArray(campaignData) ? campaignData : [campaignData];
          
          // Safe number formatting with null checks
          const formatNumber = (value: any) => {
            if (value === null || value === undefined) return 'N/A';
            return typeof value === 'number' ? value.toLocaleString() : String(value);
          };
    
          const formatPercentage = (value: any) => {
            if (value === null || value === undefined) return 'N/A';
            return typeof value === 'number' ? `${value}%` : String(value);
          };
    
          const report = campaigns.map(campaign => 
            `Campaign ID: ${campaign.campaignId || 'N/A'} | ${campaign.campaign || 'N/A'}
    Brand: ${campaign.brand || 'N/A'} | Strategy: ${campaign.strategy || 'N/A'}
    Impressions: ${formatNumber(campaign.impressions)} | Clicks: ${formatNumber(campaign.clicks)} | CTR: ${formatPercentage(campaign.ctr)}
    Spend: ${formatNumber(campaign.spend)} ${campaign.currency || ''} | Reach: ${formatNumber(campaign.reach)}
    `).join('\n---\n');
    
          return {
            content: [
              {
                type: 'text',
                text: `Campaigns Report (${args.startDate} to ${args.endDate}):
    
    ${report}
    
    Total campaigns: ${campaigns.length}`,
              },
            ],
          };
        } catch (error) {
          throw new Error(`Failed to fetch campaigns report: ${error instanceof Error ? error.message : 'Unknown error'}`);
        }
      }
  • Input schema and metadata for the get_campaigns_report tool, defining parameters for date range and optional filters (account, brand, campaign ID, external identifiers). Used in tools/list response.
      name: 'get_campaigns_report',
      description: 'Get campaign performance report with flexible filtering',
      inputSchema: {
        type: 'object',
        properties: {
          startDate: {
            type: 'string',
            description: 'Start date in YYYY-MM-DD format (required)',
          },
          endDate: {
            type: 'string',
            description: 'End date in YYYY-MM-DD format (required)',
          },
          accountId: {
            type: 'string',
            description: 'Account IDs (comma-separated)',
          },
          brandId: {
            type: 'string',
            description: 'Brand ID',
          },
          campaignId: {
            type: 'number',
            description: 'Campaign ID',
          },
          identifier1: {
            type: 'string',
            description: 'External identifier 1',
          },
          identifier2: {
            type: 'string',
            description: 'External identifier 2',
          },
          identifier3: {
            type: 'string',
            description: 'External identifier 3',
          },
        },
        required: ['startDate', 'endDate'],
      },
    },
  • Tool dispatch registration via setRequestHandler(CallToolRequestSchema). The switch case routes 'get_campaigns_report' calls to the getCampaignsReport handler.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      try {
        switch (name) {
          case 'get_campaign_details':
            return await this.getCampaignDetails(args as any);
          case 'get_campaigns_report':
            return await this.getCampaignsReport(args as any);
          default:
            throw new Error(`Unknown tool: ${name}`);
        }
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`,
            },
          ],
        };
      }
    });
  • Tool list registration via setRequestHandler(ListToolsRequestSchema), including get_campaigns_report in the available tools list with its schema.
          {
            name: 'get_campaign_details',
            description: 'Get campaign performance details by campaign ID',
            inputSchema: {
              type: 'object',
              properties: {
                campaignId: {
                  type: 'number',
                  description: 'The campaign ID to retrieve details for',
                },
                startDate: {
                  type: 'string',
                  description: 'Start date in YYYY-MM-DD format (required)',
                },
                endDate: {
                  type: 'string',
                  description: 'End date in YYYY-MM-DD format (required)',
                },
                accountId: {
                  type: 'string',
                  description: 'Optional account ID filter',
                },
                brandId: {
                  type: 'string',
                  description: 'Optional brand ID filter',
                },
              },
              required: ['campaignId', 'startDate', 'endDate'],
            },
          },
          {
            name: 'get_campaigns_report',
            description: 'Get campaign performance report with flexible filtering',
            inputSchema: {
              type: 'object',
              properties: {
                startDate: {
                  type: 'string',
                  description: 'Start date in YYYY-MM-DD format (required)',
                },
                endDate: {
                  type: 'string',
                  description: 'End date in YYYY-MM-DD format (required)',
                },
                accountId: {
                  type: 'string',
                  description: 'Account IDs (comma-separated)',
                },
                brandId: {
                  type: 'string',
                  description: 'Brand ID',
                },
                campaignId: {
                  type: 'number',
                  description: 'Campaign ID',
                },
                identifier1: {
                  type: 'string',
                  description: 'External identifier 1',
                },
                identifier2: {
                  type: 'string',
                  description: 'External identifier 2',
                },
                identifier3: {
                  type: 'string',
                  description: 'External identifier 3',
                },
              },
              required: ['startDate', 'endDate'],
            },
          },
        ],
      };
    });
    
    // Handle tool calls
  • Shared helper function to obtain and cache OAuth2 access token using client credentials, used by the handler for API authentication.
    private async getAccessToken(): Promise<string> {
      // Check if token is still valid (with 5 minute buffer)
      if (this.accessToken && this.tokenExpiry && Date.now() < this.tokenExpiry - 300000) {
        return this.accessToken;
      }
    
      const credentials = Buffer.from(`${this.clientId}:${this.clientSecret}`).toString('base64');
      
      try {
        const response = await fetch(`${this.baseUrl}/oauth2/token`, {
          method: 'POST',
          headers: {
            'Authorization': `Basic ${credentials}`,
            'Content-Type': 'application/x-www-form-urlencoded',
          },
          body: 'grant_type=client_credentials',
        });
    
        if (!response.ok) {
          throw new Error(`Authentication failed: ${response.status} ${response.statusText}`);
        }
    
        const authData: AuthResponse = await response.json();
        this.accessToken = authData.access_token;
        this.tokenExpiry = Date.now() + (authData.expires_in * 1000);
        
        return this.accessToken;
      } catch (error) {
        throw new Error(`Failed to get access token: ${error instanceof Error ? error.message : 'Unknown error'}`);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the action ('Get') and mentions 'flexible filtering', but doesn't cover critical aspects like whether this is a read-only operation, potential rate limits, authentication requirements, or what the output format looks like. For a tool with 8 parameters and no annotations, this is insufficient.

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?

The description is a single, efficient sentence that gets straight to the point without unnecessary words. It's appropriately sized for the tool's complexity, though it could be more informative while maintaining brevity.

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

Completeness2/5

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

Given the tool's complexity (8 parameters, no output schema, no annotations), the description is inadequate. It doesn't explain what a 'performance report' entails, how filtering works, or what the return values are. For a reporting tool with multiple identifiers and no structured output, more context is needed to guide the agent effectively.

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?

The description adds minimal value beyond the input schema, which has 100% coverage with clear parameter descriptions. The phrase 'flexible filtering' hints at the filtering capability of the parameters but doesn't explain how they interact or provide additional context about the identifiers. With high schema coverage, the baseline score of 3 is appropriate.

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

Purpose3/5

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

The description states the tool 'Get campaign performance report with flexible filtering', which provides a clear verb ('Get') and resource ('campaign performance report'). However, it's somewhat vague about what constitutes 'performance report' and doesn't distinguish it from the sibling tool 'get_campaign_details', leaving ambiguity about their different purposes.

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

Usage Guidelines2/5

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

The description mentions 'flexible filtering' but provides no guidance on when to use this tool versus the sibling 'get_campaign_details'. There's no mention of alternatives, prerequisites, or specific contexts where this tool is preferred, leaving the agent without usage direction.

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/AlexandreCalvet/ogury-mcp-server-test'

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