Skip to main content
Glama

deactivate_payment_link

Archive a payment link to prevent further transactions. Specify a payment link ID to disable it from accepting payments.

Instructions

Deactivate (archive) a payment link so it can no longer be used.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payment_link_idYes
deactivate_messageNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for deactivate_payment_link tool. It takes payment_link_id and optional deactivate_message parameters, creates an UpdatePaymentLinkStatusRequest with status 'INACTIVE', and makes a PATCH request to the Stream API to deactivate/archiving the payment link.
    async def deactivate_payment_link(
        payment_link_id: str,
        deactivate_message: str | None = None,
        ctx: Context = None,  # type: ignore[assignment]
    ) -> dict[str, Any]:
        """Deactivate (archive) a payment link so it can no longer be used."""
        body = UpdatePaymentLinkStatusRequest(
            status="INACTIVE",
            deactivate_message=deactivate_message,
        )
        client = await get_client(ctx)
        try:
            return await client.patch(
                f"{_BASE}/{payment_link_id}/status",
                body.model_dump(exclude_none=True),
            )
        except StreamAPIError as exc:
            return _err(exc)
  • Pydantic schema definition for UpdatePaymentLinkStatusRequest, which validates the request body when deactivating a payment link. It requires a status field ('INACTIVE', 'ACTIVE', or 'COMPLETED') and optionally a deactivate_message.
    class UpdatePaymentLinkStatusRequest(BaseModel):
        """Request body for updating a payment link status."""
    
        status: str = Field(..., description="New status: INACTIVE, ACTIVE, or COMPLETED.")
        deactivate_message: str | None = Field(default=None, description="Message shown when link is deactivated.")
  • The register function that registers all payment link tools including deactivate_payment_link. The function is decorated with @mcp.tool which automatically registers it with the MCP server.
    def register(mcp: FastMCP) -> None:
        """Register all payment-link tools on *mcp*."""
    
        @mcp.tool
        async def create_payment_link(
            name: str,
            items: list[dict],
            description: str | None = None,
            currency: str = "SAR",
            valid_until: str | None = None,
            max_number_of_payments: int | None = None,
            organization_consumer_id: str | None = None,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """Create a new payment / checkout link on Stream.
    
            *items* is a list of objects, each containing:
              - product_id (str, required)
              - quantity   (int ≥ 1, optional, default 1)
              - coupons    (list[str], optional)
    
            You **cannot** mix one-time and recurring products in the same link.
            """
            body = CreatePaymentLinkRequest(
                name=name,
                items=items,  # type: ignore[arg-type]
                description=description,
                currency=currency,
                valid_until=valid_until,
                max_number_of_payments=max_number_of_payments,
                organization_consumer_id=organization_consumer_id,
            )
            client = await get_client(ctx)
            try:
                return await client.post(_BASE, body.model_dump(exclude_none=True))
            except StreamAPIError as exc:
                return _err(exc)
    
        @mcp.tool
        async def list_payment_links(
            page: int = 1,
            limit: int = 20,
            statuses: list[str] | None = None,
            from_date: str | None = None,
            to_date: str | None = None,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """List all payment links with optional filters.
    
            *statuses* can include: INACTIVE, ACTIVE, COMPLETED.
            """
            params: dict[str, Any] = {"page": page, "limit": limit}
            if statuses:
                params["statuses"] = statuses
            if from_date:
                params["from_date"] = from_date
            if to_date:
                params["to_date"] = to_date
            client = await get_client(ctx)
            try:
                return await client.get(_BASE, params=params)
            except StreamAPIError as exc:
                return _err(exc)
    
        @mcp.tool
        async def get_payment_link(
            payment_link_id: str,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """Retrieve a single payment link by its ID."""
            client = await get_client(ctx)
            try:
                return await client.get(f"{_BASE}/{payment_link_id}")
            except StreamAPIError as exc:
                return _err(exc)
    
        @mcp.tool
        async def deactivate_payment_link(
            payment_link_id: str,
            deactivate_message: str | None = None,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """Deactivate (archive) a payment link so it can no longer be used."""
            body = UpdatePaymentLinkStatusRequest(
                status="INACTIVE",
                deactivate_message=deactivate_message,
            )
            client = await get_client(ctx)
            try:
                return await client.patch(
                    f"{_BASE}/{payment_link_id}/status",
                    body.model_dump(exclude_none=True),
                )
            except StreamAPIError as exc:
                return _err(exc)
  • Helper function _err that formats StreamAPIError exceptions into a standardized error dictionary structure, used by deactivate_payment_link for error handling.
    def _err(exc: StreamAPIError) -> dict[str, Any]:
        return {"error": True, "code": exc.status_code, "message": str(exc), "details": exc.body}
  • Helper function get_client that retrieves the appropriate StreamClient for the current request context, supporting both local (lifespan) and remote (per-user Bearer token) modes. Used by deactivate_payment_link to make API calls.
    async def get_client(ctx: "Context") -> StreamClient:
        """Return a :class:`StreamClient` for the current request.
    
        Resolution order:
    
        1. **Lifespan client** — used in local / stdio mode where a single
           ``STREAM_API_KEY`` is set as an environment variable.
        2. **Per-user client** — used in remote mode where each user passes
           their own API key as a Bearer token and (optionally) a custom
           base URL via the ``X-Stream-Base-URL`` header.
        """
        # ── 1. Local mode: shared client from server lifespan ─────────────
        shared_client = ctx.lifespan_context.get("client")
        if shared_client is not None:
            return shared_client
    
        # ── 2. Remote mode: per-user client from Bearer token ─────────────
        api_key = current_api_key.get()
        if not api_key:
            raise StreamError(
                "No Stream API key found. "
                "In local mode, set the STREAM_API_KEY env var. "
                "In remote mode, pass your key as a Bearer token in the Authorization header."
            )
    
        base_url = current_base_url.get() or settings.stream_base_url
        cache_key = f"{api_key}::{base_url}"
    
        if cache_key not in _client_cache:
            client = StreamClient(
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool deactivates/archives a payment link, implying a mutation operation, but lacks details on permissions required, whether the action is reversible, rate limits, or what 'archive' entails (e.g., hidden vs. deleted). This is insufficient for a mutation tool without annotations.

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 a single, efficient sentence that front-loads the core action and outcome. There is no wasted verbiage, and it directly communicates the tool's function without unnecessary elaboration.

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?

Given the tool's complexity (a mutation with 2 parameters), lack of annotations, and presence of an output schema (which may cover return values), the description is minimally complete. It states what the tool does but misses key contextual details like parameter meanings, behavioral traits, and usage guidelines, making it adequate but with clear gaps.

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 description coverage is 0%, so the schema provides no parameter details. The description doesn't mention any parameters, leaving both 'payment_link_id' and 'deactivate_message' unexplained. However, with only 2 parameters and a baseline of 3 when schema coverage is low but not compensated, the score reflects minimal adequacy without added value.

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 ('deactivate (archive)') and resource ('a payment link'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'archive_product' or 'deactivate_coupon', which would require mentioning payment-link-specific context to achieve a perfect score.

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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., the link must exist), exclusions (e.g., cannot deactivate already deactivated links), or comparisons with siblings like 'delete_customer' or 'void_invoice', leaving the agent without contextual usage cues.

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/streampayments/stream'

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