MCP Server for AI Agents
Let Claude, ChatGPT, and other AI agents query your analytics directly.
Overview
Echelon Analytics includes a Model Context Protocol (MCP) server that lets AI agents query your analytics via the REST API. Point it at any Echelon instance — local or remote, public or authenticated.
Why MCP?
Instead of copying analytics data into prompts manually, MCP lets AI agents call pre-defined tools to fetch exactly what they need. Ask "how's my site doing?" and the agent queries your real analytics data in the background. 9 read-only tools, zero writes, zero PII exposure.
Quick Start
# Public instance (no token needed) ECHELON_URL=https://ea.islets.app deno task mcp # Local instance with authentication ECHELON_URL=http://localhost:1947 ECHELON_SECRET=your-token deno task mcp
How It Works
The MCP server is a thin bridge between AI agents and the Echelon REST API:
- You set
ECHELON_URLto point at any Echelon Analytics instance - The MCP server starts and connects to the AI agent via stdio (JSON-RPC)
- When you ask a question, the AI agent picks the right MCP tool
- The MCP server calls the corresponding
GET /api/*endpoint (read-only — never POST, PATCH, or DELETE) - The API response is returned to the agent, which summarizes it for you
For authenticated instances, set ECHELON_SECRET — the server passes it as a Bearer token for read-only access. The server only ever calls GET endpoints; it cannot create, modify, or delete any data even if the token has write privileges. For PUBLIC_MODE instances (like the public demo), no token is needed.
Setup
1. Claude Code
The repo includes .claude/settings.json which auto-registers the MCP server. By default it points at the public demo instance. To use your own instance, edit the env block:
{
"mcpServers": {
"echelon-analytics": {
"command": "deno",
"args": ["task", "mcp"],
"cwd": "echelon-analytics",
"env": {
"ECHELON_URL": "https://your-instance.example.com",
"ECHELON_SECRET": "your-api-token"
}
}
}
}
Then just open the project and ask questions — the tools are available automatically.
2. Claude Desktop
Add the server to your Claude Desktop config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"echelon-analytics": {
"command": "deno",
"args": ["task", "mcp"],
"cwd": "/path/to/echelon-analytics",
"env": {
"ECHELON_URL": "https://your-instance.example.com",
"ECHELON_SECRET": "your-api-token"
}
}
}
}
Restart Claude Desktop. You'll see the MCP tools icon in the chat input. Ask a question like "What are my top pages?" and Claude will use the analytics tools to answer.
3. Any MCP Client (stdio)
The server speaks JSON-RPC over stdio. Point any MCP-compatible client at it:
# Public instance ECHELON_URL=https://ea.islets.app deno run -A mcp-server.ts # Authenticated instance ECHELON_URL=https://echelon.example.com ECHELON_SECRET=your-token deno run -A mcp-server.ts
Send a tools/list request to discover available tools, then tools/call with the tool name and parameters.
What You Can Ask
Once connected, try natural language questions. The AI agent picks the right tool automatically:
| Question | Tool Used |
|---|---|
| "How's my site doing?" | analytics_overview |
| "Who's on my site right now?" | analytics_realtime |
| "Show me today's live dashboard" | analytics_dashboard |
| "Which campaigns drove the most traffic?" | analytics_campaigns |
| "Do campaign visitors actually use the feature we advertised?" | analytics_campaign_events |
| "Break down the spring-sale campaign" | analytics_campaign_detail |
| "How is my checkout-v2 experiment doing?" | analytics_experiments |
| "What campaigns are set up?" | list_campaigns |
| "What experiments are running?" | list_experiments |
| "Compare this week vs last week" | analytics_overview (called twice with different days) |
Example Conversation
Here's what a typical session looks like in Claude Code or Claude Desktop:
You: How's echelon-analytics doing this week? Agent: [calls analytics_overview with site_id="echelon-analytics", days=7] Your site had 342 visits from 218 unique visitors this week. Top pages: /admin (89 views), /features.html (54), /installation.html (41). Traffic sources: 45% direct, 28% search, 18% social, 9% referral. Busiest day was Tuesday with 73 visits. You: Which campaigns are active? Agent: [calls list_campaigns] You have 3 campaigns: - spring-2026 (active) — "Spring Launch" on site default - docs-launch (active) — "Documentation Launch" on site echelon-analytics - old-promo (archived) — "Old Promo" on site default You: Break down the spring campaign Agent: [calls analytics_campaign_detail with campaign_id="spring-2026"] Spring Launch (last 30 days): 156 views, 89 unique visitors. By source: newsletter (72 views), twitter (48), google (36). By medium: email (72), social (48), cpc (36). Top landing page: /sale (94 views), / (38), /pricing (24). You: Do campaign visitors actually use the dashboard feature we advertised? Agent: [calls analytics_campaign_events with site_id="my-app", event_type="feature_used"] Campaign visitors trigger "feature_used" events at a much higher rate: - spring-2026: 89 visitors, 34 triggered feature_used (38.2% event rate) - docs-launch: 41 visitors, 22 triggered feature_used (53.7% event rate) - Organic (no campaign): 218 visitors, 29 triggered feature_used (13.3% event rate) Your docs-launch campaign drives visitors 4x more likely to use the feature compared to organic traffic. You: How's the checkout experiment? Agent: [calls analytics_experiments with experiment_id="checkout-v2"] Checkout Redesign — metric: purchase, status: active - Control (Original): 1,240 impressions, 62 conversions (5.0%) - Redesign (New Flow): 1,185 impressions, 78 conversions (6.6%) Uplift: +31.3% — 95% statistically significant
Available Tools
| Tool | Description | Parameters |
|---|---|---|
analytics_overview |
Site overview: visits, unique visitors, top paths, devices, countries, referrers, and daily trend | site_id (required), days (1–730, default 30) |
analytics_realtime |
Active visitors and top pages in the last 5 minutes | site_id (required) |
analytics_campaigns |
UTM campaign stats: views and visitors grouped by campaign | days (1–90, default 30), campaign_id (optional) |
analytics_campaign_detail |
Campaign breakdown: sources, mediums, content, terms, daily trend, top landing pages | campaign_id (required), days (1–90, default 30) |
analytics_experiments |
A/B experiment results with conversion rates and statistical significance | experiment_id (optional) |
analytics_campaign_events |
Campaign-to-event correlation: for each campaign (and organic traffic), shows visitors, event-triggering visitors, event rate, events per visitor, and event type breakdown. Use to measure whether campaign visitors adopt features or convert. | site_id (required), days (1–90, default 30), event_type (optional filter) |
analytics_dashboard |
Live dashboard: active visitors, hourly/daily trends, recent visitors and events | site_id (required) |
list_campaigns |
List all registered UTM campaigns with IDs, names, utm_campaign values, site IDs, and statuses | none |
list_experiments |
List all A/B experiments with IDs, names, statuses, metric event types, and variant definitions | none |
All 9 tools are read-only and return JSON. The server only calls GET endpoints — it cannot create, modify, or delete any data.
Client Setup Reference
Claude Code
Auto-discovered via .claude/settings.json in the repository — edit ECHELON_URL there to point at your instance.
Claude Desktop
See the config paths and JSON snippet in the Setup section above.
Other MCP Clients
Any MCP-compatible client can connect via stdio transport. Set ECHELON_URL (and optionally ECHELON_SECRET) as environment variables.
Architecture
API-Backed
The MCP server calls the Echelon REST API over HTTP — it never touches the database directly. This means:
- Works with any instance (local, remote, Docker, cloud)
- Respects
PUBLIC_MODE, anonymization, and access controls - No local database file needed
- Same data as the admin dashboard — always live
Read-Only by Design
The server only calls GET endpoints. It never sends POST, PATCH, or DELETE requests — it cannot create, modify, or delete any data even if the token has write privileges. This is a deliberate constraint to maintain data authenticity while learning MCP usage patterns. Write tools may be added in a future version.
Transport
Uses stdio transport (JSON-RPC over stdin/stdout). Logging goes to stderr to avoid interfering with the protocol. Compatible with any MCP client that supports stdio.
Dependencies
@modelcontextprotocol/sdk— official MCP SDKzod— parameter validation
Configuration
| Variable | Required | Description |
|---|---|---|
ECHELON_URL | Yes | Base URL of the Echelon Analytics instance (e.g. https://ea.islets.app) |
ECHELON_SECRET | No | Bearer token for authenticated API access. Not needed for PUBLIC_MODE instances. |
🤖 "The MCP server calls the same REST API as the admin dashboard — same data, same filters, same anonymization. Ask your AI agent 'how's my site doing?' and it gets live results." -🦭
Database Portability
The MCP server queries your analytics through the REST API, and all that data lives in a single SQLite file. Copy echelon.db to another machine, start an Echelon instance pointing at it, and query it with any MCP client. Your analytics travel with you.
See Portable Data for details on the database schema, example SQL queries, and data lifecycle.