Skip to main content
Glama
README.md
# tdsynnex-mcp — TD SYNNEX StreamOne® Ion

> **This server is for TD SYNNEX StreamOne® Ion** (the cloud marketplace at `ion.tdsynnex.com`, V3 API).
> It does not cover other TD SYNNEX platforms such as EC Express / Digital Bridge or legacy StreamOne Enterprise Solutions.

An MCP (Model Context Protocol) server that lets Claude and other MCP clients work with your StreamOne Ion reseller account: customers and their cloud tenants, the product catalog and pricing, subscriptions and renewals, orders, carts, provisioning templates and billing reports.

- Built on the **MCP TypeScript SDK v2** (`@modelcontextprotocol/server`) with Zod 4 schemas.
- **Read-only by default** (23 tools). Set `ION_ENABLE_WRITES=true` to add 17 tools for customers, carts, orders, checkout, tenants and reports (40 total).
- Runs locally over **stdio**, or in **Docker** over Streamable HTTP with bearer auth and DNS-rebinding protection.
- Handles Ion's **single-use rotating refresh tokens** for you, saving the newest one so restarts keep working.

## Tools

Every read tool accepts `response_format`: `markdown` (default, a readable summary) or `json` (complete data, also returned as `structuredContent`). List tools are paged and report `has_more` with `next_offset` or `next_page_token`. Responses stay under 25,000 characters by returning fewer items, never by cutting text.

### Read-only (always available)

| Area | Tool | What it does |
|---|---|---|
| Start here | `ion_test_connection` | Checks credentials and shows how long the access and refresh tokens stay valid |
| Customers | `ion_list_customers` | Find customers by contact name, email or status |
| | `ion_get_customer` | One customer's details |
| | `ion_get_customer_cloud_profiles` | Microsoft tenant ID and domain, GDAP status, other provider accounts |
| | `ion_get_customer_overview` | **Workflow:** details, tenants, subscriptions by status, and renewals in the next 90 days, in one call |
| Subscriptions | `ion_list_subscriptions` | Filter by customer, status, provider, product, PO, or start/end date range |
| | `ion_get_subscription` | Full detail: plan, quantity, term, dates, price and margin, attributes, activity |
| | `ion_find_upcoming_renewals` | **Workflow:** active subscriptions renewing in the next N days, soonest first |
| Catalog | `ion_list_products` | Search by name, SKU, part number or provider |
| | `ion_get_product` | SKUs, plans and prices: the `sku_id` and `plan_id` you need to order |
| | `ion_get_product_pricing` | Price vendor product IDs, optionally with a customer's pricebook |
| | `ion_list_catalog_reference` | Categories, verticals, charges or programs |
| Orders & carts | `ion_list_orders` | Account-wide or per customer, with the reason when an order failed |
| | `ion_get_order` | Line items with per-item status and errors |
| | `ion_list_carts`, `ion_get_cart` | Carts, items and totals |
| Provisioning | `ion_list_provisioning_templates`, `ion_get_provisioning_template` | Attributes a vendor requires when ordering |
| | `ion_get_customer_cloud_provider` | A customer's account with one provider |
| Reports | `ion_list_reports`, `ion_get_report` | Saved billing, invoice, customer and partner reports |
| | `ion_run_report` | Run a report as a paged table or as CSV |
| Utility | `ion_api_request` | Raw GET to any `/api/v3/` endpoint not covered above |

### Write tools (`ION_ENABLE_WRITES=true`)

Clients see each tool's hints (`readOnlyHint`, `destructiveHint`, `idempotentHint`). Tools marked † are flagged destructive, so clients ask for confirmation before running them.

