Skip to main content

Using MCP tools as an Open API

This article explains how to use Polar API — via the Model Context Protocol (MCP) — as an open API, detailing available endpoints, authentication, and a quick-start workflow for generating reports and accessing dashboard data.

Written by Kellie Reese
Updated yesterday

In a world where data flows through countless dashboards, spreadsheets, and analytics tools, tapping into real business insights can quickly become chaotic — especially when you need to combine, automate, or share that data programmatically. The Polar API, built on the MCP standard, offers a streamlined and flexible alternative: instead of manually exporting CSVs or copying dashboard views, you can directly query your analytics data via API calls. This approach empowers developers and data teams to integrate analytics-driven workflows into their applications, automate report generation, and embed business insights into existing tools with just a few lines of code.

The Polar API allows you to programmatically access dashboards, reports, and analytics data from your Polar workspace.

While multiple endpoints exist, most developers will primarily use the Generate Report endpoint to fetch data.

Quick Start

Upload an example workflow as a JSON from the file below. You just need to add your API key and slack credentials and run it to get orders by sales channel.
Get orders by Sales Channel (template).json


Authentication

To access the Polar API, you’ll need to generate an API Key in the Polar MCP page.

  1. Go to Polar MCP in the app

  2. Generate / Copy an API key

  3. Pass the key as a Bearer token in the Authorization header for all requests:

    Authorization: Bearer <YOUR_API_KEY>


Base URL:

https://api.polaranalytics.com/mcp

Tool endpoint pattern:

POST https://api.polaranalytics.com/mcp/tool/<tool_name>

Core Endpoint: Generate Report

This is the main endpoint you’ll use day-to-day.

It generates a custom analytics report with rows of data, totals, and a Polar deep link.

Endpoint:

POST POST

Description:

Generate a custom analytics report with rows, a totals row, and a deep link.

Required Arguments:

  • conversation_id (string) — from /tools/get_context

  • metrics (string, comma-separated keys)

  • dimensions (string, comma-separated names)

  • dateRangeFrom (string, YYYY-MM-DD)

  • dateRangeTo (string, YYYY-MM-DD)

  • granularity (enum: none|day|week|month|year)

  • ordering (string, e.g. billing_country:DESC,total_orders:DESC)

  • settings (object, attribution config or {} if not needed)

  • rules (object, dimension filters)

  • metricRules (object, metric filters)

  • views (string, optional, comma-separated IDs)

  • reflexion (string, description of intent, can leave empty string)

Response Example:

{ 
"data": [
{ "customer_country": "US", "total_orders": 1200, "revenue": 30000 },
{ "customer_country": "CA", "total_orders": 450, "revenue": 12000 }
],
"totals": { "total_orders": 1650, "revenue": 42000
},
"link": "https://app.polar.sh/report/xyz"
}

Always use the totals returned by the API instead of recomputing sums from rows.


Supporting Endpoints

  1. Get Context

    Endpoint:

    POST /tools/get_context

    Arguments:

    • initialQuestion (string)

    Response Example:

    { 
    "conversation_id": "abc123", "workspace": { "currency": "USD", "timezone": "America/New_York" }, "metrics": [{ "key": "total_orders", "label": "Total Orders" }], "dimensions": [{ "key": "customer_country", "label": "Customer Country" }]
    }

    2. List Dashboards

    Endpoint:

    POST /tools/list_dashboards

    Arguments:

    • conversation_id (string)

    3. Get Dashboard Details

    Endpoint:

    POST /tools/get_dashboard_details

    Arguments:

    • conversation_id (string)

    • dashboard_id (string)

    4. List Dimensions

    Endpoint:

    POST /tools/list_dimensions

    Arguments:

    • conversation_id (string)

    • metrics (string, comma-separated)

    Response Example:

    { 
    "breakdowns": ["customer_country", "utm_source"], "filters": ["device_type"], "views": [{ "id": "premium_customers", "label": "Premium Customers" }], "settings": { "attribution_model": [ { "value": "last_click", "label": "Last Click" }, { "value": "linear", "label": "Linear" }
    ]
    }
    }

    5. Get View Details

    Endpoint:

    POST /tools/get_view_details

    Arguments:

    • conversation_id (string)

    • view (string)

    6. Generate Report Link

    Endpoint:

    POST /reports/link

    Arguments: (same as /reports, plus)

    • reportMode (enum: table|bar|pie)

    Response Example:

    { "link": "https://app.polar.sh/report/xyz?view=bar" }

    7. Rate Report

    Endpoint:

    POST /tools/rate_report

    Arguments:

    • conversation_id (string)

    • rate (string, 1–10)

    • reflexion (string)


Example Workflow

  1. Call /tools/get_context → get conversation_id, metrics, dimensions.

  2. Call /tools/list_dimensions → check compatible filters/breakdowns.

  3. Call /tools/generate_report → fetch the actual data (main call - can be done many times).

  4. Optionally call /tools/generate_report_link → generate a Polar deep link for the report.


Adopting the Polar API through MCP transforms analytics from a manual, error-prone process into a seamless, programmatic experience. By exposing dashboard, report, and view metadata via well-defined endpoints — all protected by simple Bearer-token authentication — you can automate reporting, integrate analytics into downstream systems, and build data-driven tools faster. Whether you're generating aggregated sales reports, embedding analytics into internal dashboards, or automating recurring data extracts — this open API approach ensures your AI agents or applications interact with real, authoritative data, reducing friction and accelerating insights. Embracing this programmatic access sets the foundation for smarter, more scalable data workflows.

Did this answer your question?