batch_cancel_subscriptions
Cancel multiple subscriptions at once by providing subscriber codes. Optionally send notification emails.
Instructions
Batch Cancel Subscriptions
Cancela múltiplas assinaturas em lote.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subscriber_code | Yes | Lista de códigos de assinantes | |
| send_mail | No | Enviar e-mail de notificação aos assinantes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The main handler function for batch_cancel_subscriptions. It calls POST /payments/api/v1/subscriptions/cancel with subscriber_code and optional send_mail parameters, returning JSON results.
async def batch_cancel_subscriptions( subscriber_code: list[str], send_mail: Optional[bool] = None, ) -> str: """Batch Cancel Subscriptions Cancela múltiplas assinaturas em lote. Args: subscriber_code: Lista de códigos de assinantes send_mail: Enviar e-mail de notificação aos assinantes""" endpoint = "/payments/api/v1/subscriptions/cancel" body = {} body["subscriber_code"] = subscriber_code if send_mail is not None: body["send_mail"] = send_mail result = await get_client().post(endpoint, json=body) return json.dumps(result, indent=2) - src/hotmart_mcp/server.py:21-37 (registration)The dynamic registration logic in _discover_and_register_tools() that discovers all async functions in the tools package and registers them as MCP tools via mcp.tool()(obj).
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 function signature serves as the schema: subscriber_code (list[str]) and send_mail (Optional[bool]).
async def batch_cancel_subscriptions( subscriber_code: list[str], send_mail: Optional[bool] = None, ) -> str: """Batch Cancel Subscriptions Cancela múltiplas assinaturas em lote. Args: subscriber_code: Lista de códigos de assinantes send_mail: Enviar e-mail de notificação aos assinantes""" endpoint = "/payments/api/v1/subscriptions/cancel" body = {} body["subscriber_code"] = subscriber_code if send_mail is not None: body["send_mail"] = send_mail result = await get_client().post(endpoint, json=body) return json.dumps(result, indent=2) - src/hotmart_mcp/_shared.py:10-14 (helper)The get_client() helper that provides the shared HotmartClient instance used by the handler to make HTTP requests.
def get_client() -> HotmartClient: global _client if _client is None: _client = HotmartClient() return _client