| Area | Tools |
|---|---|
| Customers | `ion_create_customer`, `ion_update_customer` † |
| Catalog | `ion_set_product_enabled`, `ion_update_product_program` † |
| Orders | `ion_create_order` † (billable), `ion_cancel_order` † |
| Carts | `ion_create_cart`, `ion_update_cart` †, `ion_delete_cart` †, `ion_add_cart_item`, `ion_update_cart_item` †, `ion_remove_cart_item` †, `ion_checkout_cart` † (billable) |
| Tenants | `ion_link_customer_cloud_provider`, `ion_provision_customer_cloud_provider` † (creates a new tenant) |
| Reports | `ion_save_report` †, `ion_delete_report` † |

With writes enabled, `ion_api_request` also allows POST, PUT and DELETE.

### Example questions

- "What does Contoso have with us, and what renews soon?" → `ion_list_customers`, then `ion_get_customer_overview`
- "Which subscriptions renew in the next 30 days with auto-renew off?" → `ion_find_upcoming_renewals`
- "Why did last week's order for Fabrikam fail?" → `ion_list_orders` (status `ERROR`), then `ion_get_order`
- "What does Business Premium annual cost for Contoso?" → `ion_list_products`, then `ion_get_product` with `price_book_customer_id`
- "Export last month's billing report as CSV" → `ion_list_reports`, then `ion_run_report` with `output: "csv"`

## How Ion authentication works

| Token | Lifetime | Notes |
|---|---|---|
| Access token | 2 hours | Sent as `Authorization: Bearer …` |
| Refresh token | 32 days | **Single-use.** Each refresh returns a new one and invalidates the old one. |

Generate the first refresh token in the **StreamOne Ion portal** and set it as `ION_REFRESH_TOKEN`. After that, the server:

1. exchanges it at `POST /oauth/token` for an access token and a new refresh token,
2. **saves the newest refresh token** to `ION_TOKEN_STORE`, written atomically with file mode 0600,
3. uses the stored token on later starts, even if the old seed is still in `.env`,
4. refreshes about every 12 hours while running, and once more after any 401, so the 32-day window keeps moving.

> ⚠️ In Docker, **always mount a volume at `/data`**. Without it, a restarted container falls back to the spent seed token and can't authenticate. If that happens, or the server is stopped for more than 32 days, generate a new refresh token in the portal and set `ION_REFRESH_TOKEN`. The server notices the new value and re-seeds its store.
>
> Run only **one** server per refresh token. Two copies refreshing the same token lock each other out.

## Quick start: Docker (HTTP)

```bash
cp .env.example .env
# Set ION_ACCOUNT_ID, ION_REFRESH_TOKEN, and MCP_AUTH_TOKEN (openssl rand -hex 32)
docker compose up -d --build
curl http://127.0.0.1:8080/health
```

The MCP endpoint is `POST http://127.0.0.1:8080/mcp`. Clients must send `Authorization: Bearer <MCP_AUTH_TOKEN>`.

Compose publishes the port on **loopback only**. To use the server from other machines:

1. put a TLS reverse proxy in front (Caddy, Traefik, nginx or a Cloudflare Tunnel), and
2. add your public hostname to `MCP_ALLOWED_HOSTS`, e.g. `localhost,127.0.0.1,ion-mcp.example.com`. Requests with any other `Host` header are refused (DNS-rebinding protection).

Prebuilt images are published to `ghcr.io/jcsdy/tdsynnex-mcp` by the GitHub Actions workflow.

### Connect a client to the HTTP server

**Claude Code**

```bash
claude mcp add --transport http tdsynnex-ion http://127.0.0.1:8080/mcp \
  --header "Authorization: Bearer $MCP_AUTH_TOKEN"
```

**Any client that supports remote servers with headers**

```json
{
  "mcpServers": {
    "tdsynnex-ion": {
      "type": "http",
      "url": "https://ion-mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer <MCP_AUTH_TOKEN>" }
    }
  }
}
```

## Quick start: local stdio (Claude Desktop / Claude Code)

```bash
npm ci && npm run build
```

