update_campaign
Modify existing Uber advertising campaigns by updating campaign name, status, budget amount, or end time using the Uber External Ads API.
Instructions
Update an existing campaign
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_account_id | Yes | The ad account UUID | |
| auth_token | No | Bearer token for authentication | |
| campaign_data | Yes | ||
| campaign_id | Yes | The campaign UUID |
Implementation Reference
- src/index.ts:623-651 (handler)The core handler function for the 'update_campaign' tool. It validates inputs using Zod schemas, constructs the Uber Ads API PATCH URL, sends the request with axios, and returns the API response or handles errors.private async updateCampaign(args: any) { const authToken = this.getAuthToken(args.auth_token); const adAccountId = AdAccountIdSchema.parse(args.ad_account_id); const campaignId = CampaignIdSchema.parse(args.campaign_id); const campaignData = CampaignUpdateSchema.parse(args.campaign_data); const url = `${UBER_ADS_API_BASE_URL}/${adAccountId}/campaigns/${campaignId}`; try { const response = await axios.patch(url, campaignData, { headers: { 'Authorization': `Bearer ${authToken}`, 'Accept': 'application/json', 'Content-Type': 'application/json', }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
- src/index.ts:42-47 (schema)Zod schema used for validating the campaign_data input parameter in the update_campaign handler.const CampaignUpdateSchema = z.object({ name: z.string().min(1).optional(), status: z.enum(['ACTIVE', 'PAUSED']).optional(), budget_amount: z.number().positive().optional(), end_time: z.string().optional(), });
- src/index.ts:271-317 (registration)Tool registration in the listTools response, defining the name, description, and inputSchema for MCP clients.{ name: 'update_campaign', description: 'Update an existing campaign', inputSchema: { type: 'object', properties: { auth_token: { type: 'string', description: 'Bearer token for authentication', }, ad_account_id: { type: 'string', description: 'The ad account UUID', }, campaign_id: { type: 'string', description: 'The campaign UUID', }, campaign_data: { type: 'object', properties: { name: { type: 'string', description: 'Campaign name', }, status: { type: 'string', enum: ['ACTIVE', 'PAUSED'], description: 'Campaign status', }, budget_amount: { type: 'number', minimum: 0.01, description: 'Budget amount in USD', }, end_time: { type: 'string', description: 'Campaign end time (ISO 8601)', }, }, additionalProperties: false, }, }, required: ['ad_account_id', 'campaign_id', 'campaign_data'], additionalProperties: false, }, },
- src/index.ts:420-421 (registration)Dispatch case in the CallToolRequestSchema handler that routes 'update_campaign' calls to the updateCampaign method.case 'update_campaign': return await this.updateCampaign(args);
- src/index.ts:18-19 (schema)Zod schema for validating the campaign_id parameter.const CampaignIdSchema = z.string().min(1, 'Campaign ID is required');