# Polar.sh MCP

> Polar.sh MCP Server manages your open-source monetization and SaaS billing cycle directly through your AI agent. Use it to list products, create subscriptions, track orders, and generate invoices—all from natural language commands in your terminal or editor. It handles the full customer lifecycle, allowing you to manage everything from initial checkout sessions (`create_checkout`) to revoking access when a subscription expires (`revoke_subscription`).

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

## Description

Listen up. **Polar.sh** handles your whole open-source monetization stack—the billing, the subscriptions, the product catalog—and it runs it all straight through your AI agent. You don't gotta switch apps or leave your terminal; you just tell your agent what to do in natural language and it executes the API calls for you.

**Managing Your Product Catalog:**
When you need to sell something, you start by creating it. You use **`create_product`** to register any new digital good. If an existing product needs a name change or a price tweak, you run **`update_product`**. To define what the customer actually gets, you create specific benefits using **`create_benefit`**, and if that benefit is scrapped, running **`delete_benefit`** removes it and revokes every associated user grant. You can see all the perks customers buy into by checking **`list_benefits`**, or get the deep details on one perk using **`get_benefit`**. When you link a benefit to a product, you adjust those ties with **`update_product_benefits`**.

**Handling Customers and Accounts:**
Setting up users is simple. You use **`create_customer`** to add a new account to the billing system. Before a customer can do anything secure, your agent first generates a unique token using **`create_customer_session`**. To check on any user's current standing—what they’re subscribed to and what benefits they’ve got—you run **`get_customer_state`**. For a full rundown of all registered accounts, you can pull a filterable list with **`list_customers`**. If you need to see every single benefit granted to one specific customer, **`list_portal_benefit_grants`** shows it. To check which license keys are out there for an account, run **`list_portal_license_keys`**. You can also view all historical orders tied to a single ID using **`list_portal_orders`**, or see every subscription record for that user with **`list_portal_subscriptions`**.

**Subscriptions and Access Control:**
If you want to give someone access, you use **`create_subscription`**, which initially restricts free product setups. To track what’s going on with a specific paid service, run **`get_subscription`**. If the customer loses their right to access, calling **`revoke_subscription`** instantly terminates their account privileges. You can also update an existing subscription record using **`update_subscription`**. When you need to check if a license key is legit before giving access, use **`validate_portal_license_key`**. For general oversight of all paid services, **`list_subscriptions`** pulls the records, and checking recent user activity comes through **`list_checkouts`**, which gives you a summary list of attempted purchases.

**Billing, Orders, and Funnel Analysis:**
When it's time to get paid, your agent can initiate a purchase by running **`create_checkout`**, or modify details on an existing cart using **`update_checkout`**. Once the process is done, you check the status of that checkout with **`confirm_checkout_client`** or pull all data related to it using **`get_checkout`**. To see a customer's past purchases, use **`get_order`**, and for a summary list of historical orders across the board, run **`list_orders`**, which lets you filter by date or status. When an order is finalized, running **`generate_invoice`** creates a professional invoice file for that specific order ID. You can also retrieve the raw data for any past billing with **`get_invoice`**. If an order needs its details tweaked—say, the shipping address changed—you use **`update_order`**. For tracking how people drop off during checkout, you monitor **`list_checkouts`**. Finally, if your system sends automated updates to a custom endpoint, you first register that URL using **`create_webhook_endpoint`**, and then track the status of those messages with **`list_webhook_deliveries`**.

## Tools

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

### create_benefit
Creates a new, defined product benefit for customers.

### create_checkout
Initiates and creates a new checkout session record.

### create_customer_session
Generates a unique token needed for a customer to start a secure session.

### create_customer
Adds a brand-new customer account to the billing system.

### create_product
Creates and registers a new marketable product or digital good.

### create_subscription
Sets up a new subscription, limited only to free products initially.

### create_webhook_endpoint
Registers a custom URL endpoint where the system sends automated updates.

### delete_benefit
Removes an existing product benefit, which also revokes all associated user grants.

### generate_invoice
Creates and outputs a professional invoice file for a specific order ID.

### get_benefit
Retrieves the detailed information about a specific product benefit.

### get_checkout
Pulls all data related to a specific checkout session record.

### get_customer_state
Gets a full overview of a customer's active subscriptions and granted benefits in one call.

### get_invoice
Retrieves the raw, structured data for a previously generated invoice.

### get_order
Fetches all details about an order placed by a customer.

### get_portal_me
Gets basic profile information for the currently authenticated user making the request.

### get_product
Retrieves detailed metadata about a specific product ID.

### get_subscription
Fetches the full status and billing details of an active subscription.

### list_benefits
Lists all available, defined benefits in your product catalog.

### list_checkouts
Provides a summary list of recent checkout sessions for review.

### list_customers
Returns a filterable list of all registered customer accounts.

### list_orders
Lists historical order records, allowing filtering by date or status.

### list_portal_benefit_grants
Shows every benefit that has been explicitly granted to a specific customer.

### list_portal_license_keys
Provides a list of all license keys associated with customer accounts.

### list_portal_orders
Lists all historical orders tied specifically to a single customer ID.

### list_portal_subscriptions
Shows all subscription records for a specific customer account.

### list_products
Queries and filters your entire product catalog by various criteria.

### list_subscriptions
Lists active or past subscriptions across the whole platform.

