Skip to main content
Glama

get_coupon

Retrieve a specific coupon by its ID from the Stream payment platform to access discount details and apply to purchases.

Instructions

Get a single coupon by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coupon_idYes

Implementation Reference

  • The get_coupon tool handler function - accepts a coupon_id and retrieves a single coupon from the Stream API
    @mcp.tool
    async def get_coupon(
        coupon_id: str,
        ctx: Context = None,  # type: ignore[assignment]
    ) -> dict[str, Any]:
        """Get a single coupon by ID."""
        client = await get_client(ctx)
        try:
            return await client.get(f"{_BASE}/{coupon_id}")
        except StreamAPIError as exc:
            return _err(exc)
  • CouponResponse schema defining the structure of data returned by the get_coupon tool
    class CouponResponse(BaseModel):
        """Subset of fields returned by the Stream API for a coupon."""
    
        id: str
        name: str | None = None
        type: str | None = None
        value: float | None = None
        status: str | None = None
        created_at: str | None = None
    
        model_config = {"extra": "allow"}
  • The register function that registers the get_coupon tool with FastMCP using the @mcp.tool decorator
    def register(mcp: FastMCP) -> None:
        """Register all coupon tools on *mcp*."""
    
        @mcp.tool
        async def create_coupon(
  • Call to coupons.register(mcp) which triggers registration of the get_coupon tool
    coupons.register(mcp)
  • Call to register_all_tools which ultimately registers get_coupon on the FastMCP instance
    register_all_tools(mcp)

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