Skip to main content
Glama

create_product_set

Create a product set with JSON filter rules for Dynamic Product Ads (DPA) targeting from a product catalog.

Instructions

Create a product set with filter rules for DPA targeting.

Args: catalog_id: Product catalog ID. name: Product set name. filter_json: JSON string of filter rules. Example: '{"product_type":{"i_contains":"shoes"}}'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
catalog_idYes
nameYes
filter_jsonYes

Implementation Reference

  • The main handler function for the create_product_set tool. Decorated with @mcp.tool() and registered via the catalogs module import in server.py. Creates a product set by making a POST request to Meta's Graph API /{catalog_id}/product_sets endpoint after validating name and filter_json inputs.
    @mcp.tool()
    def create_product_set(
        catalog_id: str,
        name: str,
        filter_json: str,
    ) -> dict:
        """
        Create a product set with filter rules for DPA targeting.
    
        Args:
            catalog_id: Product catalog ID.
            name: Product set name.
            filter_json: JSON string of filter rules.
                Example: '{"product_type":{"i_contains":"shoes"}}'
        """
        import json as _json
    
        if not name or not name.strip():
            return {"error": "name is required.", "blocked_at": "input_validation"}
    
        try:
            filters = _json.loads(filter_json)
            if not isinstance(filters, dict):
                return {"error": "filter_json must be a JSON object.", "blocked_at": "input_validation"}
        except _json.JSONDecodeError as e:
            return {"error": f"Malformed filter_json: {e}", "blocked_at": "input_validation"}
    
        api_client._ensure_initialized()
    
        try:
            result = api_client.graph_post(
                f"/{catalog_id}/product_sets",
                data={
                    "name": name.strip(),
                    "filter": _json.dumps(filters),
                },
            )
        except MetaAPIError as e:
            return {"error": f"Meta API error: {e}", "blocked_at": "api_call"}
    
        ps_id = result.get("id")
        return {
            "product_set_id": ps_id,
            "catalog_id": catalog_id,
            "name": name.strip(),
            "filter": filters,
            "rate_limit_usage_pct": api_client.rate_limits.max_usage_pct,
        }
  • Input parameters defined in the function signature: catalog_id (str), name (str), filter_json (str). No dedicated Pydantic schema; validation is inline.
    def create_product_set(
        catalog_id: str,
        name: str,
        filter_json: str,
    ) -> dict:
  • Registration: the catalogs module (which contains create_product_set) is imported in server.py at line 34. The @mcp.tool() decorator at line 468 registers the function with the FastMCP server instance.
    from meta_ads_mcp.core import catalogs  # noqa: E402, F401
    from meta_ads_mcp.core import audiences  # noqa: E402, F401
  • Imports used by create_product_set: api_client (MetaAPI client for Graph API calls) and MetaAPIError for error handling.
    from meta_ads_mcp.server import mcp
    from meta_ads_mcp.core.api import api_client, MetaAPIError
    from meta_ads_mcp.core.utils import ensure_account_id_format
Behavior2/5

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

No annotations; description implies a write operation but lacks side effects, permissions, or error handling details.

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?

Short, front-loaded, with list of args and example; efficient but could slightly integrate main sentence.

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?

Covers three parameters adequately but no output schema or return value info; lacks details on creation behavior or response.

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?

Provides brief descriptions and an example for filter_json, compensating for 0% schema coverage, but catalog_id and name lack constraints or format details.

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?

Clearly states 'Create a product set with filter rules for DPA targeting', specific verb and resource, distinct from siblings like 'update_product_set'.

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?

No guidance on when to use vs alternatives; no prerequisites or exclusions mentioned.

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/brandu-mos/konquest-meta-ads-mcp'

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