### list_webhook_deliveries
Monitors and lists all webhook messages that were delivered (or failed to deliver).

### revoke_subscription
Immediately cancels a subscription, terminating customer access instantly.

### update_checkout
Modifies details on an existing checkout session before finalization.

### update_order
Changes billing or shipping details for a historical order record.

### update_product_benefits
Adjusts which benefits are tied to a specific product offering.

### update_product
Updates the core metadata (like name or price) of an existing product.

### update_subscription
Update a subscription

### validate_portal_license_key
Validate a license key

## 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 Catalog
Create new digital goods and update existing product details using `create_product` and `update_product`.

### Process Orders and Invoices
Retrieve full order details with `get_order` and generate a ready-to-use invoice document via `generate_invoice`.

### Handle User Accounts
List all customers (`list_customers`) and view their complete subscription status, including active benefits, using `get_customer_state`.

### Control Subscriptions
Grant or revoke access by creating new subscriptions (`create_subscription`) or immediately canceling an existing one with `revoke_subscription`.

### Analyze Sales Funnels
Inspect recent checkout sessions using `list_checkouts` to pinpoint where users drop off during the purchase process.

## Use Cases

### Customer needs a refund/adjustment.
A client calls in saying their last invoice was wrong. Instead of digging through email archives, your agent runs `get_order` to verify the original purchase. Then, using `update_order`, it adjusts the billing details and creates a corrected record, resolving the issue in one conversational turn.

### New open-source project launch.
You just finished building a new digital good. You use `create_product` to register it, then call `create_benefit` to define how users access it, and finally set up the payment structure with `update_product_benefits`. It's done before lunch.

### Handling a trial-to-paid upgrade.
A free user is ready to pay. Your agent first calls `create_customer` if they don't exist, then runs `create_checkout` to start the process. Finally, it validates and completes the purchase flow using `confirm_checkout_client`, getting them active billing status.

### Mass account cleanup after a merger.
You need to audit 50 old accounts for compliance. Your agent iterates through `list_portal_subscriptions` and runs `get_customer_state` on each one, giving you an immediate spreadsheet-ready report of who is paying and who needs access revoked.

## Benefits

- Process billing actions instantly: Instead of jumping between the Polar dashboard and a ticketing system, you run `get_order` and then immediately follow up with `generate_invoice`—all through your agent's prompt. You get the final invoice data in seconds.
- Maintain customer history cleanly: Use tools like `list_customers` and `get_customer_state` to pull a single, unified profile view of any user. This means you see their active subscriptions (`list_portal_subscriptions`) alongside all benefits they've ever been granted.
- Manage access control precisely: You can grant or revoke product access on the fly. Need to disable a former client? Call `revoke_subscription` and confirm termination instantly, without touching a web portal.
- Build complex workflows easily: The ability to chain calls—like checking out first (`create_checkout`), updating details (`update_checkout`), and then confirming it all in one prompt—makes multi-step billing tasks feel like single commands.
- Keep your product catalog accurate: Don't manually edit prices. Use `list_products` to see everything, and use `update_product` or `create_benefit` when pricing tiers change. The data stays source-of-truth compliant.

## How It Works

The bottom line is that your agent acts as a universal billing terminal, running complex multi-step API sequences based on simple natural language prompts.

1. Subscribe to this server and provide your Polar Personal Access Token.
2. Reference a specific business action (e.g., 'Generate an invoice for order X').
3. Your AI client calls the necessary tool(s) (like `get_order` followed by `generate_invoice`), and you get the resulting data or confirmation.

## Frequently Asked Questions

**How do I check a customer's total status using Polar.sh MCP Server?**
You run `get_customer_state`. This single call provides an overview of their active subscriptions, all granted benefits, and key billing metadata, letting you know exactly where they stand without making multiple requests.

**Can I generate a refund invoice with Polar.sh MCP Server?**
Yes. You first use `get_order` to pull the order details, then you call `generate_invoice`. This creates the necessary documentation for accounting and record-keeping.

**What if I need to change a product price? Do I use Polar.sh MCP Server?**
Yes, use `update_product` to change the core metadata like pricing. If you are changing which benefits that product offers, use `update_product_benefits` instead.

**Is there an easy way to cancel a subscription using Polar.sh MCP Server?**
Absolutely. Use `revoke_subscription`. This function terminates access immediately and updates the customer's status record without needing any manual web interaction.

**When should I use the Personal Access Token when calling `list_customers` via Polar.sh?**
You must provide your token during setup to authorize the connection. This security measure ensures that only you can view sensitive customer data, like what `list_customers` retrieves.

**If I need external systems notified of changes, how do I use `create_webhook_endpoint` with Polar.sh?**
First, you create the endpoint using this tool. This tells Polar.sh exactly where to send automatic updates whenever a relevant event happens. Use the resulting URL in your system's configuration for real-time data pushes.

**If a customer fails payment, how do I see the attempt using `list_checkouts` with Polar.sh?**
You run `list_checkouts` to pull all session records. The resulting data shows the status and failure reason for every checkout attempt. This lets you troubleshoot conversion issues before they become problems.

**Can I verify which specific benefits were granted using `list_portal_benefit_grants` with Polar.sh?**
Yes, that function shows all grants linked to a customer account. It provides the exact benefit name and when it was awarded, allowing you to audit access control easily.

**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.