Skip to main content
Glama
johnoconnor0

Google Ads MCP Server

by johnoconnor0

google_ads_search_google_audiences

Search Google's predefined audiences by interest or purchase intent. Returns matching In-Market and Affinity segments.

Instructions

Search for Google's predefined audiences (In-Market, Affinity).

Google provides hundreds of pre-built audience segments based on user interests and purchase intent. Search to find relevant audiences for your business.

Args: customer_id: Customer ID (without hyphens) search_term: Search term (e.g., "coffee", "fitness", "travel")

Returns: List of matching Google audiences

Example: google_ads_search_google_audiences( customer_id="1234567890", search_term="coffee" )

Common Categories:

  • In-Market: Users actively researching products (high purchase intent)

  • Affinity: Users with sustained interest in a topic

  • Custom Intent: Create your own based on keywords/URLs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
customer_idYes
search_termYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler that defines the tool, validates inputs, calls the audience manager, formats results, and returns a user-friendly response.
    def google_ads_search_google_audiences(
        customer_id: str,
        search_term: str
    ) -> str:
        """
        Search for Google's predefined audiences (In-Market, Affinity).
    
        Google provides hundreds of pre-built audience segments based on user
        interests and purchase intent. Search to find relevant audiences for
        your business.
    
        Args:
            customer_id: Customer ID (without hyphens)
            search_term: Search term (e.g., "coffee", "fitness", "travel")
    
        Returns:
            List of matching Google audiences
    
        Example:
            google_ads_search_google_audiences(
                customer_id="1234567890",
                search_term="coffee"
            )
    
        Common Categories:
        - In-Market: Users actively researching products (high purchase intent)
        - Affinity: Users with sustained interest in a topic
        - Custom Intent: Create your own based on keywords/URLs
        """
        with performance_logger.track_operation('search_google_audiences', customer_id=customer_id):
            try:
                client = get_auth_manager().get_client()
                audience_manager = AudienceManager(client)
    
                audiences = audience_manager.search_google_audiences(customer_id, search_term)
    
                # Audit log
                audit_logger.log_api_call(
                    customer_id=customer_id,
                    operation="search_google_audiences",
                    resource_type="user_interest",
                    action="read",
                    result="success",
                    details={'search_term': search_term, 'count': len(audiences)}
                )
    
                if not audiences:
                    return f"No Google audiences found matching '{search_term}'. Try different search terms."
    
                # Format response
                output = f"# Google Audiences - Search Results\n\n"
                output += f"**Search Term**: {search_term}\n"
                output += f"**Results Found**: {len(audiences)}\n\n"
    
                for aud in audiences:
                    output += f"## {aud['name']}\n\n"
                    output += f"- **Audience ID**: {aud['user_interest_id']}\n"
                    output += f"- **Category**: {aud['taxonomy_type']}\n"
                    if aud['parent']:
                        output += f"- **Parent Category**: {aud['parent']}\n"
                    output += "\n"
    
                output += f"**Next Steps**:\n"
                output += f"To target these audiences, you'll need to add them to campaigns via the Google Ads UI "
                output += f"or use the audience ID in targeting API calls.\n"
    
                return output
    
            except Exception as e:
                error_msg = ErrorHandler.handle_error(e, context="search_google_audiences")
                return f"❌ Failed to search Google audiences: {error_msg}"
  • Input schema: customer_id (str) and search_term (str). Returns a formatted string.
    def google_ads_search_google_audiences(
        customer_id: str,
        search_term: str
    ) -> str:
  • Registration entry in _TOOL_MODULES list that maps the audiences module to its register function.
        ("audiences",     "tools.audiences.mcp_tools_audiences",         "register_audience_tools"),
        ("conversions",   "tools.conversions.mcp_tools_conversions",     "register_conversion_tools"),
        ("reporting",     "tools.reporting.mcp_tools_reporting",         "register_reporting_tools"),
        ("insights",      "tools.insights.mcp_tools_insights",           "register_insights_tools"),
        ("batch",         "tools.batch.mcp_tools_batch",                 "register_batch_tools"),
        ("shopping_pmax", "tools.shopping_pmax.mcp_tools_shopping_pmax", "register_shopping_pmax_tools"),
        ("extensions",    "tools.extensions.mcp_tools_extensions",       "register_extension_tools"),
        ("local_app",     "tools.local_app.mcp_tools_local_app",         "register_local_app_tools"),
    ]
    
    
    def _register_all_modular_tools():
        """Import and register every modular tool module."""
        import importlib
    
        registered = 0
        for label, module_path, func_name in _TOOL_MODULES:
            try:
                mod = importlib.import_module(module_path)
                register_fn = getattr(mod, func_name)
                register_fn(mcp)
  • Dynamic import and registration of the register_audience_tools function via _register_all_modular_tools()
    for label, module_path, func_name in _TOOL_MODULES:
        try:
            mod = importlib.import_module(module_path)
            register_fn = getattr(mod, func_name)
            register_fn(mcp)
  • Core business logic: queries Google Ads API user_interest table with LIKE search, returns matching In-Market/Affinity audiences.
    def search_google_audiences(
        self,
        customer_id: str,
        search_term: str
    ) -> List[Dict[str, Any]]:
        """Search for available Google audiences (In-Market, Affinity).
    
        Args:
            customer_id: Customer ID (without hyphens)
            search_term: Search term to find audiences
    
        Returns:
            List of matching Google audiences
        """
        ga_service = self.client.get_service("GoogleAdsService")
    
        # Search for user interests (In-Market and Affinity audiences)
        query = f"""
            SELECT
                user_interest.user_interest_id,
                user_interest.name,
                user_interest.user_interest_parent,
                user_interest.taxonomy_type
            FROM user_interest
            WHERE user_interest.name LIKE '%{search_term}%'
        """
    
        response = ga_service.search(customer_id=customer_id, query=query)
    
        audiences = []
        for row in response:
            ui = row.user_interest
            audiences.append({
                'user_interest_id': str(ui.user_interest_id),
                'name': ui.name,
                'parent': ui.user_interest_parent,
                'taxonomy_type': ui.taxonomy_type.name
            })
    
        return audiences
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It explains that it searches predefined audiences and lists common categories, but does not disclose whether it is read-only, pagination behavior, or required permissions. The output schema is present but its content is not visible here.

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 well-structured: a brief summary followed by formal Args, Returns, Example, and Common Categories sections. Every sentence is useful, and there is no redundant content.

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?

For a simple search tool with two parameters and an output schema, the description covers the purpose, parameters, example, and helpful categories. It is slightly lacking in usage guidance versus sibling tools, but is otherwise complete.

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

Parameters5/5

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

The input schema lacks descriptions (0% coverage), but the description's Args section adds clear meaning for both parameters: customer_id without hyphens and search_term with examples. This compensates fully for the schema gap.

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 it searches for Google's predefined audiences such as In-Market and Affinity. Among siblings, no other tool has the same purpose (e.g., google_ads_get_audience_performance is different), so it is well-distinguished.

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 does not provide explicit guidance on when to use this tool versus alternatives like google_ads_get_audience_performance or google_ads_create_user_list. It only implies usage by stating 'Search to find relevant audiences for your business' without 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/johnoconnor0/google-ads-mcp'

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