Skip to main content
Glama

get_invoice

Retrieve a specific invoice by its unique ID from the Stream MCP server to access billing details and payment information.

Instructions

Get a single invoice by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoice_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The get_invoice tool handler - fetches a single invoice by ID using the Stream API. Takes invoice_id parameter, makes GET request to /api/v2/invoices/{invoice_id}, and returns the invoice data or error details.
    @mcp.tool
    async def get_invoice(
        invoice_id: str,
        ctx: Context = None,  # type: ignore[assignment]
    ) -> dict[str, Any]:
        """Get a single invoice by ID."""
        client = await get_client(ctx)
        try:
            return await client.get(f"{_BASE}/{invoice_id}")
        except StreamAPIError as exc:
            return _err(exc)
  • The register function that defines and registers all invoice tools including get_invoice. The @mcp.tool decorator on line 116 registers get_invoice with the FastMCP server.
    def register(mcp: FastMCP) -> None:
        """Register all invoice tools on *mcp*."""
    
        @mcp.tool
        async def create_invoice(
            customer_id: str,
            items: list[dict],
            scheduled_on: str | None = None,
            description: str | None = None,
            currency: str = "SAR",
            notify_consumer: bool = True,
            coupons: list[str] | None = None,
            accept_mada: bool = True,
            accept_visa: bool = True,
            accept_mastercard: bool = True,
            accept_amex: bool = False,
            accept_bank_transfer: bool = False,
            accept_installment: bool = False,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """Create a ZATCA-compliant invoice in Stream.
    
            *items* is a list of line-item dicts, each with:
              - product_id  (str, required)
              - quantity    (int > 0, required)
    
            *scheduled_on* is the ISO-8601 date-time for when the invoice is due/sent.
            Set *notify_consumer* to True to send the invoice to the customer.
            """
            parsed_items = [InvoiceItemCreateDto(**item) for item in items]
            if scheduled_on is None:
                scheduled_on = datetime.now(timezone.utc).isoformat()
            payment_methods = InvoicePaymentMethodDto(
                mada=accept_mada,
                visa=accept_visa,
                mastercard=accept_mastercard,
                amex=accept_amex,
                bank_transfer=accept_bank_transfer,
                installment=accept_installment,
            )
            body = CreateInvoiceRequest(
                organization_consumer_id=customer_id,
                items=parsed_items,
                payment_methods=payment_methods,
                scheduled_on=scheduled_on,
                notify_consumer=notify_consumer,
                description=description,
                coupons=coupons,
                currency=currency,
            )
            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_invoices(
            page: int = 1,
            limit: int = 20,
            organization_consumer_id: str | None = None,
            statuses: list[str] | None = None,
            payment_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 invoices with optional filters.
    
            Filter by *organization_consumer_id*, *statuses* (DRAFT, CREATED, SENT, ACCEPTED,
            REJECTED, COMPLETED, CANCELED, EXPIRED), *payment_statuses* (PENDING, PROCESSING,
            SUCCEEDED, FAILED, etc.), or a date range.
            """
            params: dict[str, Any] = {"page": page, "limit": limit}
            if organization_consumer_id:
                params["organization_consumer_id"] = organization_consumer_id
            if statuses:
                params["statuses"] = statuses
            if payment_statuses:
                params["payment_statuses"] = payment_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_invoice(
            invoice_id: str,
            ctx: Context = None,  # type: ignore[assignment]
        ) -> dict[str, Any]:
            """Get a single invoice by ID."""
            client = await get_client(ctx)
            try:
                return await client.get(f"{_BASE}/{invoice_id}")
            except StreamAPIError as exc:
                return _err(exc)
  • InvoiceResponse schema - defines the structure of the response returned by get_invoice, including id, customer_id, status, total, currency, and created_at fields.
    class InvoiceResponse(BaseModel):
        """Subset of fields returned by the Stream API for an invoice."""
    
        id: str
        customer_id: str | None = None
        status: str | None = None
        total: float | None = None
        currency: str | None = None
        created_at: str | None = None
    
        model_config = {"extra": "allow"}
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 action ('Get') but does not describe any behavioral traits such as permissions required, rate limits, error handling, or what happens if the ID is invalid. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 is front-loaded with the core action. There is no wasted wording, and it directly communicates the essential information without unnecessary elaboration, 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.

Completeness4/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, the description is reasonably complete for its purpose. It covers the basic action and parameter intent, and the output schema likely handles return values. However, without annotations and with minimal behavioral details, it could be more comprehensive for a retrieval tool in a financial context.

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 description adds minimal meaning beyond the input schema, which has 0% description coverage. It mentions 'by ID' to clarify the purpose of the 'invoice_id' parameter, but does not provide details on format, constraints, or examples. With only one parameter and low schema coverage, this offers some compensation but remains basic.

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 verb ('Get') and resource ('a single invoice by ID'), making the purpose specific and understandable. It distinguishes from sibling tools like 'list_invoices' by specifying retrieval of a single item. However, it doesn't explicitly differentiate from other 'get_' tools like 'get_customer' or 'get_product', which follow the same pattern.

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?

The description implies usage when needing a specific invoice by its ID, but provides no explicit guidance on when to use this versus alternatives like 'list_invoices' or other retrieval tools. It lacks context about prerequisites, error conditions, or comparisons with siblings, leaving usage somewhat inferred rather than clearly defined.

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