Every store is also reachable over the [Model Context Protocol](https://modelcontextprotocol.io), so an agent can run store operations without you building an integration first.

```
https://yns.store/mcp
```

Streamable HTTP, scoped to one store, able to do anything the REST API can.

## Authentication

Either credential works:

- **Store API key** — send `Authorization: Bearer sk-…`, from **Settings → API → API keys**.
- **OAuth 2.1** — connect with a YNS account. Clients discover the authorization server the standard way: an unauthenticated request answers `401` with `WWW-Authenticate: Bearer resource_metadata="https://yns.store/.well-known/oauth-protected-resource"`. Authorized apps appear under **Settings → Connected apps**, and disconnecting one revokes access immediately.

```json
{
  "mcpServers": {
    "yns": {
      "type": "http",
      "url": "https://yns.store/mcp",
      "headers": { "Authorization": "Bearer sk-your-api-key" }
    }
  }
}
```

## Tools

The whole API is exposed through two tools rather than one per endpoint, which keeps the tool list small enough to stay in an agent's context:

| Tool | Use |
|------|-----|
| `search_api` | Discover endpoints. Returns a compact index of `{ method, path, operationId, summary }`, optionally filtered by a substring `query`. Read-only. Call this first when you don't know the exact path. |
| `execute_api` | Call one `/api/v1/*` endpoint. `GET` reads; `POST`, `PUT`, `PATCH` and `DELETE` write. Substitute path parameters inline and pass `body` as a raw JSON object. |

```
search_api  { "query": "inventory" }
→ [{ "method": "POST", "path": "/api/v1/inventory/adjust", "operationId": "adjustInventory", … }]

execute_api { "method": "POST", "path": "/api/v1/inventory/adjust",
              "body": { "variantId": "019…", "delta": -3, "reason": "damaged" } }
```

Nothing is evaluated server-side — the agent composes the calls in its own loop.

## Storefront MCP server

A separate, unauthenticated MCP server runs on each storefront at `https://<your-store-domain>/api/mcp`, meant for shopping assistants rather than administration. It has two tools: `search` (find products by name or summary, returning each variant with price, image and a direct buy link) and `fetch` (get one variant by id).