Skip to main content
Glama

get_coupons

Retrieve coupons for a product. Optionally filter by coupon code and paginate results.

Instructions

Get Coupons

Retorna os cupons de um produto.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
product_idYesID do produto
codeNoCódigo do cupom
page_tokenNoToken de paginação para a próxima página
selectNoSeleção de campos customizados na resposta

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async function 'get_coupons' that implements the tool logic. It calls GET /products/api/v1/coupon/product/{product_id} with optional query params (code, page_token, select) and returns JSON.
    async def get_coupons(
        product_id: int,
        code: Optional[str] = None,
        page_token: Optional[str] = None,
        select: Optional[str] = None,
    ) -> str:
        """Get Coupons
        
        Retorna os cupons de um produto.
        
        Args:
            product_id: ID do produto
            code: Código do cupom
            page_token: Token de paginação para a próxima página
            select: Seleção de campos customizados na resposta"""
        endpoint = f"/products/api/v1/coupon/product/{product_id}"
        params = {}
        if code is not None:
            params["code"] = code
        if page_token is not None:
            params["page_token"] = page_token
        if select is not None:
            params["select"] = select
        result = await get_client().get(endpoint, params=params)
        return json.dumps(result, indent=2)
  • The '_discover_and_register_tools' function that auto-discovers and registers all async functions from tool modules (including get_coupons) as MCP tools via mcp.tool().
    def _discover_and_register_tools() -> int:
        """Import all modules under hotmart_mcp.tools and register async functions."""
        registered = 0
    
        for module_info in pkgutil.iter_modules(tools_pkg.__path__, prefix=f"{tools_pkg.__name__}."):
            if module_info.name.endswith("__init__"):
                continue
    
            module = importlib.import_module(module_info.name)
    
            for name, obj in inspect.getmembers(module, iscoroutinefunction):
                if name.startswith("_"):
                    continue
                mcp.tool()(obj)
                registered += 1
    
        return registered
  • The __all__ list in coupons.py that exports 'get_coupons' as a public function, making it discoverable by the registration mechanism.
    __all__ = ["create_coupon", "get_coupons", "delete_coupon"]
  • The function signature and type annotations serve as input schema: product_id (int, required), code (Optional[str]), page_token (Optional[str]), select (Optional[str]). Returns str (JSON).
    async def get_coupons(
        product_id: int,
        code: Optional[str] = None,
        page_token: Optional[str] = None,
        select: Optional[str] = None,
    ) -> str:
  • The 'get_client' helper that provides the HTTP client used by get_coupons to make the API request.
    def get_client() -> HotmartClient:
        global _client
        if _client is None:
            _client = HotmartClient()
        return _client
Behavior2/5

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

No annotations provided, so the description carries full burden. It mentions returning coupons but omits behavioral details such as pagination (implied by page_token parameter), error handling, or authentication requirements. The description is too terse for a tool with multiple parameters.

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 concise with two lines, front-loaded with the tool name. However, it mixes languages (English and Portuguese), which may confuse non-Portuguese users. Still efficient.

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 presence of an output schema, return values are not required. However, the description lacks information on pagination behavior, error conditions, and usage notes. For a tool with 4 parameters and pagination support, the description is incomplete.

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?

Schema coverage is 100%, so baseline is 3. The description adds no extra meaning beyond the schema; it merely restates the tool's purpose. The schema already describes parameters like code, page_token, and select.

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

Purpose4/5

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

The description clearly states the action ('Get Coupons') and the resource ('coupons of a product'), with a Portuguese translation for clarity. It distinguishes from sibling tools like create_coupon and delete_coupon, but does not explicitly differentiate from other get tools.

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

Usage Guidelines3/5

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

No explicit guidance on when to use this tool versus alternatives. The purpose is implied as read-only, but no exclusions or context are provided.

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/thaleslaray/hotmart-mcp'

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