Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_assign_shared_budget

Replace a campaign's individual budget with a shared budget, enabling centralized budget management across campaigns.

Instructions

Assign a shared budget to a campaign.

Args: customer_id: Customer ID (without hyphens) campaign_id: Campaign ID to update budget_resource_name: Resource name of the shared budget (from google_ads_create_shared_budget)

Returns: Success message

Note: The campaign will switch from its individual budget to the shared budget.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
campaign_idYes
budget_resource_nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler function for 'google_ads_assign_shared_budget'. It is decorated with @mcp.tool() and receives customer_id, campaign_id, and budget_resource_name. It calls CampaignManager.assign_shared_budget() and formats the success/error response.
    def google_ads_assign_shared_budget(
        customer_id: str,
        campaign_id: str,
        budget_resource_name: str
    ) -> str:
        """
        Assign a shared budget to a campaign.
    
        Args:
            customer_id: Customer ID (without hyphens)
            campaign_id: Campaign ID to update
            budget_resource_name: Resource name of the shared budget (from google_ads_create_shared_budget)
    
        Returns:
            Success message
    
        Note: The campaign will switch from its individual budget to the shared budget.
        """
        with performance_logger.track_operation('assign_shared_budget', customer_id=customer_id):
            try:
                client = get_auth_manager().get_client()
                campaign_manager = CampaignManager(client)
    
                result = campaign_manager.assign_shared_budget(
                    customer_id,
                    campaign_id,
                    budget_resource_name
                )
    
                # Audit log
                audit_logger.log_api_call(
                    customer_id=customer_id,
                    operation="assign_shared_budget",
                    resource_type="campaign",
                    resource_id=campaign_id,
                    action="update",
                    result="success",
                    details={'budget_resource_name': budget_resource_name}
                )
    
                # Invalidate cache
                get_cache_manager().invalidate(customer_id, ResourceType.CAMPAIGN)
    
                output = f"✅ Shared budget assigned to campaign {campaign_id}\n\n"
                output += f"**Budget Resource**: {budget_resource_name}\n\n"
                output += f"{result['message']}\n\n"
                output += "The campaign now shares its budget with other campaigns using the same budget."
    
                return output
    
            except Exception as e:
                error_msg = ErrorHandler.handle_error(e, context="assign_shared_budget")
                return f"❌ Failed to assign shared budget: {error_msg}"
  • The CampaignManager.assign_shared_budget() method that contains the core logic. It creates a CampaignOperation, sets the campaign_budget field to the shared budget resource name, applies a field mask, and calls the Google Ads CampaignService.mutate_campaigns() API.
    def assign_shared_budget(
        self,
        customer_id: str,
        campaign_id: str,
        budget_resource_name: str
    ) -> Dict[str, Any]:
        """
        Assign a shared budget to a campaign.
    
        Args:
            customer_id: Customer ID
            campaign_id: Campaign ID
            budget_resource_name: Resource name of the shared budget
    
        Returns:
            Operation result
        """
        campaign_service = self.client.get_service("CampaignService")
    
        campaign_operation = self.client.get_type("CampaignOperation")
        campaign = campaign_operation.update
    
        campaign.resource_name = campaign_service.campaign_path(customer_id, campaign_id)
        campaign.campaign_budget = budget_resource_name
    
        # Set field mask
        self.client.copy_from(
            campaign_operation.update_mask,
            field_mask_pb2.FieldMask(paths=["campaign_budget"])
        )
    
        # Update campaign
        response = campaign_service.mutate_campaigns(
            customer_id=customer_id,
            operations=[campaign_operation]
        )
    
        logger.info(f"Assigned shared budget to campaign {campaign_id}")
    
        return {
            "campaign_id": campaign_id,
            "budget_resource_name": budget_resource_name
        }
  • The 'register_campaign_tools' function registers all campaign tools (including this one) with the MCP server via @mcp.tool() decorator inside the function body.
    def register_campaign_tools(mcp: FastMCP):
        """Register campaign management tools with MCP server."""
Behavior3/5

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

No annotations are provided, so the description bears full behavioral transparency burden. It discloses that 'The campaign will switch from its individual budget to the shared budget,' which is a key behavioral change. However, it does not mention whether the operation is reversible, what permissions are required, or what happens if the campaign already uses a shared budget.

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 very concise: a single sentence for the main action, followed by an Args list and a Note. Every sentence is essential and there is no extraneous text. It is well-structured and front-loaded.

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

Completeness4/5

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

Given the tool's simplicity and the presence of an output schema (though not detailed in the description), the description covers the main action, parameter sources, and a behavioral note. It lacks details on error handling or what happens if the budget resource is invalid, but overall it provides sufficient context for typical usage.

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

Parameters4/5

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

Input schema has 0% description coverage, but the description adds value by explaining parameter sources and formatting: customer_id (without hyphens), campaign_id, and budget_resource_name (from sibling tool). This helps the agent understand where to get the values, going beyond the schema's type-only fields.

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 'Assign a shared budget to a campaign.' It uses a specific verb ('Assign'), identifies the resource ('shared budget'), and the target ('campaign'), which distinguishes it from siblings like 'google_ads_create_shared_budget' or 'google_ads_update_campaign_budget_v2'.

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

Usage Guidelines4/5

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

The description indicates that the budget_resource_name should come from 'google_ads_create_shared_budget', implying a prior step. The note about switching from individual to shared budget provides context on when to use this tool (when a campaign currently has an individual budget). It does not explicitly state when not to use it or list alternatives, but the context is clear enough.

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/johnoconnor0/google-ads-mcp'

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