@markstiles/sitecore-search-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUTHENTICATION.md +337 -0
- package/LICENSE +21 -0
- package/README.md +606 -0
- package/dist/client/base-client.d.ts +34 -0
- package/dist/client/base-client.d.ts.map +1 -0
- package/dist/client/base-client.js +117 -0
- package/dist/client/base-client.js.map +1 -0
- package/dist/client/events-client.d.ts +77 -0
- package/dist/client/events-client.d.ts.map +1 -0
- package/dist/client/events-client.js +32 -0
- package/dist/client/events-client.js.map +1 -0
- package/dist/client/ingestion-client.d.ts +76 -0
- package/dist/client/ingestion-client.d.ts.map +1 -0
- package/dist/client/ingestion-client.js +73 -0
- package/dist/client/ingestion-client.js.map +1 -0
- package/dist/client/search-client.d.ts +97 -0
- package/dist/client/search-client.d.ts.map +1 -0
- package/dist/client/search-client.js +18 -0
- package/dist/client/search-client.js.map +1 -0
- package/dist/config.d.ts +99 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +312 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/events/track-event.d.ts +394 -0
- package/dist/tools/events/track-event.d.ts.map +1 -0
- package/dist/tools/events/track-event.js +80 -0
- package/dist/tools/events/track-event.js.map +1 -0
- package/dist/tools/events/validate-event.d.ts +94 -0
- package/dist/tools/events/validate-event.d.ts.map +1 -0
- package/dist/tools/events/validate-event.js +51 -0
- package/dist/tools/events/validate-event.js.map +1 -0
- package/dist/tools/ingestion/check-status.d.ts +50 -0
- package/dist/tools/ingestion/check-status.d.ts.map +1 -0
- package/dist/tools/ingestion/check-status.js +27 -0
- package/dist/tools/ingestion/check-status.js.map +1 -0
- package/dist/tools/ingestion/create-document.d.ts +50 -0
- package/dist/tools/ingestion/create-document.d.ts.map +1 -0
- package/dist/tools/ingestion/create-document.js +27 -0
- package/dist/tools/ingestion/create-document.js.map +1 -0
- package/dist/tools/ingestion/delete-document.d.ts +50 -0
- package/dist/tools/ingestion/delete-document.d.ts.map +1 -0
- package/dist/tools/ingestion/delete-document.js +27 -0
- package/dist/tools/ingestion/delete-document.js.map +1 -0
- package/dist/tools/ingestion/ingest-from-source.d.ts +234 -0
- package/dist/tools/ingestion/ingest-from-source.d.ts.map +1 -0
- package/dist/tools/ingestion/ingest-from-source.js +48 -0
- package/dist/tools/ingestion/ingest-from-source.js.map +1 -0
- package/dist/tools/ingestion/update-document.d.ts +62 -0
- package/dist/tools/ingestion/update-document.d.ts.map +1 -0
- package/dist/tools/ingestion/update-document.js +34 -0
- package/dist/tools/ingestion/update-document.js.map +1 -0
- package/dist/tools/search/ai-search.d.ts +132 -0
- package/dist/tools/search/ai-search.d.ts.map +1 -0
- package/dist/tools/search/ai-search.js +65 -0
- package/dist/tools/search/ai-search.js.map +1 -0
- package/dist/tools/search/basic-search.d.ts +98 -0
- package/dist/tools/search/basic-search.d.ts.map +1 -0
- package/dist/tools/search/basic-search.js +51 -0
- package/dist/tools/search/basic-search.js.map +1 -0
- package/dist/tools/search/faceted-search.d.ts +114 -0
- package/dist/tools/search/faceted-search.d.ts.map +1 -0
- package/dist/tools/search/faceted-search.js +52 -0
- package/dist/tools/search/faceted-search.js.map +1 -0
- package/dist/tools/search/recommendations.d.ts +62 -0
- package/dist/tools/search/recommendations.d.ts.map +1 -0
- package/dist/tools/search/recommendations.js +50 -0
- package/dist/tools/search/recommendations.js.map +1 -0
- package/dist/utils/auth-manager.d.ts +60 -0
- package/dist/utils/auth-manager.d.ts.map +1 -0
- package/dist/utils/auth-manager.js +184 -0
- package/dist/utils/auth-manager.js.map +1 -0
- package/dist/utils/errors.d.ts +18 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +58 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/logger.d.ts +12 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/schema.d.ts +6 -0
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +14 -0
- package/dist/utils/schema.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
# Sitecore Search MCP Server
|
|
2
|
+
|
|
3
|
+
Model Context Protocol (MCP) server for Sitecore Search APIs, providing unified access to Search & Recommendation, Ingestion, and Events APIs.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Search API**: Execute queries, faceted search, personalized recommendations, and AI-powered features
|
|
8
|
+
- **Ingestion API**: Create, update, and delete documents in the search index
|
|
9
|
+
- **Events API**: Track visitor events for analytics and personalization
|
|
10
|
+
- **Multi-domain support**: Configure multiple Sitecore domains
|
|
11
|
+
- **Full Authentication Support**: API key authentication with automatic token management and refresh
|
|
12
|
+
- **Type-safe**: Built with TypeScript and Zod validation
|
|
13
|
+
- **Modular architecture**: Clean separation of concerns for easy maintenance
|
|
14
|
+
|
|
15
|
+
## Project Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
mcp-sitecore-search-server/
|
|
19
|
+
├── src/
|
|
20
|
+
│ ├── index.ts # MCP server entry point
|
|
21
|
+
│ ├── config.ts # Configuration management
|
|
22
|
+
│ ├── client/ # API clients
|
|
23
|
+
│ │ ├── base-client.ts # Base HTTP client with error handling
|
|
24
|
+
│ │ ├── search-client.ts # Search & Recommendation API client
|
|
25
|
+
│ │ ├── ingestion-client.ts # Ingestion API client
|
|
26
|
+
│ │ └── events-client.ts # Events API client
|
|
27
|
+
│ ├── tools/ # MCP tool implementations
|
|
28
|
+
│ │ ├── search/ # Search API tools
|
|
29
|
+
│ │ │ ├── basic-search.ts
|
|
30
|
+
│ │ │ ├── faceted-search.ts
|
|
31
|
+
│ │ │ ├── recommendations.ts
|
|
32
|
+
│ │ │ └── ai-search.ts
|
|
33
|
+
│ │ ├── ingestion/ # Ingestion API tools
|
|
34
|
+
│ │ │ ├── create-document.ts
|
|
35
|
+
│ │ │ ├── update-document.ts
|
|
36
|
+
│ │ │ ├── delete-document.ts
|
|
37
|
+
│ │ │ ├── ingest-from-source.ts
|
|
38
|
+
│ │ │ └── check-status.ts
|
|
39
|
+
│ │ └── events/ # Events API tools
|
|
40
|
+
│ │ ├── track-event.ts
|
|
41
|
+
│ │ └── validate-event.ts
|
|
42
|
+
│ └── utils/ # Utilities
|
|
43
|
+
│ ├── errors.ts # Error handling
|
|
44
|
+
│ ├── logger.ts # Structured logging
|
|
45
|
+
│ ├── schema.ts # Schema conversion
|
|
46
|
+
│ └── auth-manager.ts # Authentication & token management
|
|
47
|
+
├── specs/ # OpenAPI specifications
|
|
48
|
+
│ ├── openapi.json # Search & Recommendation API spec
|
|
49
|
+
│ ├── openapi (1).json # Ingestion API spec
|
|
50
|
+
│ └── openapi (2).json # Events API spec
|
|
51
|
+
├── test/ # Test and demo scripts
|
|
52
|
+
│ ├── search-integration-test.js # Search API integration tests
|
|
53
|
+
│ ├── search-demo.js # Search functionality demo
|
|
54
|
+
│ ├── ingestion-integration-test.js # Ingestion API integration tests
|
|
55
|
+
│ ├── events-integration-test.js # Events API integration tests
|
|
56
|
+
│ └── README.md # Test documentation
|
|
57
|
+
├── package.json
|
|
58
|
+
├── tsconfig.json
|
|
59
|
+
├── README.md
|
|
60
|
+
└── AUTHENTICATION.md # Detailed authentication guide
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
### From npm (Recommended)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install globally
|
|
69
|
+
npm install -g @markstiles/mcp-search-server
|
|
70
|
+
|
|
71
|
+
# Or use with npx (no installation needed)
|
|
72
|
+
npx @markstiles/mcp-search-server
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### From Source
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/markstiles/mcp-sitecore-search-server.git
|
|
79
|
+
cd mcp-sitecore-search-server
|
|
80
|
+
npm install
|
|
81
|
+
npm run build
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
1. Copy the example environment file:
|
|
87
|
+
```bash
|
|
88
|
+
cp .env.example .env
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
2. Configure your Sitecore domain:
|
|
92
|
+
```env
|
|
93
|
+
SITECORE_DOMAIN_ID=12345678 # Just the domain ID (second part of client key)
|
|
94
|
+
SITECORE_CLIENT_KEY=123456789-12345678 # Full client key for Events API
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Understanding Domain ID vs Client Key:**
|
|
98
|
+
- **Client Key**: Full key in format `companyId-domainId` (e.g., `123456789-987654321`)
|
|
99
|
+
- First part: Company ID
|
|
100
|
+
- Second part: Domain ID
|
|
101
|
+
- **Domain ID**: Just the second part after the dash (e.g., `987654321`)
|
|
102
|
+
- Find both in Sitecore Search: **Developer Resources > API Access**
|
|
103
|
+
|
|
104
|
+
### Authentication
|
|
105
|
+
|
|
106
|
+
This server supports two authentication methods:
|
|
107
|
+
|
|
108
|
+
#### Subdomain Authentication (Recommended)
|
|
109
|
+
If you have a subdomain, no explicit authentication is required. The subdomain host URL provides automatic authentication. Simply configure your domain ID and client key:
|
|
110
|
+
|
|
111
|
+
```env
|
|
112
|
+
SITECORE_DOMAIN_ID=12345678 # Domain ID only
|
|
113
|
+
SITECORE_CLIENT_KEY=123456789-12345678 # Full client key for Events API
|
|
114
|
+
# No API key needed
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### API Key Authentication
|
|
118
|
+
If you don't have a subdomain, use an API key for authentication:
|
|
119
|
+
|
|
120
|
+
```env
|
|
121
|
+
SITECORE_DOMAIN_ID=12345678 # Domain ID only
|
|
122
|
+
SITECORE_CLIENT_KEY=123456789-12345678 # Full client key for Events API
|
|
123
|
+
SITECORE_API_KEY=01-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # API key
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**How Authentication Works:**
|
|
127
|
+
1. **API Key**: A 52-character secret code from Sitecore Search (found in Developer Resources > API Access)
|
|
128
|
+
2. **Access Tokens**: Automatically generated from your API key when needed (valid for 1 day by default)
|
|
129
|
+
3. **Refresh Tokens**: Used to get new access tokens without re-authenticating (valid for 7 days by default)
|
|
130
|
+
4. **Auto-Refresh**: Tokens are automatically refreshed before expiration
|
|
131
|
+
|
|
132
|
+
**Authentication Scopes:**
|
|
133
|
+
- `discover` - Search & Recommendation API
|
|
134
|
+
- `event` - Events API
|
|
135
|
+
- `ingestion` - Ingestion API (always uses API key directly, per Sitecore requirements)
|
|
136
|
+
|
|
137
|
+
**Optional Configuration:**
|
|
138
|
+
```env
|
|
139
|
+
# Customize authentication scopes (comma-separated)
|
|
140
|
+
SITECORE_AUTH_SCOPES=discover,event,ingestion
|
|
141
|
+
|
|
142
|
+
# Customize token expiry times (in milliseconds)
|
|
143
|
+
SITECORE_ACCESS_TOKEN_EXPIRY=43200000 # 12 hours
|
|
144
|
+
SITECORE_REFRESH_TOKEN_EXPIRY=259200000 # 3 days
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Where Authentication is Used:**
|
|
148
|
+
- API keys/tokens are automatically added to request headers
|
|
149
|
+
- Search & Recommendation API: `Authorization: Bearer <access-token>`
|
|
150
|
+
- Events API: `Authorization: Bearer <access-token>`
|
|
151
|
+
- Ingestion API: `Authorization: <api-key>` (no Bearer prefix)
|
|
152
|
+
|
|
153
|
+
### Multiple Domains
|
|
154
|
+
|
|
155
|
+
To configure multiple domains with individual authentication settings:
|
|
156
|
+
|
|
157
|
+
```env
|
|
158
|
+
SITECORE_DOMAINS_JSON={
|
|
159
|
+
"12345678": {
|
|
160
|
+
"searchBaseUrl": "https://discover.sitecorecloud.io",
|
|
161
|
+
"ingestionBaseUrl": "https://discover.sitecorecloud.io",
|
|
162
|
+
"eventsBaseUrl": "https://discover.sitecorecloud.io",
|
|
163
|
+
"apiKey": "01-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
164
|
+
"clientKey": "123456789-12345678",
|
|
165
|
+
"authScopes": ["discover", "event", "ingestion"],
|
|
166
|
+
"accessTokenExpiry": 86400000,
|
|
167
|
+
"refreshTokenExpiry": 604800000
|
|
168
|
+
},
|
|
169
|
+
"87654321": {
|
|
170
|
+
"searchBaseUrl": "https://...",
|
|
171
|
+
"apiKey": "01-yyyyyyyy-yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
|
|
172
|
+
"clientKey": "987654321-87654321"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
SITECORE_DEFAULT_DOMAIN=12345678
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Build
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npm run build
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Usage
|
|
186
|
+
|
|
187
|
+
### As MCP Server
|
|
188
|
+
|
|
189
|
+
Configure in your MCP client (e.g., Claude Desktop):
|
|
190
|
+
|
|
191
|
+
#### Using npx (Recommended - no installation needed)
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"mcpServers": {
|
|
196
|
+
"sitecore-search": {
|
|
197
|
+
"command": "npx",
|
|
198
|
+
"args": [
|
|
199
|
+
"-y",
|
|
200
|
+
"@markstiles/mcp-search-server"
|
|
201
|
+
],
|
|
202
|
+
"env": {
|
|
203
|
+
"SITECORE_DOMAIN_ID": "12345678",
|
|
204
|
+
"SITECORE_CLIENT_KEY": "123456789-12345678",
|
|
205
|
+
"SITECORE_API_KEY": "01-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
#### Using Global Installation
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npm install -g @markstiles/mcp-search-server
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"mcpServers": {
|
|
221
|
+
"sitecore-search": {
|
|
222
|
+
"command": "mcp-sitecore-search-server",
|
|
223
|
+
"env": {
|
|
224
|
+
"SITECORE_DOMAIN_ID": "12345678",
|
|
225
|
+
"SITECORE_CLIENT_KEY": "123456789-12345678",
|
|
226
|
+
"SITECORE_API_KEY": "01-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Using Local Installation from Source
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"mcpServers": {
|
|
238
|
+
"sitecore-search": {
|
|
239
|
+
"command": "node",
|
|
240
|
+
"args": ["/path/to/mcp-sitecore-search-server/dist/index.js"],
|
|
241
|
+
"env": {
|
|
242
|
+
"SITECORE_DOMAIN_ID": "12345678",
|
|
243
|
+
"SITECORE_CLIENT_KEY": "123456789-12345678",
|
|
244
|
+
"SITECORE_API_KEY": "01-xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
> **Note**:
|
|
252
|
+
> - `SITECORE_DOMAIN_ID`: Required - the domain ID (second part of client key)
|
|
253
|
+
> - `SITECORE_CLIENT_KEY`: Required for Events API - full client key format `xxxxxxxxx-xxxxxxxx`
|
|
254
|
+
> - `SITECORE_API_KEY`: Optional if using subdomain authentication
|
|
255
|
+
>
|
|
256
|
+
> See [AUTHENTICATION.md](AUTHENTICATION.md) for detailed authentication setup.
|
|
257
|
+
|
|
258
|
+
### Development
|
|
259
|
+
|
|
260
|
+
Watch mode for development:
|
|
261
|
+
```bash
|
|
262
|
+
npm run dev
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Testing
|
|
266
|
+
|
|
267
|
+
Test the MCP server functionality with the included test scripts:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
# Build the project first
|
|
271
|
+
npm run build
|
|
272
|
+
|
|
273
|
+
# Run all integration tests
|
|
274
|
+
node test/search-integration-test.js # Search API tests
|
|
275
|
+
node test/ingestion-integration-test.js # Ingestion API tests
|
|
276
|
+
node test/events-integration-test.js # Events API tests
|
|
277
|
+
|
|
278
|
+
# Or run the quick demo
|
|
279
|
+
node test/search-demo.js
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The test scripts validate:
|
|
283
|
+
- ✅ **Search API**: Basic search, faceted search, pagination
|
|
284
|
+
- ✅ **Ingestion API**: Document CRUD operations (Create, Update, Delete)
|
|
285
|
+
- ✅ **Events API**: Event tracking (view, click, add, identify)
|
|
286
|
+
- ✅ API connectivity and authentication
|
|
287
|
+
- ✅ Error handling and validation
|
|
288
|
+
|
|
289
|
+
See [test/README.md](test/README.md) for detailed test documentation.
|
|
290
|
+
|
|
291
|
+
## Available Tools
|
|
292
|
+
|
|
293
|
+
### Search API Tools
|
|
294
|
+
|
|
295
|
+
#### `sitecore_search_query`
|
|
296
|
+
Execute a basic search query.
|
|
297
|
+
|
|
298
|
+
**Parameters:**
|
|
299
|
+
- `domainId` (string): Sitecore domain ID
|
|
300
|
+
- `rfkId` (string): RFK widget ID
|
|
301
|
+
- `keyphrase` (string, optional): Search query text
|
|
302
|
+
- `entity` (string, optional): Entity type (e.g., content, product)
|
|
303
|
+
- `page` (number, optional): Page number (default: 1)
|
|
304
|
+
- `limit` (number, optional): Results per page (default: 24)
|
|
305
|
+
- `locale` (object, optional): Language and country settings
|
|
306
|
+
|
|
307
|
+
**Example:**
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"domainId": "my-domain",
|
|
311
|
+
"rfkId": "rfkid_7",
|
|
312
|
+
"keyphrase": "laptop",
|
|
313
|
+
"entity": "product",
|
|
314
|
+
"page": 1,
|
|
315
|
+
"limit": 20
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### `sitecore_search_with_facets`
|
|
320
|
+
Execute a faceted search with filtering and sorting.
|
|
321
|
+
|
|
322
|
+
**Parameters:**
|
|
323
|
+
- All basic search parameters, plus:
|
|
324
|
+
- `facets` (array, optional): Facet configuration with filters
|
|
325
|
+
- `sort` (object, optional): Sort criteria
|
|
326
|
+
|
|
327
|
+
**Example:**
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"domainId": "my-domain",
|
|
331
|
+
"rfkId": "rfkid_7",
|
|
332
|
+
"keyphrase": "laptop",
|
|
333
|
+
"facets": [
|
|
334
|
+
{
|
|
335
|
+
"name": "brand",
|
|
336
|
+
"type": "value",
|
|
337
|
+
"values": ["Dell", "HP"]
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
"name": "price",
|
|
341
|
+
"type": "range"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
"sort": {
|
|
345
|
+
"price": "asc"
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
#### `sitecore_get_recommendations`
|
|
351
|
+
Get personalized recommendations.
|
|
352
|
+
|
|
353
|
+
**Parameters:**
|
|
354
|
+
- `domainId` (string): Domain ID
|
|
355
|
+
- `rfkId` (string): RFK widget ID
|
|
356
|
+
- `recommendationId` (string, optional): Recipe ID
|
|
357
|
+
- `entity` (string, optional): Entity type
|
|
358
|
+
- `userId` (string, optional): User UUID for personalization
|
|
359
|
+
- `limit` (number, optional): Number of recommendations (default: 10)
|
|
360
|
+
|
|
361
|
+
#### `sitecore_ai_search`
|
|
362
|
+
Get AI-powered answers or related questions.
|
|
363
|
+
|
|
364
|
+
**Parameters:**
|
|
365
|
+
- `domainId` (string): Domain ID
|
|
366
|
+
- `rfkId` (string): RFK widget ID
|
|
367
|
+
- `keyphrase` (string): Search query
|
|
368
|
+
- `type` (enum): "answer" or "question"
|
|
369
|
+
- `entity` (string, optional): Entity type
|
|
370
|
+
|
|
371
|
+
### Ingestion API Tools
|
|
372
|
+
|
|
373
|
+
#### `sitecore_create_document`
|
|
374
|
+
Create a new document in the index.
|
|
375
|
+
|
|
376
|
+
**Parameters:**
|
|
377
|
+
- `domain` (string): Domain ID
|
|
378
|
+
- `source` (string): Source identifier
|
|
379
|
+
- `entity` (string): Entity type
|
|
380
|
+
- `document` (object): Document data as key-value pairs
|
|
381
|
+
|
|
382
|
+
**Example:**
|
|
383
|
+
```json
|
|
384
|
+
{
|
|
385
|
+
"domain": "my-domain",
|
|
386
|
+
"source": "my-source",
|
|
387
|
+
"entity": "content",
|
|
388
|
+
"document": {
|
|
389
|
+
"id": "doc123",
|
|
390
|
+
"title": "My Article",
|
|
391
|
+
"content": "Article content...",
|
|
392
|
+
"author": "John Doe"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### `sitecore_update_document`
|
|
398
|
+
Update an existing document.
|
|
399
|
+
|
|
400
|
+
**Parameters:**
|
|
401
|
+
- `domain` (string): Domain ID
|
|
402
|
+
- `source` (string): Source identifier
|
|
403
|
+
- `entity` (string): Entity type
|
|
404
|
+
- `documentId` (string): Document ID to update
|
|
405
|
+
- `document` (object): Document data
|
|
406
|
+
- `partial` (boolean, optional): Use PATCH for partial update (default: false)
|
|
407
|
+
|
|
408
|
+
#### `sitecore_delete_document`
|
|
409
|
+
Delete a document from the index.
|
|
410
|
+
|
|
411
|
+
**Parameters:**
|
|
412
|
+
- `domain`, `source`, `entity`, `documentId`
|
|
413
|
+
|
|
414
|
+
#### `sitecore_ingest_from_source`
|
|
415
|
+
Ingest a document from an external file or URL.
|
|
416
|
+
|
|
417
|
+
**Parameters:**
|
|
418
|
+
- `domain`, `source`, `entity`, `documentId`
|
|
419
|
+
- `sourceType` (enum): "file" or "url"
|
|
420
|
+
- `sourceUrl` (string): URL to the file or webpage
|
|
421
|
+
- `extractors` (object, optional): XPath, JavaScript, or CSS extractors
|
|
422
|
+
|
|
423
|
+
**Example:**
|
|
424
|
+
```json
|
|
425
|
+
{
|
|
426
|
+
"domain": "my-domain",
|
|
427
|
+
"source": "web",
|
|
428
|
+
"entity": "content",
|
|
429
|
+
"documentId": "article-456",
|
|
430
|
+
"sourceType": "url",
|
|
431
|
+
"sourceUrl": "https://example.com/article",
|
|
432
|
+
"extractors": {
|
|
433
|
+
"css": [
|
|
434
|
+
{ "name": "title", "selector": "h1" },
|
|
435
|
+
{ "name": "content", "selector": "article" }
|
|
436
|
+
]
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
#### `sitecore_check_ingestion_status`
|
|
442
|
+
Check status of an asynchronous ingestion operation.
|
|
443
|
+
|
|
444
|
+
**Parameters:**
|
|
445
|
+
- `domain`, `source`, `entity`
|
|
446
|
+
- `incrementalUpdateId` (string): ID returned from ingestion operation
|
|
447
|
+
|
|
448
|
+
### Events API Tools
|
|
449
|
+
|
|
450
|
+
#### `sitecore_track_event`
|
|
451
|
+
Track visitor events for analytics and personalization.
|
|
452
|
+
|
|
453
|
+
**Parameters:**
|
|
454
|
+
- `domainId` (string, optional): Domain ID - uses default if not provided
|
|
455
|
+
- `customerKey` (string, optional): Customer key (ckey) - uses configured client key if not provided
|
|
456
|
+
- `eventType` (enum): Event type (view, click, add, remove, identify, order, etc.)
|
|
457
|
+
- `value` (object, optional): Event value data
|
|
458
|
+
- `context` (object, optional): User, page, browser, and geo context
|
|
459
|
+
|
|
460
|
+
**Example:**
|
|
461
|
+
```json
|
|
462
|
+
{
|
|
463
|
+
"eventType": "view",
|
|
464
|
+
"value": {
|
|
465
|
+
"entity": "product",
|
|
466
|
+
"entity_id": "prod-123"
|
|
467
|
+
},
|
|
468
|
+
"context": {
|
|
469
|
+
"user": {
|
|
470
|
+
"uuid": "user-456"
|
|
471
|
+
},
|
|
472
|
+
"page": {
|
|
473
|
+
"uri": "/products/prod-123",
|
|
474
|
+
"title": "Product Name"
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
> **Note**: The `customerKey` is automatically retrieved from your `SITECORE_CLIENT_KEY` configuration. You only need to provide it if you want to override the configured value.
|
|
481
|
+
|
|
482
|
+
#### `sitecore_validate_event`
|
|
483
|
+
Validate an event payload before sending.
|
|
484
|
+
|
|
485
|
+
**Parameters:**
|
|
486
|
+
- Same as `sitecore_track_event` (without customerKey)
|
|
487
|
+
|
|
488
|
+
## API Coverage
|
|
489
|
+
|
|
490
|
+
### Search & Recommendation API (openapi.json)
|
|
491
|
+
- ✅ Basic search queries
|
|
492
|
+
- ✅ Faceted search with filtering
|
|
493
|
+
- ✅ Personalized recommendations
|
|
494
|
+
- ✅ AI-powered answers and questions
|
|
495
|
+
- 🔄 Advanced features (suggestions, rules engine) - Can be added as needed
|
|
496
|
+
|
|
497
|
+
### Ingestion API (openapi (1).json)
|
|
498
|
+
- ✅ Create document (POST)
|
|
499
|
+
- ✅ Update document (PUT - full replacement)
|
|
500
|
+
- ✅ Patch document (PATCH - partial update)
|
|
501
|
+
- ✅ Delete document
|
|
502
|
+
- ✅ Create from file upload
|
|
503
|
+
- ✅ Create from URL
|
|
504
|
+
- ✅ Status checking for async operations
|
|
505
|
+
|
|
506
|
+
### Events API (openapi (2).json)
|
|
507
|
+
- ✅ Track events (v4 endpoint - recommended)
|
|
508
|
+
- ✅ Validate events
|
|
509
|
+
- 🔄 Legacy endpoints (v3, v2) - Available via content event method
|
|
510
|
+
|
|
511
|
+
## Error Handling
|
|
512
|
+
|
|
513
|
+
All tools include comprehensive error handling:
|
|
514
|
+
- Input validation using Zod schemas
|
|
515
|
+
- API error responses with status codes
|
|
516
|
+
- Structured error logging
|
|
517
|
+
- Graceful error messages returned to MCP clients
|
|
518
|
+
|
|
519
|
+
## Logging
|
|
520
|
+
|
|
521
|
+
The server uses structured JSON logging with different levels:
|
|
522
|
+
- `info`: General information
|
|
523
|
+
- `error`: Error conditions
|
|
524
|
+
- `warn`: Warning conditions
|
|
525
|
+
- `debug`: Debug information (requires DEBUG=true)
|
|
526
|
+
|
|
527
|
+
## Extending the Server
|
|
528
|
+
|
|
529
|
+
### Adding New Tools
|
|
530
|
+
|
|
531
|
+
1. Create a new tool file in the appropriate directory:
|
|
532
|
+
```typescript
|
|
533
|
+
// src/tools/search/new-feature.ts
|
|
534
|
+
import { z } from 'zod';
|
|
535
|
+
import { SearchClient } from '../../client/search-client.js';
|
|
536
|
+
|
|
537
|
+
export const NewFeatureSchema = z.object({
|
|
538
|
+
// Define parameters
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
export async function executeNewFeature(client: SearchClient, input: unknown) {
|
|
542
|
+
// Implementation
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export const newFeatureTool = {
|
|
546
|
+
name: 'sitecore_new_feature',
|
|
547
|
+
description: 'Description of the feature',
|
|
548
|
+
inputSchema: NewFeatureSchema,
|
|
549
|
+
};
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
2. Import and register in [src/index.ts](src/index.ts):
|
|
553
|
+
```typescript
|
|
554
|
+
import { newFeatureTool, executeNewFeature } from './tools/search/new-feature.js';
|
|
555
|
+
|
|
556
|
+
// Add to ListToolsRequestSchema handler
|
|
557
|
+
// Add case to CallToolRequestSchema handler
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
### Modifying API Clients
|
|
561
|
+
|
|
562
|
+
API clients are in [src/client/](src/client). Each client extends `BaseClient` which provides:
|
|
563
|
+
- HTTP methods (get, post, put, patch, delete)
|
|
564
|
+
- Error handling
|
|
565
|
+
- Request/response logging
|
|
566
|
+
- Retry logic
|
|
567
|
+
|
|
568
|
+
## License
|
|
569
|
+
|
|
570
|
+
MIT
|
|
571
|
+
|
|
572
|
+
## Contributing
|
|
573
|
+
|
|
574
|
+
Contributions are welcome! The modular structure makes it easy to:
|
|
575
|
+
- Add new tools for existing APIs
|
|
576
|
+
- Extend API clients with new methods
|
|
577
|
+
- Add support for additional Sitecore APIs
|
|
578
|
+
- Improve error handling and validation
|
|
579
|
+
|
|
580
|
+
## Publishing
|
|
581
|
+
|
|
582
|
+
See [PUBLISHING.md](PUBLISHING.md) for detailed instructions on publishing this package to npm.
|
|
583
|
+
|
|
584
|
+
Quick publish steps:
|
|
585
|
+
```bash
|
|
586
|
+
# Update version
|
|
587
|
+
npm version patch|minor|major
|
|
588
|
+
|
|
589
|
+
# Build
|
|
590
|
+
npm run build
|
|
591
|
+
|
|
592
|
+
# Publish (first time with scoped package)
|
|
593
|
+
npm publish --access public
|
|
594
|
+
|
|
595
|
+
# Subsequent publishes
|
|
596
|
+
npm publish
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
## Support
|
|
600
|
+
|
|
601
|
+
For Sitecore API documentation, visit:
|
|
602
|
+
- [Sitecore Search Documentation](https://doc.sitecore.com/search)
|
|
603
|
+
- [OpenAPI Specifications](./specs/)
|
|
604
|
+
|
|
605
|
+
For issues with this MCP server:
|
|
606
|
+
- [GitHub Issues](https://github.com/yourusername/mcp-sitecore-search-server/issues)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { Logger } from '../utils/logger.js';
|
|
3
|
+
import { AuthManager } from '../utils/auth-manager.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base HTTP client for all Sitecore API requests
|
|
6
|
+
* Provides common functionality: error handling, logging, retry logic, authentication
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseClient {
|
|
9
|
+
protected axios: AxiosInstance;
|
|
10
|
+
protected logger: Logger;
|
|
11
|
+
protected authManager?: AuthManager;
|
|
12
|
+
constructor(baseURL: string, context: string, authManager?: AuthManager);
|
|
13
|
+
/**
|
|
14
|
+
* Make a GET request
|
|
15
|
+
*/
|
|
16
|
+
protected get<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Make a POST request
|
|
19
|
+
*/
|
|
20
|
+
protected post<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Make a PUT request
|
|
23
|
+
*/
|
|
24
|
+
protected put<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
|
|
25
|
+
/**
|
|
26
|
+
* Make a PATCH request
|
|
27
|
+
*/
|
|
28
|
+
protected patch<T>(url: string, data?: unknown, config?: AxiosRequestConfig): Promise<T>;
|
|
29
|
+
/**
|
|
30
|
+
* Make a DELETE request
|
|
31
|
+
*/
|
|
32
|
+
protected delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=base-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-client.d.ts","sourceRoot":"","sources":["../../src/client/base-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAEhF,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD;;;GAGG;AACH,qBAAa,UAAU;IACrB,SAAS,CAAC,KAAK,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;gBAGlC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,WAAW;IAwD3B;;OAEG;cACa,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAS5E;;OAEG;cACa,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAS7F;;OAEG;cACa,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAS5F;;OAEG;cACa,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAS9F;;OAEG;cACa,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;CAQhF"}
|