# Connect an AI client with MCP

Give an AI assistant access to reports or let it manage question visibility in your paid Shopoll workspace. Connect through the Model Context Protocol (MCP). Your AI client must support HTTP connections and bearer authentication, which sends an access key with each request.

## Connect the client

1. In your workspace, open **Developer access** and choose **Reports** for analysis or **Manage question visibility** for question editing. Create a separate key for each purpose.
2. Copy the key when it is shown. Add the Shopoll app endpoint ending in `/mcp` to the client.
3. Configure the authorization header as `Authorization: Bearer <your-key>`. Keep the key in the client's credential settings.
4. Discover the server tools. Start by asking which surveys are in the workspace.

## Reporting tools

| Tool | What it returns |
| --- | --- |
| list_surveys | A page of surveys, including the identifier for later requests |
| get_poll | Survey title, current publication status and the number of questions in a published version |
| list_slides | Question IDs, labels, types and visibility in the order set by the merchant |
| get_slide | One question’s wording and answer format, including choices, scale or form fields |
| list_templates | Built-in survey templates and delivery presets, searchable by purpose |
| get_template | A template’s questions and branching, or a delivery preset’s settings |
| survey_report | Response totals and report data for one survey |
| analyze_attribution | Order-linked attribution results for the selected survey |

Ask “Which answers were most common on mobile versus desktop, and what was the linked order value for each group?” The client can call **analyze_attribution** with **view** set to **groups**, the question ID and **group** set to **device**. Use **entryCampaign** to compare storefront landing campaigns, **referringDomain** to compare referring sites, or **lastClickSource** for the final visit Shopify associated with each linked order. The result uses the same within-group shares and currency-specific order values as the merchant report. [Group report fields](/api/#read-an-answer-by-group-breakdown)

## Choose a survey template

Ask “Which templates ask about delivery, and what questions do they include?” The client can search `list_templates` with `kind` set to `survey`, then use the returned ID with `get_template`. Each questionnaire includes its suggested placement. To see how a placement works, pass its `placementPreset` ID to `get_template`. An abandoned-checkout starter also includes an `invitationPreset` ID for its suggested follow-up.

Ask “How would I follow up after delivery by SMS?” Search with `kind` set to `delivery`. The order-invitation presets show the channel, event, initial delay and recipient audience. For a website path preset, supply your own path to see its targeting rule. With no path supplied, the result marks the example path. Storefront appearance settings show the preset with the default Shopoll design. The editor applies it to your survey’s own design.

Use **Surveys → Create a survey** to try a [built-in template](/docs/surveys/choosing-a-template.md) and create a hidden draft. Looking up a template through MCP leaves your workspace unchanged.

## Read individual responses

Use a **Responses** key and call `list_responses` with the survey ID. For example, ask your client to show the five most recent submissions to your delivery survey. Each record includes its saved answers, completion status and submission time. Corrections made in Shopoll appear in the returned answers. Set `limit` to a number from 1 to 100 (default 50). To continue, send `next` as `before` until the result has no next page.

## Understand an older answer

Ask “What question did this shopper answer when they chose Blue?” With a **Responses** key, read the submission using `list_responses`. Pass its `version`, survey ID and the question ID from `answers` to `get_slide`. This retrieves the wording and choices published at the time, even if the question was later renamed or removed. The wording is the survey’s original text before translation or personalisation.

For a choice, match the saved answer to `choices[].value` and use `label` for display. A form answer uses field IDs, and a matrix answer follows the listed row order. A ranking lists the shopper’s choices from first to last. A write-in or long-answer attachment has a separate answer key shown in the question details.

Omit `version` to read the latest publication. For a survey that has never been published, `get_poll` shows its title and a null version, and `list_slides` returns an empty list. Archived surveys retain their published question history.

## Read comments from people who gave a particular answer

Ask “What did shoppers who chose **Too expensive** write in their follow-up?” Give the client a **Responses** key. It can use `list_slides` to find the reason and follow-up questions, then call `get_verbatims` with their IDs. For example, if the IDs are `reason` and `comment`, use these arguments with your survey ID.

```json
{"survey":"YOUR_SURVEY_ID","question":"comment","group":{"question":"reason","value":"Too expensive"}}
```

Leave out `question` to read all written feedback from that group, or leave out `group` to read everyone’s comments. For multiple choice, a response matches if the shopper selected the value. For rankings, it matches their first pick. Use the saved choice value or the score written as a string, such as `"0"`. Set `version` when you want one published version.

The tool returns short and long answers, written form fields and details shoppers typed beside a choice. Each comment includes the question wording from its published version and any correction saved in Shopoll. Comments are returned as written, including contact details someone typed into a comment. Separate email and phone fields are excluded.

Results start with the most recent submissions. The default page contains up to 20 comments. Set `limit` from 1 to 100 to change the page size. Send the returned `next` object as `cursor` with the same filters to continue, including when one submission’s comments span two pages. A null `next` marks the end.

## Collected email addresses

With a **Responses** key, use `list_emails` to retrieve addresses people entered into email questions and email fields in forms. Supply `survey` to read one survey, or omit it for the workspace. Corrected answers are included. Anonymous surveys and email addresses supplied only by store or order details are excluded.

The result contains `emails` and `next`. Pass `next` as `after` to continue until it is null, even if a page has no addresses. Combine matching addresses across pages for a unique list. To download a single CSV in Shopoll, use **Answers → Export**.

## Question visibility tools

With a **Manage question visibility** key, the client can use `list_surveys` and `list_questions` to find a question and inspect its current visibility. Ask it to use `update_slide` with `settings.hidden` set to true or false. Changes go to the draft by default. Specify `applyTo: "live"` to update the live question as well. Earlier answers remain available in reports.

## Ask a question

Try “Which discovery source accounted for the most revenue in October?” Have the assistant list surveys, choose the attribution survey and pass the date range into the report. Check the currency and number of linked orders before comparing two channels.

## Check a connection

Use your Shopoll app address for the connection. Create a key in the workspace you want the assistant to read, with **Reports** or **Responses** access. A webhook-management key does not give report access. If access changes, revoke the key under Developer access and configure the replacement in your client.

## Tool arguments

Reports and Responses keys can read published survey definitions and aggregate reports. A Responses key also exposes `get_verbatims`, `list_emails` and `list_responses`. A question-visibility key exposes `list_surveys`, `list_questions` and `update_slide`. Customer-history and webhook keys cannot use these MCP tools. Each key has one scope; create separate connections when both reporting and visibility changes are needed.

| Tool | Required arguments | Optional arguments |
| --- | --- | --- |
| `list_surveys` | None | `before`: positive integer cursor; page size is fixed at 50 |
| `get_poll` or `list_slides` | `survey` | `version` from a published survey or a saved response |
| `get_slide` | `survey`, `question` | `version` from a published survey or a saved response |
| `list_templates` | None | `kind` (`survey` or `delivery`), `search` |
| `get_template` | `id` from the template list | `path` for the specific website path preset |
| `list_responses` | `survey`: survey ID | `limit`: 1–100; `before`: cursor from the previous page |
| `get_verbatims` | `survey` | `question`, `version`, `group`, `limit`, `cursor` |
| `list_emails` | None | `survey`: survey ID; `after`: numeric cursor from the previous page |
| `survey_report` | `survey`: survey ID string | None; this tool returns the survey-wide aggregate report |
| `analyze_attribution` | `survey`: survey ID string | `group`, `question`, `field`, `value`, `interval`, `from`, `to`, `compare`, `projected` |
| `list_questions` | `survey`: survey ID string | None |
| `update_slide` | `survey`, `question`: ID strings; `settings`: object containing only boolean `hidden` | `applyTo`: `draft` (default) or `live`; `expectedVersion`: non-negative integer |

For `analyze_attribution`, `group` is a metadata field name and defaults to `attribution_channel`. `question` splits results by the answers to a choice, numeric or ranked question. `field` and `value` together restrict responses by an exact metadata match. These fields are strings. `interval` accepts `day` (default), `week` or `month`. `from` and `to` are inclusive UTC date strings in `YYYY-MM-DD` format. `compare: "previous"` requires both dates and compares the preceding equal-length period. `projected` is the number `0` or `1`; inspect the returned projection status before using estimates. Status and analysis filters from the REST API are not exposed in the advertised MCP tool schema.

`list_surveys` returns `items` with `id`, `title`, `active`, `archived` and `version`, plus `next`. Pass a numeric `next` as `before` for another page; stop when it is null. `survey_report` returns `responses`, `completed`, `channels`, `insights` and `funnel`. Attribution row fields, currency handling, comparison alignment and projection eligibility match the [REST API reference](/docs/api.md).

`list_questions` returns `survey`, `version`, `active` and `questions`. Each question includes `id`, `label`, draft `hidden` and `publishedHidden` (null when unpublished). Pass the returned version as `expectedVersion` when editing. A live change requires an active survey and a question already in its published version. Archived surveys must be restored first. On a conflict, read the questions again before retrying. The update result includes `survey`, `question`, `hidden`, `applyTo` and the resulting `version`.

## HTTP request examples

POST JSON-RPC 2.0 messages to `https://YOUR_APP_HOST/mcp` with `Authorization: Bearer YOUR_KEY` and `Content-Type: application/json`. Replace the host and IDs. For initialization:

```json
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"Your client","version":"1.0"}}}
```

Discover the tools available to this key:

```json
{"jsonrpc":"2.0","id":2,"method":"tools/list"}
```

Request October attribution compared with the preceding period using a reporting key:

```json
{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"analyze_attribution","arguments":{"survey":"SURVEY_ID","from":"2026-10-01","to":"2026-10-31","interval":"month","compare":"previous"}}}
```

With a visibility key, first call `list_questions`, then use its question ID and version:

```json
{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"update_slide","arguments":{"survey":"SURVEY_ID","question":"QUESTION_ID","settings":{"hidden":true},"applyTo":"draft","expectedVersion":2}}}
```

Successful tool calls return data in `result.structuredContent` and as JSON text in `result.content`. A tool-level failure can return `result.isError: true` with a text explanation. Protocol errors appear in `error`, including codes `-32700` (parse error), `-32600` (invalid request), `-32601` (unknown method) and `-32602` (invalid arguments or unknown tool). Authentication and permission failures use HTTP 401 or 403 before a tool runs.

## Connection scope and limits

The endpoint supports POST requests for `initialize`, `ping`, `tools/list` and `tools/call`. Notifications without an ID receive HTTP 202. It does not provide a GET event stream, MCP resources or prompts, or OAuth onboarding. Use a client that supports this HTTP POST and bearer-key setup.

Reporting tools are read-only. The visibility connection can hide or show existing questions; it cannot create surveys, rewrite questions, change branching, publish an entire draft, manage webhooks, administer teams or change billing. Visibility changes default to the draft; request `applyTo: "live"` explicitly when a live change is intended.
