# Polar.sh MCP

> Polar.sh manages open-source monetization, SaaS billing, and digital product delivery. Connect it to your agent to list products, track customer orders, generate invoices, and manage subscriptions—all from natural language. It's a centralized system for running the business side of your code.

## Overview
- **Category:** developer-tools
- **Price:** Free
- **Tags:** monetization, open-source, saas-billing, subscription-management, developer-economy

## Description

Connect Polar.sh to any AI client to handle all aspects of open-source monetization and SaaS billing using plain English.

### What You Can Do

*   **Product Catalog:** List, create, or update digital goods and physical products. Manage benefits and recurring pricing models with `list_products` and `create_product`.
*   **Billing & Orders:** Check sales history, retrieve specific order details using `get_order`, and generate professional invoices via `generate_invoice`.
*   **Access Control (Subscriptions):** List active users, grant free subscriptions for community members, or immediately revoke access when needed with `revoke_subscription`.
*   **Checkout Funnel:** Inspect checkout sessions to understand where customers drop off using `list_checkouts`.

### How It Works

1.  Subscribe to the Polar server and enter your Polar Personal Access Token. 
2.  Your AI agent connects this token to the service.
3.  You manage your entire developer business—from billing inquiries to product updates—directly through your preferred client (Claude, Cursor, etc.).

## Tools

### confirm_checkout_client
Confirms a specific checkout session from the client side.

### create_benefit
Creates and defines a new benefit for customers.

### create_checkout
Starts a new billing session to capture customer intent and details.

### create_customer_session
Generates a secure token needed to initiate a customer billing session.

### create_customer
Creates a brand-new customer record in the system.

### create_product
Defines and adds a new product to the store catalog.

### create_subscription
Sets up a free subscription for a user account (limited to products).

### create_webhook_endpoint
Creates an external URL endpoint that will receive data updates from Polar.

### delete_benefit
Removes a benefit and revokes all associated user grants immediately.

### generate_invoice
Creates a formal invoice record for a specific order ID.

### get_benefit
Retrieves the detailed definition of a single product benefit.

### get_checkout
Fetches all details about a specific, ongoing checkout session.

### get_customer_state
Retrieves a complete profile showing the customer's current subscriptions and benefits.

### get_invoice
Fetches the stored data of an invoice that was previously generated.

### get_order
Retrieves all historical details for a single customer order ID.

### get_portal_me
Gets the basic profile information of the currently authenticated user.

### get_product
Retrieves all details for a specific product ID or SKU.

### get_subscription
Fetches the current status and renewal dates of an active subscription.

### list_benefits
Lists all benefits that have been defined in the system.

### list_checkouts
Retrieves a list of recent, completed, or abandoned checkout sessions.

### list_customers
Lists all customer accounts in the system, often filtered by criteria.

### list_orders
Retrieves a paginated list of multiple historical order records.

### list_portal_benefit_grants
Shows which benefits have been granted to specific customers by the portal.

### list_portal_license_keys
Lists all license keys assigned to customer accounts.

### list_portal_orders
Shows a list of orders associated with the developer portal account.

### list_portal_subscriptions
Lists all subscriptions tied to a specific developer portal customer.

### list_products
Filters and lists available products, allowing filtering by recurrence or organization ID.

### list_subscriptions
Provides a list of all active subscriptions across the platform.

### list_webhook_deliveries
Lists and monitors the delivery status of webhooks.

### revoke_subscription
Immediately cancels or revokes a customer's active subscription access.

### update_checkout
Modifies the details of an existing, in-progress checkout session.

### update_order
Updates non-billing data on a historical order record (e.g., billing address).

### update_product_benefits
Changes which benefits a specific product grants to its users.

### update_product
Modifies the details of an existing product in the catalog.

### update_subscription
Updates details for an existing subscription, such as billing cycles or plan names.

### validate_portal_license_key
Checks if a given license key is active and valid against the customer account.

## Prompt Examples

**Prompt:** 
```
List all my active products on Polar.
```

**Response:** 
```
I've retrieved your products. You have 3 active items: 'Developer Pro' (ID: prod_1), 'Sponsorship' (ID: prod_2), and 'API Access' (ID: prod_3). Would you like to see the details for any of these?
```

**Prompt:** 
```
Get the details for order ID 'ord_123' and generate an invoice.
```

