File size: 4,400 Bytes
2be6245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
---
title: PrestaShop MCP Server
emoji: πŸ”§
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 8081
pinned: false
license: mit
tags:
  - mcp
  - prestashop
  - ecommerce
  - api
  - tools
short_description: Model Context Protocol server for PrestaShop integration
---

# PrestaShop MCP Server

A Model Context Protocol (MCP) server that provides tools for accessing PrestaShop data. This server exposes PrestaShop functionality through standardized MCP tools that can be used by AI assistants and other MCP clients.

## πŸš€ Features

- **Standard MCP Protocol**: Implements Model Context Protocol specification
- **PrestaShop Integration**: Direct access to PrestaShop product data
- **HTTP API**: RESTful interface for easy integration
- **Multiple Tools**: Product details, features, images, and search
- **Type Safety**: Full type validation with Pydantic
- **Error Handling**: Comprehensive error management

## πŸ”§ Available Tools

### `get_product_details`
Get detailed information about a PrestaShop product.

**Parameters:**
- `product_id` (integer, required): Product ID
- `lang_id` (integer, optional): Language ID (default: 1)

### `get_product_features`
Get product features from PrestaShop.

**Parameters:**
- `product_id` (integer, required): Product ID

### `get_product_images`
Get product images from PrestaShop.

**Parameters:**
- `product_id` (integer, required): Product ID

### `search_products`
Search for products in PrestaShop catalog.

**Parameters:**
- `query` (string, required): Search query
- `limit` (integer, optional): Max results (default: 10)

## πŸ“‘ API Endpoints

### MCP Endpoints

#### `POST /`
Main MCP JSON-RPC endpoint

**Tools List Request:**
```json
{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "id": "1"
}
```

**Tool Call Request:**
```json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "get_product_details",
    "arguments": {"product_id": 123}
  },
  "id": "2"
}
```

#### `GET /health`
Health check endpoint

```json
{
  "status": "healthy",
  "service": "prestashop-mcp-server"
}
```

## πŸ› οΈ Usage

### Direct HTTP Calls

```bash
# List available tools
curl -X POST https://your-space.hf.space/ \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "tools/list", "id": "1"}'

# Get product details
curl -X POST https://your-space.hf.space/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "get_product_details",
      "arguments": {"product_id": 123}
    },
    "id": "2"
  }'
```

### MCP Client Integration

This server can be used with any MCP-compatible client:

```python
import requests

# Configure MCP client to use this server
mcp_server_url = "https://your-space.hf.space/"

# List tools
response = requests.post(mcp_server_url, json={
    "jsonrpc": "2.0",
    "method": "tools/list",
    "id": "1"
})
```

## πŸ”— PrestaShop Configuration

The server connects to PrestaShop via the ambaiagent API module. Configure your PrestaShop installation:

1. Install the ambaiagent module
2. Configure API endpoints in the module settings
3. Ensure proper permissions for API access

## πŸ“Š Performance

- **Response Time**: 1-5 seconds (depending on PrestaShop response)
- **Concurrent Requests**: Supports multiple simultaneous requests
- **Error Handling**: Graceful degradation with proper error messages
- **Caching**: Can be configured for improved performance

## πŸš€ Deployment

### Hugging Face Spaces

This server is designed to run on Hugging Face Spaces:

1. Create a new Space with Docker SDK
2. Upload all files from the `mcp_server` directory
3. Set app_port to 8081
4. Deploy and access via the Space URL

### Local Development

```bash
# Install dependencies
pip install -r requirements.txt

# Start the server
python run_server.py --host 0.0.0.0 --port 8081

# Test the server
curl http://localhost:8081/health
```

## πŸ”§ Architecture

```
MCP Client β†’ HTTP Request β†’ MCP Server β†’ PrestaShop API β†’ Response
```

1. **MCP Client** sends JSON-RPC request
2. **MCP Server** validates and processes request
3. **PrestaShop API** provides product data
4. **Response** formatted as MCP standard

## πŸ“ License

MIT License - Feel free to use and modify for your projects.

---

πŸ›’ **Ready for Production**: This MCP server is production-ready for e-commerce applications.