# AI Analyst (MCP Server)

The Eraya AI Analyst gives AI assistants like Claude, Cursor, and Gemini secure, authenticated access to your Eraya A/B test data and Shopify store analytics through the Model Context Protocol (MCP). Query experiments, results, revenue impact, and KPIs in plain English — no dashboard required.

***

### What is MCP?

The Model Context Protocol (MCP) is an open standard created by Anthropic that allows AI assistants to securely connect to external data sources and tools. The Eraya MCP Server implements this protocol to give AI assistants controlled access to:

* Your A/B experiments and test results
* Bayesian statistics: win probability, lift, and credible intervals
* Store revenue, orders, and conversion metrics
* Product catalogue and daily product analytics
* Business KPIs (sessions, revenue, conversion rate, AOV)
* AI-driven test recommendations: surfaces highest-opportunity products with session funnel + revenue context

***

### Prerequisites

* An active Eraya account with a connected Shopify store
* A **Pro plan** subscription (AI Analyst is a Pro-only feature — [upgrade at app.eraya.ai](https://app.eraya.ai))
* An MCP-compatible AI client (e.g., Claude Desktop, Claude Code, Cursor, Gemini)

***

### Installation

The Eraya MCP Server is hosted at:

```
https://api.eraya.ai
```

**No installation is required.** The server is hosted by Eraya and ready to use immediately.

| Property            | Value                                                         |
| ------------------- | ------------------------------------------------------------- |
| **MCP endpoint**    | `https://api.eraya.ai/mcp`                                    |
| **Transport**       | HTTP (Streamable HTTP, MCP 2024-11-05)                        |
| **Auth**            | OAuth 2.0 + PKCE (magic-link login)                           |
| **OAuth discovery** | `https://api.eraya.ai/.well-known/oauth-authorization-server` |

***

### Configuration

Add the Eraya MCP Server to your AI client following the applicable guide below:

1. Claude (Desktop & Code)
2. Google Gemini
3. Cursor
4. Other MCP Clients

For a full reference of all tools, parameters, and example responses, see Available Tools.

For example prompts and best practices, see Examples & Best Practices.

***

#### Claude Desktop

1. Open the **Claude Desktop** app.
2. Click **Customize** in the top-left navigation.
3. Go to the **Connectors** tab.
4. Click the **"+"** button → **"Add custom connector"**.

> **Note:** Custom Connectors require a Claude Pro, Max, Team, or Enterprise plan.

5. Set the **Title** to `Eraya` and the **URL** to `https://api.eraya.ai/mcp`. Leave the OAuth field empty, then click **Add**.
6. Click the **Connect** button to authenticate. You will receive a magic-link email — click the link to complete the login.
7. When starting a new chat, confirm that **Eraya** is toggled on in the options menu.

> **Tip:** To avoid clicking "Allow" every time Claude reads from Eraya, go to **Settings → Customize → Connectors → Eraya** and switch the dropdown next to "Read-only tools" to **Always allow**.

***

#### Claude Code

Add the Eraya MCP Server using the CLI:

```bash
# Add with HTTP transport (recommended)
claude mcp add --transport http eraya https://api.eraya.ai/mcp
```

When you first use the server, Claude Code will open a browser-based OAuth login. Complete the magic-link authentication to authorize access to your Eraya account. Your token is stored securely and is valid for 365 days.

Alternatively, add the server to your `.mcp.json` in your project root, or `~/.claude.json` for user-wide access:

```json
{
  "mcpServers": {
    "eraya": {
      "type": "http",
      "url": "https://api.eraya.ai/mcp"
    }
  }
}
```

Management commands:

```bash
claude mcp list           # View all configured servers
claude mcp get eraya      # Get server details
claude mcp remove eraya   # Remove the server
```

***

#### Cursor

1. Open **Cursor Settings → MCP**.
2. Click **Add Server**.
3. Set type to **HTTP** and URL to `https://api.eraya.ai/mcp`.
4. Cursor will open an OAuth browser login. Complete the magic-link flow to authorize.

Alternatively, add the following to your `.cursor/mcp.json` or `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "eraya": {
      "type": "http",
      "url": "https://api.eraya.ai/mcp"
    }
  }
}
```

***

#### Google Gemini

Add the Eraya MCP server as a tool integration in Gemini Advanced / Gemini for Google Workspace. Use the HTTP endpoint:

```
https://api.eraya.ai/mcp
```

Refer to Google's documentation for adding OAuth2-authenticated HTTP MCP servers to Gemini.

***

#### Other MCP Clients

For any other MCP-compatible client, use the following connection details:

* **HTTP endpoint:** `https://api.eraya.ai/mcp` *(recommended)*
* **Auth:** OAuth 2.0 + PKCE — discovery document at `https://api.eraya.ai/.well-known/oauth-authorization-server`
* **Dynamic client registration:** `POST https://api.eraya.ai/mcp-oauth/register`

***

### Authentication

Eraya uses **OAuth 2.0 + PKCE** with a magic-link email flow. No passwords are stored.

1. Your MCP client redirects you to the Eraya login page at `https://api.eraya.ai/mcp-oauth/authorize`.
2. Enter your Eraya account email address.
3. Check your inbox for a magic-link login email.
4. Click the link to complete authentication — your client receives a long-lived access token valid for **365 days**.
5. All subsequent MCP requests are automatically authorized using this token.

> **Pro plan required.** If your account is not on the Pro plan, authentication will return an error. Upgrade at [app.eraya.ai](https://app.eraya.ai).

***

### Multi-Store Support

If your Eraya account has access to multiple Shopify stores, you can switch between them within a session.

* Call `list_stores` to see all stores your account has access to and which store is currently active.
* Call `switch_store` with a `storeId` to make all subsequent tool calls use that store.
* If you always work with a specific store, add a **System Prompt** or **Custom Instruction** to your AI client with your store name — the AI will call `switch_store` automatically at the start of each session.

> **Note:** Each store you switch to must also be on an active Pro plan.

**Example:**

> "Switch to my store 'Acme Shop' and show me all active experiments."

***

### Available Tools

| Tool                        | Description                                                                                                                                                                                                                                                                                                           |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `list_experiments`          | List all A/B experiments for the store. Filter by status (`active`, `completed`, `all`) or test type.                                                                                                                                                                                                                 |
| `get_experiment_results`    | Get session-based funnel analytics for an experiment: sessions → add-to-cart → purchases, broken down by variation, device, and visitor type.                                                                                                                                                                         |
| `get_experiment_statistics` | Get pre-computed **Bayesian statistics**: win probability, lift, credible intervals, significance, and per-variation conversion/revenue/AOV. Use this for winner determination.                                                                                                                                       |
| `get_experiment_details`    | Get the full configuration of an experiment: variations, goals, targeting, traffic allocation, and dates.                                                                                                                                                                                                             |
| `get_experiment_orders`     | Retrieve raw orders attributed to a specific experiment. Useful for revenue deep-dives per variation.                                                                                                                                                                                                                 |
| `get_store_orders`          | Retrieve all store orders for a date range. Useful for revenue trends, discount analysis, and customer behaviour.                                                                                                                                                                                                     |
| `get_products`              | Retrieve your product catalogue including variants, prices, and inventory.                                                                                                                                                                                                                                            |
| `get_product_analytics`     | Query per-product sales analytics via ShopifyQL: `total_sales`, `net_sales`, `gross_sales`, `orders`, `net_items_sold`, and `average_order_value`. Supports filtering by product IDs, time-series grouping, N-period moving averages, and optional session/conversion data. Use relative dates like `-30d` or `-90d`. |
| `get_business_kpis`         | Get store-level daily KPIs: sessions, revenue, conversion rate, and average order value.                                                                                                                                                                                                                              |
| `get_test_recommendations`  | Surfaces the highest-opportunity products to A/B test by merging sales, session funnel, and store-average data. Returns per-product `sessions`, `conversion_rate`, `aov_vs_store_avg`, `revenue_share_pct`, and `currently_being_tested` flag, with `note` guidance on which test type to run and why.                |
| `list_stores`               | List all Shopify stores your account has access to and see which is currently active.                                                                                                                                                                                                                                 |
| `switch_store`              | Switch the active store for this session.                                                                                                                                                                                                                                                                             |
| `get_eraya_schema`          | Returns the full Eraya data schema, test type conventions, and a guide on which tool to use for each analytics task. **Call this at the start of a session** to help the AI understand your data.                                                                                                                     |
| `list_collections`          | List product collections in the Shopify store. Filter by title.                                                                                                                                                                                                                                                       |
| `list_pages`                | List content pages in the Shopify store (About, FAQ, Contact, etc.). Filter by title.                                                                                                                                                                                                                                 |
| `search_policies`           | Retrieve store policies: privacy, refund, terms of service, shipping, and subscription.                                                                                                                                                                                                                               |

#### Supported Test Types

| Type       | Description                                 |
| ---------- | ------------------------------------------- |
| `price`    | Tests different prices for product variants |
| `shipping` | Tests different shipping rates              |
| `theme`    | Tests different Shopify theme versions      |
| `content`  | Tests different content/copy on pages       |
| `redirect` | Split-URL (redirect) tests                  |
| `checkout` | Tests different checkout experiences        |
| `template` | Tests different product page templates      |
| `offer`    | Tests promotional offers and discounts      |

***

### Data Privacy

Eraya's MCP server automatically strips personally identifiable information (PII) from all data returned to your AI client:

* Customer names, email addresses, and phone numbers are removed
* Full billing and shipping addresses are removed (city, province, and country are retained for geographic analysis)
* Client IP addresses are removed
* Fulfillment tracking numbers and URLs are removed

Your A/B test data and store analytics are never used to train AI models.

***

### Plan Requirement

AI Analyst is available on the **Pro plan** only.

* MCP access is verified on every request. Downgrading your plan immediately revokes access even with an existing token.
* To upgrade, visit [app.eraya.ai](https://app.eraya.ai) → **Settings → Billing**.

***

### Support

Questions or issues connecting? Contact **<support@eraya.ai>**.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eraya.gitbook.io/eraya-docs/mcp-server/ai-analyst-mcp-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