**Response:** 
```
Order 'ord_123' was placed by user@example.com for $50.00. I have successfully triggered the `generate_invoice` action for this order. You can now retrieve the invoice data using `get_invoice`.
```

**Prompt:** 
```
Revoke subscription 'sub_999' immediately.
```

**Response:** 
```
I have successfully revoked subscription 'sub_999'. The customer's access to the associated product benefits has been terminated.
```

## Capabilities

### Manage Product Catalogs
Create new digital products or update existing ones using `create_product` and `update_product`.

### Process Billing and Orders
List all customer orders (`list_orders`), check specific order details (`get_order`), or generate an invoice record (`generate_invoice`).

### Control User Access
Create free subscriptions for community members (`create_subscription`) or immediately terminate access using `revoke_subscription`.

### Inspect Billing Sessions
Review the checkout funnel by listing recent sessions with `list_checkouts` and getting details with `get_checkout`.

### View Customer Status
Get a full overview of any customer's active subscriptions, benefits, and account status using `get_customer_state`.

## Use Cases

### Handling an Abandoned Subscription
A community member tries to upgrade but quits halfway through. The agent runs `list_checkouts` to find the session ID, then uses `get_checkout` to see exactly where they got stuck (e.g., tax calculation failure). This data tells you precisely how to adjust your product or billing flow.

### Generating Quarterly Reports
The finance team needs a report on all paid users last quarter. You ask the agent to run `list_orders` and filter by date range, then use `get_invoice` for the top 10 largest orders to manually compile key data points.

### Onboarding a New Partner
A new partner needs access to a premium feature benefit. Instead of emailing a manual grant, you instruct your agent to run `create_benefit` first (if needed), and then use `create_subscription` to instantly activate that benefit for their account.

### Auditing Product Changes
Product pricing changed, but the billing system needs updating. You instruct your agent to run `get_product` first to confirm old details, then use `update_product` and finally `list_products` to verify the change went live correctly.

## Benefits

- Automate access control: Instead of emailing manual revocation notices, call `revoke_subscription` to immediately terminate user access when payment fails. This is a critical workflow step.
- Full financial oversight: Get the complete picture by running `get_customer_state`. It pulls together active subscriptions and benefits into one readable report for customer support.
- Handle billing history: Need to know why an invoice was generated? Use `get_order` or `list_orders` to pull up every detail, including item costs and dates. No more guessing games.
- Build the catalog dynamically: When you launch a new digital good, use `create_product`. This tool makes sure your agent knows exactly what products are available for purchase right away.
- Inspect conversion paths: Before writing code to fix a payment issue, run `list_checkouts` and `get_checkout`. You can pinpoint if the failure happened on step 1 or step 3 of the checkout process.

## How It Works

The bottom line is you manage complex billing tasks without leaving your terminal or editor.

1. Subscribe to the server and provide your Polar Personal Access Token.
2. Your AI client authenticates with the server using that token.
3. You issue commands in natural language (e.g., 'Show me all active subscriptions for user X') which map directly to specific tools.

## Frequently Asked Questions

**How do I check if a user can afford to use Polar.sh with the list_orders tool?**
The `list_orders` tool only pulls historical order data. If you need current payment status, you must first run `get_customer_state` to see active subscriptions and benefits.

**Can I use Polar.sh to cancel a subscription using the revoke_subscription tool?**
Yep. `revoke_subscription` immediately cancels access for a specified user ID. It's the quickest way to terminate service after a billing issue.

**What if I need to update an order but don't know the ID? Can Polar.sh help with get_order?**
No, `get_order` requires a precise Order ID. If you don't have it, start by running `list_orders`, then locate the record and use that specific ID.

**How do I manage product benefits with Polar.sh?**
You can define them using `create_benefit` or update existing ones via `update_product_benefits`. The best practice is to check the current state first by running `list_benefits`.

**Can I cancel a user's subscription through the AI?**
Yes, you can use the `revoke_subscription` tool by providing the specific Subscription ID to terminate access immediately.

**How do I generate an invoice for a specific order?**
Simply use the `generate_invoice` tool with the Order ID. The agent will trigger the invoice generation process on Polar.sh.

**Is it possible to update the benefits of an existing product?**
Yes, the `update_product_benefits` tool allows you to modify the array of benefit IDs associated with any of your products.