```json
{
  "mcpServers": {
    "tdsynnex-ion": {
      "command": "node",
      "args": ["/absolute/path/to/tdsynnex-mcp/dist/index.js"],
      "env": {
        "ION_ACCOUNT_ID": "12345",
        "ION_REFRESH_TOKEN": "xxxxxxxx",
        "ION_TOKEN_STORE": "/absolute/path/to/tdsynnex-mcp/data/ion-token.json"
      }
    }
  }
}
```

## Auth modes

| Mode | Where ION credentials come from | Use for |
|---|---|---|
| `env` (default) | `ION_REFRESH_TOKEN` / `ION_ACCOUNT_ID`; refreshed and saved automatically | One reseller account |
| `gateway` | Each request's `X-Ion-Access-Token` and optional `X-Ion-Account-Id` headers; nothing stored in the container | A multi-tenant front end that manages each tenant's tokens itself |

Start gateway mode with `docker compose --profile gateway up -d ion-mcp-gateway`. It listens on port 8081. `MCP_AUTH_TOKEN` is required in both modes.

## Configuration

See [`.env.example`](.env.example) for every setting. The main ones:

| Variable | Default | Purpose |
|---|---|---|
| `ION_ACCOUNT_ID` | — | Default reseller account |
| `ION_REFRESH_TOKEN` | — | Seed refresh token from the Ion portal |
| `ION_TOKEN_STORE` | `./data/ion-token.json` (`/data/…` in Docker) | Where rotated tokens are saved |
| `ION_ENABLE_WRITES` | `false` | Adds the write tools |
| `MCP_TRANSPORT` | `stdio` (`http` in Docker) | Transport |
| `MCP_AUTH_TOKEN` | — | Bearer token HTTP clients must send (required for HTTP) |
| `MCP_ALLOWED_HOSTS` | `localhost,127.0.0.1` in Docker | Hostnames accepted in the `Host` header |
| `AUTH_MODE` | `env` | `env` or `gateway` |
| `ION_MAX_INFLIGHT` | `4` | Maximum concurrent calls to Ion |
| `ION_TIMEOUT_MS` | `60000` | Per-request timeout for Ion calls |

## Development

```bash
npm ci
npm run build
npm test                 # end-to-end tests against a mock Ion API (tests/mock-ion.mjs)
npm run smoke            # self-check: read-only calls against the Ion configured in your env
npx @modelcontextprotocol/inspector node dist/index.js   # interactive explorer
```

`npm test` covers:

- token seeding, rotation, persistence and restart,
- a forced refresh and retry after a 401,
- markdown and JSON output matching `structuredContent`,
- token and offset pagination,
- the 25k-character limit,
- the overview and renewals workflows,
- report paging and CSV,
- actionable errors and strict input validation,
- path-traversal protection in raw requests,
- HTTP bearer auth, DNS-rebinding refusal, gateway headers,
- refusing to start HTTP without an auth token.

[`evaluations/`](evaluations/) has a 10-question evaluation against the mock data, and a template for building one from your real account.

## Notes and limitations

- Tools follow the official V3 OpenAPI document (`ccp-mp-apidocs-v2.yaml` behind https://www.tdsynnex.com/ion/v3api/). Some request bodies are loosely documented: order and checkout `attributes`, Azure company and billing profiles, and report `specs`. Use `ion_get_provisioning_template` to find the required attributes.
- Ion cannot search customers by organization name. `ion_list_customers` filters by contact name, email and status.
- Ion has no "renews in the next N days" filter. `ion_find_upcoming_renewals` scans active subscriptions (up to `max_scan`) and filters them itself.
- Cart endpoints in V3 are not scoped by account, so cart tools take only `customer_id`.
- `ion_get_subscription` takes the **internal** `id` from `ion_list_subscriptions`, not the vendor's subscription ID.

## License

[MIT](LICENSE). Not affiliated with or endorsed by TD SYNNEX. StreamOne® is a trademark of TD SYNNEX.