# Scarf Analytics MCP Server

MCP server for Scarf package analytics - create filters, analyze company insights, and track usage patterns.

## Quick Start

```bash
npm install
npm run build
npm run dev
```

## Available Tools

### Filter Management

- **`create-insights-filter`** - Create reusable filters for analytics queries
- **`get-insights-filter`** - Retrieve filter by ID
- **`list-insights-filters`** - List all named filters

### Company Analytics

- **`get-company-totals`** - Aggregate metrics for a company
- **`get-consolidated-company-insights`** - Paginated company insights with filtering

## Basic Usage

**1. Create a filter for enterprise prospects:**

```json
{
  "tool": "create-insights-filter",
  "arguments": {
    "filterConfig": {
      "name": "Enterprise Prospects",
      "company_funnelstage": { "ops": ["investigation", "experimentation"] },
      "company_is_fortune_500": { "value": true }
    }
  }
}
```

**2. Use filter to get company insights:**

```json
{
  "tool": "get-consolidated-company-insights",
  "arguments": {
    "insights_filters_id": "filter-id-from-step-1",
    "order_by": ["count_desc"]
  }
}
```

**3. Get detailed metrics for a specific company:**

```json
{
  "tool": "get-company-totals",
  "arguments": {
    "company_domain": "github.com"
  }
}
```

## Local Development

- Owner defaults to "scarf" (no need to specify)
- Dates default to last 30 days
- Uses basic auth instead of API tokens

See `local/claude/mcp-client-guide.md` for detailed examples and workflows.
