# Workflow: Connect NiftyImages Store MCP (ChatGPT / Claude / Codex)

**Human-friendly landing page:** [/docs/connect-ai](/docs/connect-ai.md) (screenshots, demo phrases, product story).

Use this technical checklist when a non-engineer wants ChatGPT (or similar) to manage a Data Store.

## What you need

1. A NiftyImages account with a Data Store (or permission to create one).
2. An **API key** from the NiftyImages product UI:
   - **Store API Key** (starts with `store-`) — best for one list; safest for demos.
   - **Account API Key** — can see multiple stores, create/update/delete stores, and create a store from CSV.
3. An AI product that can add a **remote MCP server** (ChatGPT custom connector / Claude MCP / Cursor / Codex, depending on plan).

You do **not** need someone to put your key in Azure App Settings.

## Connect (once)

1. Open your AI app’s **connectors / MCP / custom tools** settings.
2. Add a new MCP server:
   - **URL:** `https://dev.niftyimages.com/store_mcp`  
     (or your production host + `/store_mcp`)
   - **Authentication:** API key / Bearer token  
     Paste the key from the NiftyImages UI.
   - Header the client should send:

     ```http
     Authorization: Bearer <your-key>
     ```

3. Save. Confirm the tools appear (store CRUD tools such as `store_access`, `store_query`, `store_upsert`, `store_delete_record`, …).

4. Chat normally, for example:
   - “What store can I use?”
   - “How many VIP guests are in California?”
   - “Update alice@example.com score to 100.”
   - “Delete frank@example.com from the list.”

## Tips for co-founder demos

- Give each person their **own Store API Key** for a shared demo store, or their own store.
- Same MCP URL for everyone; **different keys** = different access.
- Do **not** put the key in the URL (`?key=`). Use Bearer only.
- Prefer Store keys so a mistake cannot wipe the whole account’s stores.
- Destructive tools require `confirmDelete=true` only after the user clearly asked to delete.

## If the AI app has no “API key” field

Some clients only store a URL. Then either:

- Use a client that supports custom headers / Bearer on MCP, or  
- For a private local demo only, run MCP on your machine with `NIFTY_API_KEY` set (not for co-founder self-serve).

## Skills vs MCP

- **MCP:** connect once with key → chat (recommended for demos).
- **Skills:** paste instructions + call REST with Bearer (more steps for the model).

## Call Details (logs)

MCP calls that include a Bearer key appear in the same API Call Details UI as `/v2`:

- Path looks like `/store_mcp [tools/call store_import_csv]` (host omitted in the grid)
- Large CSV bodies are truncated in the log
- Outbound `/v2` tool calls (count, batch, get store) still appear as separate rows

If you see an MCP tool row but no `POST …/records/batch`, the tool failed before writing (or the client never completed the call).

## Troubleshooting

| Symptom | Fix |
| --- | --- |
| Tools list works, calls fail with “Authorization: Bearer” | Client is not sending the key on tool calls |
| 401 / API key not found | Wrong key, or key revoked; create a new one in the UI |
| Store-scoped key can’t create a store | Expected; use account key or import into the assigned store |
| Timer / image tools missing | Expected; this MCP is Data Store only; REST `/v2` has the rest |
| Old `/mcp` URL fails | Use `/store_mcp` only — `/mcp` is not mapped |
