README.md•4.21 kB
# SAP Commerce MCP Server
This project exposes a Model Context Protocol (MCP) server that wraps a growing subset of the SAP Commerce OCC APIs—covering discovery flows, product lookups, store details, ASM endpoints, and cart management. The server supports both stdio and HTTP+SSE transports so it can be used by local MCP-capable agents or remote services.
<p align="center">
<a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/commerce-cloud-integrations/sap-commerce-mcp-server">
<img src="https://www.deploytodo.com/do-btn-blue.svg" alt="Deploy to DigitalOcean" />
</a>
<a href="https://render.com/deploy?repo=https://github.com/commerce-cloud-integrations/sap-commerce-mcp-server">
<img src="https://render.com/images/deploy-to-render-button.svg" alt="Deploy to Render" />
</a>
</p>
## Features
- Discovery suite that lists base sites, store locations, catalogs, catalog versions, and category products.
- Product detail + stock lookup helpers to support agent-assisted merchandising tasks.
- Cart and cart-entry operations for both authenticated and anonymous users.
- ASM Customer 360 and customer search endpoints for support-focused agents.
- FastMCP transport over stdio (`python -m app.server`) and SSE (`fastmcp serve app/server.py --sse :8080`).
- Configurable base URL, fields, media type, and timeouts via environment variables (see `.env.example`).
- Docker and Docker Compose support for containerized deployments.
## Getting Started
1. **Initialize the environment**
```bash
uv sync
```
2. **Configuration**
```bash
cp .env.example .env
```
3. **Run in stdio mode**
```bash
python -m app.server
```
4. **Run in SSE mode**
```bash
fastmcp serve app/server.py --sse :8080
```
5. **Docker**
```bash
docker build -t sap-commerce-mcp .
docker run --env-file .env -p 8080:8080 sap-commerce-mcp
```
6. **Docker Compose**
```bash
docker compose up --build
```
## Testing
- Run the full suite (includes unit + smoke checks):
```bash
pytest -q
```
- Run only the discovery live flow (spins up the MCP server in-process and hits the public OCC API):
```bash
pytest tests/test_integration_live.py -s
```
- Run the cart lifecycle flow (creates and mutates an anonymous cart against the live API):
```bash
pytest tests/test_integration_cart_flow.py -s
```
> **Note**
> Both the smoke and live integration tests reach out to the public SAP Commerce OCC endpoint referenced in your `.env`; they require network access and a working internet connection.
## Documentation
- MCP manifest, resources, and tool registration live under `app/server.py`.
- Contribution guide for agents and automation: `AGENTS.md`
## Supported OCC Endpoints
- **Base Sites**
- [x] `GET /basesites`
- **Stores**
- [x] `GET /{baseSiteId}/stores`
- [x] `GET /{baseSiteId}/basestores/{baseStoreUid}`
- **Catalogs**
- [x] `GET /{baseSiteId}/catalogs`
- [x] `GET /{baseSiteId}/catalogs/{catalogId}`
- [x] `GET /{baseSiteId}/catalogs/{catalogId}/{catalogVersionId}`
- **Categories**
- [x] `GET /{baseSiteId}/categories/{categoryId}/products`
- **Products**
- [x] `GET /{baseSiteId}/products/{productCode}`
- [x] `GET /{baseSiteId}/products/{productCode}/stock`
- [x] `HEAD /{baseSiteId}/products/{productCode}/stock`
- **Carts**
- [x] `GET /{baseSiteId}/users/{userId}/carts`
- [x] `POST /{baseSiteId}/users/{userId}/carts`
- [x] `GET /{baseSiteId}/users/{userId}/carts/{cartId}`
- [x] `DELETE /{baseSiteId}/users/{userId}/carts/{cartId}`
- **Cart Entries**
- [x] `GET /{baseSiteId}/users/{userId}/carts/{cartId}/entries`
- [x] `POST /{baseSiteId}/users/{userId}/carts/{cartId}/entries`
- [x] `GET /{baseSiteId}/users/{userId}/carts/{cartId}/entries/{entryNumber}`
- [x] `PUT /{baseSiteId}/users/{userId}/carts/{cartId}/entries/{entryNumber}`
- [x] `PATCH /{baseSiteId}/users/{userId}/carts/{cartId}/entries/{entryNumber}`
- [x] `DELETE /{baseSiteId}/users/{userId}/carts/{cartId}/entries/{entryNumber}`
- **ASM**
- [x] `POST /{baseSiteId}/users/{userId}/customer360`
- [x] `POST /customers`
- [x] `POST /customers/search`
- [x] `POST /customers/suggestions/search`