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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
# MCP Server API Reference
> **⚠️ DEPRECATION NOTICE**
>
> This MCP server is **EXPERIMENTAL** and **NOT ACTIVELY MAINTAINED**.
>
> The author currently manages prompts through slash commands and meta-commands
> in the hexai agent system, making this MCP server redundant for its original
> purpose. This code is kept for potential future enhancements (possibly with
> different functionality beyond prompt management), but no guarantees are made
> about stability or continued support.
>
> **This documentation is preserved for reference only.**
The hexai-mcp-server implements the Model Context Protocol with prompt management extensions.
## Protocol Version
**Version**: `2025-06-18`
## Server Capabilities
The server advertises these capabilities during initialization:
```json
{
"capabilities": {
"prompts": {
"listChanged": false,
"mutable": true
}
}
}
```
- `listChanged`: Server does not currently emit notifications when prompts change
- `mutable`: **Server supports create/update/delete operations**
## Standard MCP Methods
### initialize
Establishes connection and negotiates capabilities.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": {
"name": "my-client",
"version": "1.0.0"
}
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2025-06-18",
"capabilities": {
"prompts": {
"listChanged": false,
"mutable": true
}
},
"serverInfo": {
"name": "hexai-mcp-server",
"version": "0.19.0"
}
}
}
```
### prompts/list
Lists all available prompts with pagination support.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "prompts/list",
"params": {
"cursor": ""
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"prompts": [
{
"name": "code_review",
"title": "Request Code Review",
"description": "Analyzes code quality, style, and suggests improvements",
"arguments": [
{
"name": "code",
"description": "The code to review",
"required": true
}
]
}
],
"nextCursor": ""
}
}
```
### prompts/get
Retrieves a specific prompt with argument rendering.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 3,
"method": "prompts/get",
"params": {
"name": "code_review",
"arguments": {
"code": "function hello() { console.log('world'); }"
}
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"description": "Analyzes code quality, style, and suggests improvements",
"messages": [
{
"role": "user",
"content": {
"type": "text",
"text": "Please review the following code for quality, style, and potential issues:\n\nfunction hello() { console.log('world'); }"
}
}
]
}
}
```
## Management Methods (Extension)
These methods are **hexai-mcp-server extensions** that allow prompt management through the MCP protocol.
### prompts/create
Creates a new custom prompt.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 4,
"method": "prompts/create",
"params": {
"name": "api_design",
"title": "Design REST API",
"description": "Creates RESTful API endpoint specification",
"arguments": [
{
"name": "resource",
"description": "Resource name (e.g., users, posts)",
"required": true
}
],
"messages": [
{
"role": "user",
"content": {
"type": "text",
"text": "Design a REST API for: {{resource}}"
}
}
],
"tags": ["api", "rest", "design"]
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"success": true,
"message": "Created prompt: api_design"
}
}
```
**Required Fields:**
- `name`: Unique identifier (alphanumeric + underscores)
- `title`: Display name
- `messages`: At least one message
**Optional Fields:**
- `description`: Human-readable description
- `arguments`: Template variables
- `tags`: Categorization tags
### prompts/update
Updates an existing custom prompt.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 5,
"method": "prompts/update",
"params": {
"name": "api_design",
"title": "Design RESTful API (Updated)",
"description": "Creates comprehensive RESTful API specification with best practices"
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"success": true,
"message": "Updated prompt: api_design"
}
}
```
**Required Fields:**
- `name`: Prompt identifier
**Optional Fields** (only provided fields are updated):
- `title`: New title
- `description`: New description
- `arguments`: New arguments (replaces entire list)
- `messages`: New messages (replaces entire list)
- `tags`: New tags (replaces entire list)
### prompts/delete
Deletes a custom prompt.
**Request:**
```json
{
"jsonrpc": "2.0",
"id": 6,
"method": "prompts/delete",
"params": {
"name": "old_prompt"
}
}
```
**Response:**
```json
{
"jsonrpc": "2.0",
"id": 6,
"result": {
"success": true,
"message": "Deleted prompt: old_prompt"
}
}
```
**Note**: Can only delete custom prompts from `user.jsonl`, not built-in prompts from `default.jsonl`.
## Error Responses
All methods return standard JSON-RPC 2.0 errors:
```json
{
"jsonrpc": "2.0",
"id": 7,
"error": {
"code": -32602,
"message": "Prompt name is required"
}
}
```
### Error Codes
| Code | Meaning | Example |
|------|---------|---------|
| -32700 | Parse error | Invalid JSON |
| -32600 | Invalid request | Malformed request structure |
| -32601 | Method not found | Unknown method |
| -32602 | Invalid params | Missing required field |
| -32603 | Internal error | Database/storage error |
## Template Syntax
Prompts support template variables using `{{variable}}` syntax:
```json
{
"text": "Review this {{language}} code:\n\n{{code}}"
}
```
When rendered with arguments `{"language": "Go", "code": "..."}`:
```
Review this Go code:
...
```
## Example: Full Workflow
```javascript
// 1. Initialize
send({
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2025-06-18",
capabilities: {},
clientInfo: { name: "my-client", version: "1.0" }
}
});
// 2. List prompts
send({
jsonrpc: "2.0",
id: 2,
method: "prompts/list"
});
// 3. Create custom prompt
send({
jsonrpc: "2.0",
id: 3,
method: "prompts/create",
params: {
name: "perf_analysis",
title: "Performance Analysis",
arguments: [{ name: "code", required: true }],
messages: [
{
role: "user",
content: { type: "text", text: "Analyze performance: {{code}}" }
}
],
tags: ["performance"]
}
});
// 4. Use the prompt
send({
jsonrpc: "2.0",
id: 4,
method: "prompts/get",
params: {
name: "perf_analysis",
arguments: { code: "for i := 0; i < n; i++ { ... }" }
}
});
// 5. Update prompt
send({
jsonrpc: "2.0",
id: 5,
method: "prompts/update",
params: {
name: "perf_analysis",
description: "Enhanced performance analysis with profiling suggestions"
}
});
// 6. Delete prompt
send({
jsonrpc: "2.0",
id: 6,
method: "prompts/delete",
params: { name: "perf_analysis" }
});
```
## Client Implementation Notes
### Capability Detection
Check for `mutable: true` in server capabilities:
```javascript
const initResult = await initialize();
const canManage = initResult.capabilities.prompts?.mutable === true;
if (canManage) {
// Show create/edit/delete UI
}
```
### Error Handling
Always check for errors in responses:
```javascript
const response = await request("prompts/create", params);
if (response.error) {
console.error(`Error ${response.error.code}: ${response.error.message}`);
return;
}
if (response.result.success) {
console.log(response.result.message);
}
```
### Immediate Effect
Changes take effect immediately:
- Create/update/delete operations modify `user.jsonl`
- Next `prompts/list` or `prompts/get` reflects changes
- No server restart required
### Built-in vs Custom
- **Built-in prompts**: Cannot be modified or deleted
- **Custom prompts**: Stored in `user.jsonl`, fully manageable
- Attempting to delete/update built-in prompts returns an error
## Testing with curl
```bash
# Initialize
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | hexai-mcp-server
# Create prompt
cat <<EOF | hexai-mcp-server
Content-Length: 300
{"jsonrpc":"2.0","id":2,"method":"prompts/create","params":{"name":"test","title":"Test","messages":[{"role":"user","content":{"type":"text","text":"Test"}}]}}
EOF
```
## See Also
- [MCP Setup Guide](mcp-setup.md)
- [Creating Custom Prompts](mcp-prompts.md)
- [Managing Prompts](mcp-managing-prompts.md)
- [MCP Specification](https://modelcontextprotocol.io/)
|