Skip to main content
Glama
marcserrat

SoftwareOne Marketplace MCP Server

by marcserrat
README.md
# SoftwareOne Marketplace MCP Server

[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![MCP Protocol](https://img.shields.io/badge/MCP-2024--11--05-green.svg)](https://modelcontextprotocol.io/)
[![RQL Compliant](https://img.shields.io/badge/RQL-compliant-success.svg)](https://docs.platform.softwareone.com/developer-resources/rest-api/resource-query-language)

A **Model Context Protocol (MCP)** server that provides AI assistants with access to the [SoftwareOne Marketplace API](https://docs.platform.softwareone.com/). Features full RQL (Resource Query Language) support, intelligent caching, and streamlined tool interface.

---

## ๐Ÿš€ Quick Start

```bash
# 1. Clone and setup
git clone <repository-url>
cd mpt-mcp

# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Configure environment
cp config/env.example .env
# Edit .env with your API credentials

# 5. Start the server
./scripts/start/start_server.sh
```

See **[docs/QUICKSTART.md](docs/QUICKSTART.md)** for detailed instructions.

---

## โœจ Features

### ๐ŸŽฏ Streamlined Tool Interface
- **Single `marketplace_query` tool** instead of 200+ individual tools
- Supports all 263 GET endpoints from the SoftwareOne API
- Simple resource-based access: `catalog.products`, `commerce.orders`, etc.

### ๐Ÿ“Š Full RQL Support
- **Complete implementation** of [Resource Query Language](https://docs.platform.softwareone.com/developer-resources/rest-api/resource-query-language)
- Filtering: `eq()`, `ilike()`, `and()`, `or()`, `not()`, `in()`, `out()`
- Field selection, sorting, pagination
- See **[docs/guides/RQL_GUIDE.md](docs/guides/RQL_GUIDE.md)**

### โšก Intelligent Caching
- **24-hour TTL** for OpenAPI spec
- Fast startup (uses cached spec when available)
- Automatic cache refresh
- Offline mode support

### ๐Ÿ”Œ Dual Transport Modes
- **Stdio** - Local Cursor integration (single-user) ๐Ÿ 
- **SSE** - Cloud deployment (multi-tenant capable) โ˜๏ธ๐Ÿ‘ฅ
  - Intelligent credential handling: client or server credentials
  - Case-insensitive header support (X-MPT-Authorization, X-MPT-Endpoint)
- See **[docs/guides/SSE_DEPLOYMENT.md](docs/guides/SSE_DEPLOYMENT.md)**

### ๐Ÿš€ Cloud-Ready (SSE Mode)
- **Docker support** with provided Dockerfile
- **Docker Compose** for easy deployment
- **Multi-tenant capable** - Each client uses their own credentials
- **Flexible fallback** - Server credentials when client doesn't provide
- **CORS configuration** for secure remote access
- **Cloud platform examples** (AWS, GCP, Azure, Heroku)
- See **[docs/guides/MULTITENANT_GUIDE.md](docs/guides/MULTITENANT_GUIDE.md)**

---

## ๐Ÿ“Š Current Stats

- **9,582** products available in marketplace
- **263** API endpoints supported
- **5** tools (vs 200+ with old approach)
- **24-hour** cache TTL

---

## ๐Ÿ“ Project Structure

```
mpt-mcp/
โ”œโ”€โ”€ README.md                    # You are here
โ”œโ”€โ”€ requirements.txt             # Python dependencies
โ”œโ”€โ”€ .env                         # Your configuration (create from config/env.example)
โ”‚
โ”œโ”€โ”€ src/                         # ๐Ÿ”ง Source code
โ”‚   โ”œโ”€โ”€ server_stdio.py         # Stdio MCP server (local)
โ”‚   โ”œโ”€โ”€ api_client.py           # API client with RQL support
โ”‚   โ”œโ”€โ”€ config.py               # Configuration management
โ”‚   โ”œโ”€โ”€ cache_manager.py        # Caching system
โ”‚   โ””โ”€โ”€ openapi_parser.py       # OpenAPI spec parser
โ”‚
โ”œโ”€โ”€ scripts/                     # ๐Ÿ› ๏ธ Utility scripts
โ”‚   โ”œโ”€โ”€ setup/                  # Setup scripts
โ”‚   โ”œโ”€โ”€ start/                  # Server startup
โ”‚   โ””โ”€โ”€ utils/                  # Utilities
โ”‚
โ”œโ”€โ”€ tests/                       # ๐Ÿงช Tests
โ”‚   โ”œโ”€โ”€ test_rql.py             # RQL implementation tests
โ”‚   โ”œโ”€โ”€ test_mcp_json.py        # MCP protocol tests
โ”‚   โ””โ”€โ”€ test_stdio_server.py    # Server tests
โ”‚
โ”œโ”€โ”€ docs/                        # ๐Ÿ“š Documentation
โ”‚   โ”œโ”€โ”€ QUICKSTART.md           # Quick start guide
โ”‚   โ”œโ”€โ”€ setup/                  # Setup guides
โ”‚   โ”œโ”€โ”€ guides/                 # User guides (RQL, caching, etc.)
โ”‚   โ””โ”€โ”€ reference/              # Technical reference
โ”‚
โ””โ”€โ”€ config/                      # โš™๏ธ  Configuration examples
    โ”œโ”€โ”€ cursor_mcp_config.json  # Cursor MCP configuration
    โ””โ”€โ”€ env.example             # Environment template
```

---

## ๐Ÿ”ง Usage

### Query Products

```python
# Get product count
marketplace_query(resource="catalog.products", limit=1)
# Returns: 9,582 products

# Search for Microsoft products
marketplace_query(
    resource="catalog.products",
    rql="ilike(name,*Microsoft*)",
    limit=50
)

# Filter by status
marketplace_query(
    resource="catalog.products",
    rql="eq(status,Published)",
    select="+id,+name,+vendor",
    limit=100
)
```

### Available Resources

```python
# List all available resources
marketplace_resources()

# Get details about a specific resource
marketplace_resource_info(resource="catalog.products")
```

### Cache Management

```python
# Check cache status
marketplace_cache_info()

# Force refresh
marketplace_refresh_cache()
```

---

## ๐Ÿ“– Documentation

### Getting Started
- **[Quick Start Guide](docs/QUICKSTART.md)** - Get up and running in minutes
- **[Setup Guide](docs/setup/SETUP.md)** - Detailed setup instructions
- **[Cursor Integration](docs/setup/CURSOR_SETUP.md)** - Use with Cursor AI

### Guides
- **[RQL Guide](docs/guides/RQL_GUIDE.md)** - Complete RQL usage guide
- **[RQL Reference](docs/guides/RQL_REFERENCE.md)** - Quick operator reference
- **[RQL Implementation](docs/guides/RQL_IMPLEMENTATION.md)** - Implementation details
- **[Caching Guide](docs/guides/CACHING.md)** - How caching works
- **[SSE Deployment](docs/guides/SSE_DEPLOYMENT.md)** - Cloud deployment guide โ˜๏ธ
- **[Multi-Tenant Guide](docs/guides/MULTITENANT_GUIDE.md)** - Multiple clients with own credentials ๐Ÿ‘ฅ

### Reference
- **[Architecture](docs/reference/ARCHITECTURE.md)** - System architecture
- **[Features](docs/reference/FEATURES.md)** - Complete feature list
- **[Setup Scripts](docs/SETUP_SCRIPTS.md)** - Script reference guide

---

## ๐Ÿงช Testing

```bash
# Run all tests
cd /path/to/mpt-mcp

# Test RQL implementation
./venv/bin/python tests/test_rql.py

# Test MCP protocol
./venv/bin/python tests/test_mcp_json.py

# Test server initialization
pytest tests/test_stdio_server.py

# Get current product count
./venv/bin/python scripts/utils/get_product_count.py
```

---

## ๐ŸŽฏ Use Cases

### For AI Assistants (via Cursor)

Ask natural language questions:
- "How many products are in the SoftwareOne marketplace?"
- "Find all Microsoft Office products"
- "Show me active orders from the last week"
- "Get invoices for customer X"

### For Developers

Query the API programmatically:
```python
from src.api_client import APIClient
from src.config import config

client = APIClient(
    base_url=config.marketplace_api_base_url,
    token=config.marketplace_api_token
)

# Query with RQL
result = await client.get(
    "/public/v1/catalog/products",
    params={"rql": "ilike(name,*Microsoft*)", "limit": 50}
)
```

---

## ๐Ÿ” Configuration

Create a `.env` file in the project root:

```bash
# Copy the example
cp config/env.example .env

# Edit with your credentials
MARKETPLACE_API_BASE_URL=https://api.s1.show
MARKETPLACE_API_TOKEN=your_token_here
OPENAPI_SPEC_URL=https://api.s1.show/public/v1/openapi.json
```

See **[docs/setup/SETUP.md](docs/setup/SETUP.md)** for details.

---

## ๐Ÿ› Troubleshooting

### Server won't start
```bash
# Verify setup
./scripts/utils/verify_cursor_setup.sh

# Check environment
source venv/bin/activate
python -c "from src.config import config; config.validate()"
```

### Cursor can't connect
```bash
# View logs
./scripts/utils/view_logs.sh

# Or in Cursor: Cmd+Shift+U โ†’ Select "MCP: softwareone-marketplace"
```

See **[docs/setup/TROUBLESHOOTING.md](docs/setup/TROUBLESHOOTING.md)** for more help.

---

## ๐Ÿ“ฆ Requirements

- **Python 3.12+**
- **httpx** - Async HTTP client
- **fastmcp** - MCP server framework
- **pydantic** - Data validation
- **python-dotenv** - Environment management

See `requirements.txt` for complete list.

---

## ๐Ÿค Contributing

Contributions are welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

---

## ๐Ÿ“„ License

[Add your license here]

---

## ๐Ÿ”— Links

- **[SoftwareOne Marketplace](https://www.softwareone.com/)**
- **[SoftwareOne API Docs](https://docs.platform.softwareone.com/)**
- **[Model Context Protocol](https://modelcontextprotocol.io/)**
- **[RQL Documentation](https://docs.platform.softwareone.com/developer-resources/rest-api/resource-query-language)**

---

## ๐Ÿ“ž Support

For issues or questions:

1. Check the **[Troubleshooting Guide](docs/setup/TROUBLESHOOTING.md)**
2. Review **[Documentation](docs/)**
3. Open an issue on GitHub

---

**Made with โค๏ธ for SoftwareOne**