AtroPIM MCP Server
# AtroPIM MCP Server
A [Model Context Protocol](https://modelcontextprotocol.io) server for
[AtroPIM](https://www.atropim.com) and other [AtroCore](https://github.com/atrocore/atrocore)
applications. It lets AI agents search, read and update products, categories,
files and any other entity through the AtroCore REST API, as the authenticated user.
- Works with any entity, including custom ones, by reading the instance metadata.
- Tools are organised into business tool groups. Only `catalog-read` is enabled by default.
- Results are compacted for LLM context and carry `deepLink` URLs into the AtroPIM UI.
- Runs over stdio, or Streamable HTTP with OAuth 2.1 so every person signs in as themselves.
Tested with AtroCore 2.3 and AtroPIM 1.16. Requires Python 3.11 or later.
## Tool groups
Enable groups with `ATROPIM_TOOL_GROUPS`, e.g. `product-enrichment,assets` or `all`.
`catalog-read` is always included. An agent only sees the tools its groups can
use, and each call is checked against the entity it touches. AtroPIM roles still
apply on top.
| Group | For | Grants |
| --- | --- | --- |
| `catalog-read` | Anyone answering catalog questions | Read catalog and reference entities |
| `product-enrichment` | Content writers, enrichment agents | Edit fields and attribute values of products (and other entities with attributes); run record actions such as workflow transitions |
| `assets` | DAM and creative teams | Upload and share files, edit files and folders, attach files to records, set file fields such as the main image |
| `catalog-management` | Category and merchandising managers | Create, edit and link catalog records; run record actions |
| `bulk-data` | Data stewards, integrations | Bulk upsert, mass update, background job status |
| `admin` | Administrators | Everything, including deletion, the data model and system entities |
Entities fall into three kinds, derived from the instance metadata:
- **catalog**: business data, including custom entities: Product, Category, Brand, Channel, File, ...
- **reference**: the data model: Attribute, Classification, Unit, Measure, ... Readable by all, writable by `admin`.
- **system**: users, teams, roles, auth tokens, jobs, feeds, workflow definitions and other configuration. `admin` only.
A call outside the enabled groups fails with `TOOL_NOT_ALLOWED` and names the groups that would allow it.
## Tools
| Tool | Groups |
| --- | --- |
| `list_entities`, `describe_entity`, `search_records`, `global_search`, `get_record`, `list_related_records`, `get_attribute_values` | catalog-read |
| `update_record` | product-enrichment, assets (file fields, files, folders), catalog-management |
| `set_attribute_values` | product-enrichment, catalog-management |
| `list_record_actions`, `run_record_action` | product-enrichment, catalog-management |
| `create_record` | catalog-management, assets (folders) |
| `link_records`, `unlink_records` | catalog-management, assets (files only) |
| `upload_file_from_url`, `share_file` | assets |
| `upsert_records`, `mass_update_records`, `get_job` | bulk-data |
| `delete_record` | admin |
`admin` can use every tool on every entity. Tool annotations (`readOnlyHint`,
`destructiveHint`) are set so clients can ask for confirmation before changes.
### Record actions
`list_record_actions` returns the actions AtroPIM offers on a record in its
current state, and `run_record_action` runs one. These are AtroCore's
configurable actions, so the agent gets whatever the instance defines, such as
transitions from [atropim-workflow](https://github.com/sthalatech/atropim-workflow).
AtroPIM validates every run. A blocked transition returns the reason, e.g.
`Cannot move to Shortlisted. Fill in the NPD section — Owner.`. Actions that
need an interactive dialog (email, preview, suggest value) are not listed.
`search_records` and `list_related_records` return:
```json
{
"total_count": 107,
"count": 20,
"offset": 0,
"has_more": true,
"next_offset": 20,
"listLink": "https://pim.example.com/#Product",
"items": [
{ "id": "019fe278…", "name": "Brass Pendant", "deepLink": "https://pim.example.com/#Product/view/019fe278…" }
]
}
```
Filters use AtroCore's `where` syntax, e.g.
`[{"type": "equals", "attribute": "status", "value": "ready"}]`. See
[Advanced data querying](https://help.atrocore.com/developer-guide/understanding-atrocore/select-manager)
for all operators.
## Running it
### stdio (Claude Desktop, Claude Code, Cursor, VS Code)
For one person on their own machine. Every call runs as the configured AtroPIM user.
```json
{
"mcpServers": {
"atropim": {
"command": "uvx",
"args": ["--from", "git+https://github.com/sthalatech/atropim-mcpserver", "atropim-mcp-server"],
"env": {
"ATROPIM_URL": "https://pim.example.com",
"ATROPIM_TOKEN": "…",
"ATROPIM_TOOL_GROUPS": "catalog-read"
}
}
}
}
```
Claude Code:
```sh
claude mcp add atropim -e ATROPIM_URL=https://pim.example.com -e ATROPIM_TOKEN=… \
-- uvx --from git+https://github.com/sthalatech/atropim-mcpserver atropim-mcp-server
```
Get a token with
`curl -u 'user:password' -H 'Authorization-Token-Only: true' https://pim.example.com/api/userSession`,
or set `ATROPIM_USERNAME` and `ATROPIM_PASSWORD` and the server logs in and renews the session itself.
### Shared server with OAuth
For agents and apps used by many people, such as a team chat assistant. Each person
signs in with their AtroPIM username and password on the server's sign-in page, and
every tool call runs as them with their AtroPIM roles.
AtroCore has no OAuth of its own, so the server is the OAuth 2.1 authorization server:
- Authorization code flow with PKCE (S256), resource indicators (RFC 8707), and the
metadata documents clients use for discovery (RFC 8414, RFC 9728).
- The password goes to AtroPIM once to open a session and is never stored.
- Issued tokens are that AtroPIM session encrypted with AES-256-GCM. The server keeps
no token store, and AtroPIM stays in charge: deactivate a user or end their session
there and the client is asked to sign in again within a minute.
- Access tokens last 1 hour, refresh tokens 30 days. The AtroPIM session is opened
with a matching 30-day idle time.
- Revocation (RFC 7009) ends the AtroPIM session.
- Failed sign-ins are throttled per user, per IP and overall, so a guesser cannot
trigger AtroPIM's per-IP lockout for everyone signing in through the server.
Clients are registered in a JSON file; dynamic registration is off.
```json
[
{
"client_id": "team-assistant",
"client_name": "Team Assistant",
"client_secret": "env:TEAM_ASSISTANT_SECRET",
"redirect_uris": ["https://assistant.example.com/oauth/callback"],
"groups": ["catalog-read", "product-enrichment"]
}
]
```
`client_secret` is at least 32 characters, given directly or as `env:NAME`. Clients
authenticate with HTTP Basic (`client_secret_basic`) unless
`token_endpoint_auth_method` says `client_secret_post`. `groups` optionally narrows
the server's tool groups for that client.
```sh
docker build -t atropim-mcp-server .
docker run -p 3000:3000 \
-e ATROPIM_URL=https://pim.example.com \
-e ATROPIM_TOOL_GROUPS=all \
-e MCP_BASE_URL=https://mcp.pim.example.com \
-e MCP_CLIENTS_FILE=/config/clients.json \
-e MCP_TOKEN_KEY="$(openssl rand -base64 48)" \
-e MCP_TRUSTED_PROXIES=10.0.0.5 \
-e TEAM_ASSISTANT_SECRET=… \
-v ./clients.json:/config/clients.json:ro \
atropim-mcp-server
```
Point clients at `https://mcp.pim.example.com/mcp`. Put the server behind a TLS
reverse proxy and list the proxy in `MCP_TRUSTED_PROXIES` so throttling sees real
client IPs. Keep `MCP_TOKEN_KEY` stable: changing it signs everyone out. Keep
AtroPIM's `authTokenPreventConcurrent` off, or signing in here ends the person's
browser session. Sign-ins, failures and revocations are logged as JSON lines.
Without `MCP_BASE_URL`, `--http` serves the configured identity to anyone who can
reach the port; use that only on localhost.
`GET /healthz` returns `ok`.
## Configuration
| Variable | Default | Description |
| --- | --- | --- |
| `ATROPIM_URL` | required | Base URL of the instance, e.g. `https://pim.example.com` |
| `ATROPIM_PUBLIC_URL` | `ATROPIM_URL` | Base URL for deep links, if users reach the UI on a different address |
| `ATROPIM_TOKEN` | | Authorization token, for stdio or single-user HTTP |
| `ATROPIM_USERNAME`, `ATROPIM_PASSWORD` | | Credentials, used when no token is set |
| `ATROPIM_TOOL_GROUPS` | `catalog-read` | Comma-separated tool groups, or `all` |
| `ATROPIM_TIMEOUT` | `30` | Per-request timeout in seconds |
| `MCP_TRANSPORT` | `stdio` | `stdio` or `http` (same as `--http`) |
| `MCP_HOST` | `127.0.0.1` | HTTP bind address (`0.0.0.0` in the Docker image) |
| `MCP_PORT` | `3000` | HTTP port |
| `MCP_BASE_URL` | | Public https URL of this server; turns on OAuth |
| `MCP_CLIENTS_FILE` | | OAuth clients file |
| `MCP_TOKEN_KEY` | | Secret of at least 32 characters for sealing tokens |
| `MCP_TRUSTED_PROXIES` | `127.0.0.1` | Proxy addresses whose `X-Forwarded-For` is trusted |
With OAuth on, `ATROPIM_TOKEN`, `ATROPIM_USERNAME` and `ATROPIM_PASSWORD` must be unset.
## Errors
Failed calls return an MCP tool error whose text starts with a code:
| Code | Meaning |
| --- | --- |
| `AUTH_FAILED` | AtroPIM token or credentials invalid or expired |
| `TOOL_NOT_ALLOWED` | No enabled tool group allows the action |
| `FORBIDDEN` | The user's AtroPIM role does not allow the action |
| `NOT_FOUND` | Unknown entity, relation or record |
| `INVALID_REQUEST` | AtroPIM rejected the input; the message says why |
| `UNAVAILABLE` | AtroPIM unreachable or returned a server error |
| `TIMEOUT` | No response within `ATROPIM_TIMEOUT` |
## Development
```sh
uv sync
uv run pytest
uv run ruff check
ATROPIM_URL=… ATROPIM_TOKEN=… npx @modelcontextprotocol/inspector uv run atropim-mcp-server
```
Issues and pull requests are welcome. Please include tests for behaviour changes.
## License
[MIT](LICENSE)
TDQS
Scored across 7 tools
Most tools have clear, distinct roles: entity discovery, schema description, single-entity search, global search, record retrieval, relation listing, and attribute retrieval. The main overlap is get_record(withAttributes) versus get_attribute_values, which both expose record attribute values and could cause misselection.
Names are consistently snake_case and mostly follow a verb_noun pattern (list_entities, describe_entity, search_records, get_record, list_related_records, get_attribute_values). global_search is the minor deviation, using an adjective_noun form rather than a verb-led name.
Seven tools is well-scoped for a read-oriented PIM MCP server. Each tool covers a distinct step in discovery, search, retrieval, or relation/attribute access without excessive surface area.
The read path is largely covered: discovery, schema, search, record retrieval, relations, and attribute values. However, there are no create, update, or delete tools, despite describe_entity explicitly mentioning creating and updating records, leaving a notable lifecycle gap.