Skip to main content

Using MCP tools as an API

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

Written by Kellie Reese

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 with n8n

See an example with n8n at the end of this document.


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.


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

Did this answer your question?