# Analyze your Stripe data with AI

Connect an AI agent to the Stripe MCP server to query metrics, run financial reports, and analyze your data.

The Stripe Model Context Protocol (MCP) server lets an AI agent analyze aggregated data across your Stripe account. Instead of reading individual API objects one at a time, you can ask for metrics such as monthly recurring revenue (MRR), run financial reports, and run SQL queries against your reporting tables.

## Tools 

Two MCP tools are behind the analytics workflow:

- `stripe_analytics` handles three kinds of requests:
  - Metric queries for Stripe-defined metrics such as MRR and gross volume
  - Template runs for subscription and billing metrics such as churn rate and subscriber counts (which you can break down by product or price)
  - SQL query runs against your reporting tables for custom analysis
- `stripe_report` searches available financial report types and creates report runs for reports such as balance, payouts, activity, tax, and Revenue Recognition. Report runs generate downloadable CSV files.

## What you can analyze 

You can ask an AI agent to do the following:

- Query [Stripe-defined metrics](https://docs.stripe.com/data/analytics.md) such as MRR, churn rate, active subscribers, and gross volume (`stripe_analytics`).
- Run pre-built templates for [subscription and billing metrics](https://docs.stripe.com/billing/subscriptions/analytics.md) (`stripe_analytics`).
- Run [financial reports](https://docs.stripe.com/reports/api.md) such as balance, payouts, activity, tax, and Revenue Recognition (`stripe_report`).
- Run [SQL queries](https://docs.stripe.com/reports/query-runs.md) against your reporting tables for custom analysis (`stripe_analytics`).

## Connect your AI agent 

To connect the Stripe MCP server to your agent, install the official agent plugin. See [Build on Stripe with AI](https://docs.stripe.com/agents.md) for setup instructions. Afterwards, grant the required permissions to your AI agent.

You can authorize the analytics and reporting tools either using OAuth or with an API key.

### OAuth

When you connect an [MCP client](https://docs.stripe.com/mcp.md#manual) that supports OAuth, authorize the following permissions in the consent screen:

- **Analytics**: `Write`
- **Reporting**: `Write`
- **Sigma**: `Write`

These tools require write permissions because they use HTTP POST operations. However, the tools don’t modify or write to your data.

### API key

> #### Protect your API keys
> 
> Don’t embed an API key in code. Provide keys to your agent through an environment variable or a secrets vault.

To create an API key with the required permissions:

1. Go to the [API keys page](https://dashboard.stripe.com/apikeys) in the Dashboard.
2. Create or edit a restricted key.
3. Set the following permissions:
   - **Analytics**: `Write`
   - **Reporting**: `Write`
   - **Sigma**: `Write`

These tools require write permissions because they use HTTP POST operations. However, the tools don’t modify or write to your data.

## Example prompts 

Ask your agent questions in plain language, and it selects the right tool and returns the results. Report runs and SQL queries run asynchronously, so some answers take a moment to complete. For the full list of metrics you can query, see [Supported metrics](https://docs.stripe.com/data/analytics/supported-metrics.md).

### Query metrics (Private preview)

The following prompts cause an agent to use `stripe_analytics` to pull Stripe-defined metrics over a time range. It discovers metrics with the `list_analytics` intent and queries them with `execute_analytics`.

- What’s my MRR for the last 6 months, by month?
- Show my net MRR churn rate this year.
- How many active subscribers do I have, grouped by product?

### Analyze subscriptions and billing (Public preview)

The following prompts cause an agent to use `stripe_analytics` for subscription and billing metrics, broken down by product or price. It starts a template with the `execute_query_template` intent and returns results through `retrieve_query_template`.

- What’s my subscriber churn rate by product this quarter?
- How much revenue did I lose to churn last month?
- Compare new subscribers and churned subscribers by month this year.
- Show active subscriber growth for my top five products.

### Run financial reports (Public preview)

The following prompts cause an agent to use `stripe_report` to find report types and generate report runs. It finds reports with the `search_report_type` and `retrieve_report_type` intents, then generates them with `create_report_run` and `retrieve_report_run`.

- What report types are available for payouts?
- Run the balance summary report for last month.

### Run SQL queries (Public preview)

The following prompts cause an agent to use `stripe_analytics` to run SQL against your reporting tables. It explores tables with the `search_query_tables` and `retrieve_query_table` intents, then runs SQL with `execute_query_run` and `retrieve_query_run`.

- What reporting tables can I query about charges?
- Total my refunds by month for this year.

## Limitations 

- The tools read data from your own account only. Connect platforms can’t use them to read connected account data.
- The available metrics and reports can change during public preview.
- If an agent calculates a metric itself from raw data, the result can differ from how Stripe officially calculates it. For example, an agent that sums subscription amounts to estimate MRR doesn’t match Stripe’s [MRR definition](https://docs.stripe.com/billing/subscriptions/analytics.md#mrr). `stripe_analytics` is always accurate for [Stripe-defined metrics](https://docs.stripe.com/data/analytics.md).

## See also

- [Build on Stripe with AI](https://docs.stripe.com/agents.md)
- [Stripe skills](https://docs.stripe.com/skills.md)
