Salla MCP Server
# salla-mcp
[](https://github.com/theYahia/salla-mcp/actions/workflows/ci.yml)
MCP server for the [Salla](https://salla.sa) e-commerce platform (Saudi Arabia). Manage
products, categories, brands, orders, customers, coupons, branches, and store settings
through the Salla Admin API v2 — with OAuth 2.0, automatic token refresh, and rate-limit
aware retries.
## Tools (22)
### Products
| Tool | Description |
| ------------------------ | ---------------------------------------------- |
| `list_products` | List products (pagination + status filter) |
| `get_product` | Get a product by ID |
| `get_product_by_sku` | Get a product by SKU |
| `create_product` | Create a new product |
| `update_product` | Update an existing product |
| `delete_product` | Delete a product |
| `bulk_update_quantities` | Bulk-update stock by product/variant ID or SKU |
### Categories & brands
| Tool | Description |
| ----------------- | ----------------------------------------- |
| `list_categories` | List categories (keyword + status filter) |
| `get_category` | Get a category by ID |
| `create_category` | Create a category |
| `list_brands` | List brands |
### Orders
| Tool | Description |
| --------------------- | ---------------------------------------- |
| `list_orders` | List orders (pagination + status filter) |
| `get_order` | Get an order by ID |
| `update_order_status` | Update an order's fulfillment status |
| `list_order_statuses` | List valid order statuses for the store |
| `get_order_histories` | Get an order's status-change timeline |
### Customers, store & operations
| Tool | Description |
| ---------------------- | ---------------------------------- |
| `list_customers` | List customers |
| `get_customer` | Get a customer by ID |
| `get_store_info` | Get store information and settings |
| `list_coupons` | List discount coupons |
| `list_abandoned_carts` | List abandoned carts |
| `list_branches` | List store branches |
## Quick Start
```json
{
"mcpServers": {
"salla": {
"command": "npx",
"args": ["-y", "@theyahia/salla-mcp"],
"env": {
"SALLA_ACCESS_TOKEN": "<YOUR_ACCESS_TOKEN>"
}
}
}
}
```
## Authentication
Salla uses OAuth 2.0. You can run this server in one of two ways.
### Option 1 — Static access token (simplest)
Set `SALLA_ACCESS_TOKEN`. **Salla access tokens expire after 14 days**, after which calls
fail with `401` and you must supply a new token. Good for quick local use; for anything
long-running, use auto-refresh below.
### Option 2 — Auto-refresh (recommended for long-running use)
Provide your app's OAuth credentials and a refresh token, and the server refreshes the
access token automatically — proactively before expiry and reactively on a `401`:
```json
{
"mcpServers": {
"salla": {
"command": "npx",
"args": ["-y", "@theyahia/salla-mcp"],
"env": {
"SALLA_CLIENT_ID": "<CLIENT_ID>",
"SALLA_CLIENT_SECRET": "<CLIENT_SECRET>",
"SALLA_REFRESH_TOKEN": "<REFRESH_TOKEN>"
}
}
}
}
```
Salla refresh tokens are **single-use and rotate** on every refresh (and themselves expire
after ~1 month). To survive restarts, the server persists the latest tokens to a token
store file (`SALLA_TOKEN_STORE`, default `~/.salla-mcp/token.json`) and reloads them on
start. Concurrent refreshes are collapsed into one request, which Salla requires.
### Where credentials come from
Create an app in the [Salla Partners portal](https://salla.partners) and install it on a
store. In **Easy Mode**, Salla delivers the access token to your app's configured webhook
on the `app.store.authorize` event. In **Custom Mode**, you take the `Client ID` /
`Client Secret` from the app's keys and run the standard authorization-code exchange
against `https://accounts.salla.sa/oauth2/token`. See the
[Salla authorization docs](https://docs.salla.dev/doc-421118).
## Environment Variables
| Variable | Required | Default | Description |
| --------------------- | ----------------------- | ---------------------------------------- | ------------------------------------ |
| `SALLA_ACCESS_TOKEN` | One of these two setups | – | OAuth 2.0 access token |
| `SALLA_CLIENT_ID` | For auto-refresh | – | OAuth app client ID |
| `SALLA_CLIENT_SECRET` | For auto-refresh | – | OAuth app client secret |
| `SALLA_REFRESH_TOKEN` | For auto-refresh | – | OAuth refresh token (rotated on use) |
| `SALLA_TOKEN_STORE` | No | `~/.salla-mcp/token.json` | Where rotated tokens are persisted |
| `SALLA_BASE_URL` | No | `https://api.salla.dev/admin/v2` | API base URL |
| `SALLA_TIMEOUT_MS` | No | `15000` | Per-request timeout |
| `SALLA_MAX_RETRIES` | No | `3` | Retries for `429`/`5xx` responses |
| `SALLA_TOKEN_URL` | No | `https://accounts.salla.sa/oauth2/token` | OAuth token endpoint |
## Rate Limits
Salla enforces per-plan limits over a 1-minute window (Plus 120, Pro 360, Special 720
requests/min). On `429` the server honors the `Retry-After` header and retries with
exponential backoff; transient `5xx` responses are retried too, up to `SALLA_MAX_RETRIES`.
## Demo Prompts
- "List all products in my Salla store"
- "Create a new product called 'Premium Dates' for 150 SAR"
- "What order statuses can I set, and move order 1001 to completed"
- "Sync stock: set SKU ABC-1 to 40 units"
- "Show me the abandoned carts from this week"
## Troubleshooting
- **`Salla authentication is not configured`** — set `SALLA_ACCESS_TOKEN`, or the three
`SALLA_CLIENT_ID` / `SALLA_CLIENT_SECRET` / `SALLA_REFRESH_TOKEN` variables.
- **`Salla HTTP 401`** with a static token — the token has expired (14-day lifetime);
generate a new one or switch to auto-refresh.
- **Repeated `401` after refresh** — your refresh token may have been consumed elsewhere
(they are single-use). Delete the token store file and re-supply a fresh refresh token.
- **`Salla HTTP 429`** — you hit the plan rate limit; the server already retries, but
sustained high volume needs a higher Salla plan.
## Development
```bash
npm install
npm run dev # run the server with tsx (stdio)
npm test # vitest
npm run lint # eslint
npm run typecheck # tsc --noEmit
npm run build # emit dist/
```
## License
MIT
TDQS
Scored across 22 tools
Most tools have clearly distinct resource-and-action purposes. Minor potential overlap exists between get_product and get_product_by_sku, and between update_product and bulk_update_quantities, but the descriptions differentiate them adequately.
All tools use snake_case with a predictable verb_noun pattern (list_products, get_order, update_order_status, delete_product). The few longer names like get_product_by_sku and bulk_update_quantities remain readable and consistent with the overall convention.
22 tools is on the heavy side for the stated rubric range, though the broad e-commerce domain justifies many of them. The set is not bloated with duplicates, but it sits at the upper boundary of manageable scope.
Core product CRUD and order read/status workflows are covered well. However, categories lack update/delete, and brands, coupons, branches, and abandoned carts are mostly list-only, leaving notable gaps for full store administration.