Skip to main content
Glama

get_payment_link

Retrieve a payment link by its ID to access payment details and status information for processing transactions.

Instructions

Retrieve a single payment link by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
payment_link_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The get_payment_link tool handler - retrieves a single payment link by ID using the Stream API client. Accepts payment_link_id parameter and returns the API response or error details.
    @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)
  • The register function that registers all payment-link tools including get_payment_link. This is called by register_all_tools to expose the tool to 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)
  • PaymentLinkResponse schema defining the structure of data returned when retrieving a payment link (id, url, status, name, description, created_at, with extra fields allowed).
    class PaymentLinkResponse(BaseModel):
        """Subset of fields returned by the Stream API for a payment link."""
    
        id: str
        url: str | None = None
        status: str | None = None
        name: str | None = None
        description: str | None = None
        created_at: str | None = None
    
        model_config = {"extra": "allow"}
  • Error helper function that formats StreamAPIError exceptions into a consistent dict structure with error, code, message, and details fields.
    def _err(exc: StreamAPIError) -> dict[str, Any]:
        return {"error": True, "code": exc.status_code, "message": str(exc), "details": exc.body}
  • register_all_tools function that imports and calls payment_links.register(mcp) to make all payment link tools available to the MCP server.
    def register_all_tools(mcp: FastMCP) -> None:
        """Import every tool / resource module and call its ``register(mcp)``."""
        from stream_mcp.tools import (
            coupons,
            customers,
            docs,
            invoices,
            payment_links,
            payments,
            products,
        )
    
        payment_links.register(mcp)
        customers.register(mcp)
        products.register(mcp)
        payments.register(mcp)
        coupons.register(mcp)
        invoices.register(mcp)
        docs.register(mcp)
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 retrieves data, implying a read-only operation, but does not address permissions, error handling, or rate limits. This leaves significant gaps in understanding the tool's behavior beyond basic functionality.

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 directly states the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured.

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 low complexity (one parameter) and the presence of an output schema (which handles return values), the description is minimally adequate. However, it lacks details on behavioral aspects like authentication or error cases, which are important for a retrieval tool with no annotations.

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?

The schema description coverage is 0%, but the description adds meaning by specifying that the parameter 'payment_link_id' is used to retrieve a single payment link. However, it does not detail the ID format or constraints, so it partially compensates for the schema gap without fully documenting the parameter.

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 ('Retrieve') and resource ('a single payment link by its ID'), making the purpose unambiguous. However, it does not explicitly differentiate from sibling tools like 'list_payment_links' or 'get_payment', which could enhance clarity further.

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 such as 'list_payment_links' for multiple links or 'get_payment' for related resources. It lacks context on prerequisites or exclusions, leaving usage decisions to inference.

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