converse-mcp-server 2.29.2 → 3.0.1

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.
Files changed (42) hide show
  1. package/.env.example +6 -3
  2. package/README.md +96 -94
  3. package/docs/API.md +703 -1562
  4. package/docs/ARCHITECTURE.md +13 -11
  5. package/docs/EXAMPLES.md +241 -667
  6. package/docs/PROVIDERS.md +104 -79
  7. package/package.json +1 -1
  8. package/src/async/asyncJobStore.js +2 -2
  9. package/src/async/jobRunner.js +6 -1
  10. package/src/async/providerStreamNormalizer.js +59 -1
  11. package/src/config.js +4 -3
  12. package/src/prompts/helpPrompt.js +43 -61
  13. package/src/providers/anthropic.js +0 -31
  14. package/src/providers/claude.js +0 -14
  15. package/src/providers/codex.js +15 -21
  16. package/src/providers/copilot.js +36 -202
  17. package/src/providers/deepseek.js +73 -53
  18. package/src/providers/gemini-cli.js +0 -3
  19. package/src/providers/google.js +10 -27
  20. package/src/providers/interface.js +0 -3
  21. package/src/providers/mistral.js +169 -63
  22. package/src/providers/openai-compatible.js +113 -28
  23. package/src/providers/openai.js +14 -66
  24. package/src/providers/openrouter-discovery.js +308 -0
  25. package/src/providers/openrouter.js +452 -282
  26. package/src/providers/xai.js +298 -280
  27. package/src/services/summarizationService.js +4 -14
  28. package/src/systemPrompts.js +19 -2
  29. package/src/tools/cancelJob.js +7 -1
  30. package/src/tools/chat.js +957 -995
  31. package/src/tools/checkStatus.js +1 -0
  32. package/src/tools/index.js +2 -6
  33. package/src/tools/modes/parallel.js +488 -0
  34. package/src/tools/modes/roundtable.js +495 -0
  35. package/src/tools/modes/streamShared.js +31 -0
  36. package/src/utils/contextProcessor.js +1 -38
  37. package/src/utils/conversationExporter.js +6 -26
  38. package/src/utils/formatStatus.js +46 -19
  39. package/src/utils/modelRouting.js +207 -4
  40. package/src/providers/openrouter-endpoints-client.js +0 -220
  41. package/src/tools/consensus.js +0 -1813
  42. package/src/tools/conversation.js +0 -1233
package/docs/API.md CHANGED
@@ -1,1562 +1,703 @@
1
- # Converse MCP Server - API Reference
2
-
3
- ## Overview
4
-
5
- The Converse MCP Server provides five main tools through the Model Context Protocol (MCP):
6
-
7
- 1. **Chat Tool** - Single-provider conversational AI with context support and AI summarization
8
- 2. **Consensus Tool** - Multi-provider parallel execution with response aggregation and combined summaries
9
- 3. **Conversation Tool** - Turn-based multi-model round-table where models respond sequentially, each seeing the full running transcript
10
- 4. **Check Status Tool** - Monitor and retrieve results from asynchronous operations with intelligent summaries
11
- 5. **Cancel Job Tool** - Cancel running background operations
12
-
13
- All tools support both **synchronous** (immediate response) and **asynchronous** (background processing) execution modes. When AI summarization is enabled, tools automatically generate titles and summaries for better context understanding.
14
-
15
- ## Transport Protocols
16
-
17
- The server supports two transport modes:
18
-
19
- ### HTTP Transport (Default)
20
- - **Endpoint**: `http://localhost:3157/mcp`
21
- - **Protocol**: HTTP streaming with JSON-RPC 2.0
22
- - **Usage**: Best for development, debugging, and web integrations
23
- - **Features**: Health endpoints, CORS support, session management
24
-
25
- ### Stdio Transport (Legacy)
26
- - **Protocol**: Standard input/output with JSON-RPC 2.0
27
- - **Usage**: Traditional MCP client integrations
28
- - **Features**: Process-based communication, lower latency
29
-
30
- **Transport Selection:**
31
- ```bash
32
- # Default (HTTP)
33
- npm start
34
-
35
- # Explicit HTTP
36
- npm start -- --transport=http
37
-
38
- # Stdio transport
39
- npm start -- --transport=stdio
40
-
41
- # Environment variable
42
- MCP_TRANSPORT=stdio npm start
43
- ```
44
-
45
- ## Tool Schemas
46
-
47
- ### Chat Tool
48
-
49
- **Description**: General conversational AI with context and continuation support.
50
-
51
- #### Request Schema
52
-
53
- ```json
54
- {
55
- "type": "object",
56
- "properties": {
57
- "prompt": {
58
- "type": "string",
59
- "description": "Your question or topic with relevant context. Example: 'How should I structure the authentication module for this Express.js API?'"
60
- },
61
- "model": {
62
- "type": "string",
63
- "description": "AI model to use. Examples: 'auto' (recommended), 'gemini-2.5-flash', 'gpt-5', 'grok-4'. Default: 'auto'"
64
- },
65
- "files": {
66
- "type": "array",
67
- "items": {"type": "string"},
68
- "description": "File paths to include as context (absolute paths required). Example: ['/path/to/src/auth.js', '/path/to/config.json']"
69
- },
70
- "images": {
71
- "type": "array",
72
- "items": {"type": "string"},
73
- "description": "Image paths for visual context (absolute paths or base64). Example: ['/path/to/diagram.png', 'data:image/jpeg;base64,...']"
74
- },
75
- "continuation_id": {
76
- "type": "string",
77
- "description": "Continuation ID for persistent conversation. Example: 'chat_1703123456789_abc123'"
78
- },
79
- "temperature": {
80
- "type": "number",
81
- "minimum": 0.0,
82
- "maximum": 1.0,
83
- "default": 0.5,
84
- "description": "Response randomness (0.0-1.0). Examples: 0.2 (focused), 0.5 (balanced), 0.8 (creative)"
85
- },
86
- "reasoning_effort": {
87
- "type": "string",
88
- "enum": ["minimal", "low", "medium", "high", "max"],
89
- "default": "medium",
90
- "description": "Reasoning depth for thinking models. Examples: 'minimal' (fastest, few reasoning tokens), 'low' (light analysis), 'medium' (balanced), 'high' (complex analysis)"
91
- },
92
- "verbosity": {
93
- "type": "string",
94
- "enum": ["low", "medium", "high"],
95
- "default": "medium",
96
- "description": "Output verbosity for GPT-5 models. Examples: 'low' (concise answers), 'medium' (balanced), 'high' (thorough explanations)"
97
- },
98
- "use_websearch": {
99
- "type": "boolean",
100
- "default": false,
101
- "description": "Enable web search for current information. Example: true for framework docs, false for private code analysis"
102
- },
103
- "media_resolution": {
104
- "type": "string",
105
- "enum": ["MEDIA_RESOLUTION_LOW", "MEDIA_RESOLUTION_MEDIUM", "MEDIA_RESOLUTION_HIGH", "MEDIA_RESOLUTION_UNSPECIFIED"],
106
- "default": "MEDIA_RESOLUTION_HIGH",
107
- "description": "Control image/PDF/video processing quality (Gemini 3.0). Defaults to 'MEDIA_RESOLUTION_HIGH' for Gemini 3.0. Examples: 'MEDIA_RESOLUTION_LOW' (faster, less detail), 'MEDIA_RESOLUTION_MEDIUM' (balanced), 'MEDIA_RESOLUTION_HIGH' (maximum detail)"
108
- },
109
- "async": {
110
- "type": "boolean",
111
- "default": false,
112
- "description": "Execute in background mode. Returns continuation_id immediately for status monitoring. Example: true for long-running analysis"
113
- },
114
- "export": {
115
- "type": "boolean",
116
- "default": false,
117
- "description": "Export conversation to disk. Creates folder with continuation_id name containing numbered request/response files and metadata. Example: true to save for documentation"
118
- }
119
- },
120
- "required": ["prompt"]
121
- }
122
- ```
123
-
124
- #### Response Format
125
-
126
- **Synchronous Response (async=false):**
127
- ```json
128
- {
129
- "content": "AI response text",
130
- "continuation": {
131
- "id": "conv_d6a6a5ec-6900-4fd8-a4e0-1fa4f75dfc42",
132
- "provider": "openai",
133
- "model": "gpt-5-mini",
134
- "messageCount": 3
135
- },
136
- "metadata": {
137
- "model": "gpt-5-mini",
138
- "usage": {
139
- "input_tokens": 150,
140
- "output_tokens": 85,
141
- "total_tokens": 235
142
- },
143
- "response_time_ms": 1247,
144
- "provider": "openai"
145
- },
146
- "title": "Authentication Module Structure Guide", // When summarization enabled
147
- "final_summary": "Provided architectural recommendations for Express.js auth module with JWT tokens and role-based access control." // When summarization enabled
148
- }
149
- ```
150
-
151
- **Asynchronous Response (async=true):**
152
- ```json
153
- {
154
- "content": "⏳ PROCESSING | CHAT | conv_abc123def | 1/1 | Started: 2023-12-01 10:30:00 | openai/gpt-5",
155
- "continuation": {
156
- "id": "conv_abc123def",
157
- "status": "processing"
158
- },
159
- "async_execution": true
160
- }
161
- ```
162
-
163
- #### Example Usage
164
-
165
- **Basic query:**
166
- ```json
167
- {
168
- "prompt": "Review this authentication function for security issues",
169
- "model": "o3",
170
- "files": ["/project/src/auth.js", "/project/config/security.json"],
171
- "temperature": 0.2,
172
- "reasoning_effort": "high"
173
- }
174
- ```
175
-
176
- **With conversation export:**
177
- ```json
178
- {
179
- "prompt": "Help me design a scalable architecture for our system",
180
- "model": "gpt-5",
181
- "export": true,
182
- "continuation_id": "conv_architecture_design"
183
- }
184
- ```
185
-
186
- When export is enabled, the conversation will be saved to disk in the following structure:
187
- ```
188
- conv_architecture_design/
189
- ├── 1_request.txt # First user prompt
190
- ├── 1_response.txt # First AI response
191
- ├── 2_request.txt # Second user prompt (if continuing)
192
- ├── 2_response.txt # Second AI response
193
- └── metadata.json # Conversation metadata and settings
194
- ```
195
-
196
- ### Consensus Tool
197
-
198
- **Description**: Multi-provider parallel execution with cross-model feedback for gathering perspectives from multiple AI models.
199
-
200
- #### Request Schema
201
-
202
- ```json
203
- {
204
- "type": "object",
205
- "properties": {
206
- "prompt": {
207
- "type": "string",
208
- "description": "The problem or proposal to gather consensus on. Example: 'Should we use microservices or monolith architecture for our e-commerce platform?'"
209
- },
210
- "models": {
211
- "type": "array",
212
- "items": {"type": "string"},
213
- "minItems": 1,
214
- "description": "List of models to consult. Example: ['o3', 'gemini-2.5-flash', 'grok-4']"
215
- },
216
- "files": {
217
- "type": "array",
218
- "items": {"type": "string"},
219
- "description": "File paths for additional context. Example: ['/path/to/architecture.md', '/path/to/requirements.txt']"
220
- },
221
- "images": {
222
- "type": "array",
223
- "items": {"type": "string"},
224
- "description": "Image paths for visual context. Example: ['/path/to/architecture.png', '/path/to/user_flow.jpg']"
225
- },
226
- "continuation_id": {
227
- "type": "string",
228
- "description": "Thread continuation ID for multi-turn conversations. Example: 'consensus_1703123456789_xyz789'"
229
- },
230
- "enable_cross_feedback": {
231
- "type": "boolean",
232
- "default": true,
233
- "description": "Enable refinement phase where models see others' responses. Example: true (recommended), false (faster)"
234
- },
235
- "cross_feedback_prompt": {
236
- "type": "string",
237
- "description": "Custom prompt for refinement phase. Example: 'Focus on scalability trade-offs in your refinement'"
238
- },
239
- "temperature": {
240
- "type": "number",
241
- "minimum": 0.0,
242
- "maximum": 1.0,
243
- "default": 0.2,
244
- "description": "Response randomness. Examples: 0.1 (very focused), 0.2 (analytical), 0.5 (balanced)"
245
- },
246
- "reasoning_effort": {
247
- "type": "string",
248
- "enum": ["minimal", "low", "medium", "high", "max"],
249
- "default": "medium",
250
- "description": "Reasoning depth. Examples: 'medium' (balanced), 'high' (complex analysis), 'max' (thorough evaluation)"
251
- },
252
- "async": {
253
- "type": "boolean",
254
- "default": false,
255
- "description": "Execute in background mode with per-provider progress tracking. Returns continuation_id immediately for monitoring."
256
- },
257
- "export": {
258
- "type": "boolean",
259
- "default": false,
260
- "description": "Export conversation to disk. Creates folder with continuation_id name containing numbered request/response files and metadata. Example: true to save consensus results"
261
- }
262
- },
263
- "required": ["prompt", "models"]
264
- }
265
- ```
266
-
267
- #### Response Format
268
-
269
- **Synchronous Response (async=false):**
270
- ```json
271
- {
272
- "status": "consensus_complete",
273
- "models_consulted": 3,
274
- "successful_initial_responses": 3,
275
- "failed_responses": 0,
276
- "refined_responses": 3,
277
- "title": "Architecture Review Recommendations", // When summarization enabled
278
- "final_summary": "All models agree on microservices approach with event-driven architecture for scalability.", // When summarization enabled
279
- "phases": {
280
- "initial": [
281
- {
282
- "model": "o3",
283
- "status": "success",
284
- "response": "Initial analysis from O3...",
285
- "metadata": {
286
- "provider": "openai",
287
- "input_tokens": 200,
288
- "output_tokens": 150,
289
- "response_time": 2500
290
- }
291
- }
292
- ],
293
- "refined": [
294
- {
295
- "model": "o3",
296
- "status": "success",
297
- "initial_response": "Initial analysis...",
298
- "refined_response": "After considering other perspectives...",
299
- "metadata": {
300
- "total_response_time": 4800,
301
- "total_input_tokens": 450,
302
- "total_output_tokens": 320
303
- }
304
- }
305
- ],
306
- "failed": []
307
- },
308
- "continuation": {
309
- "id": "consensus_xyz789",
310
- "messageCount": 2
311
- },
312
- "settings": {
313
- "enable_cross_feedback": true,
314
- "temperature": 0.2,
315
- "models_requested": ["o3", "gemini-2.5-flash", "grok-4"]
316
- }
317
- }
318
- ```
319
-
320
- **Asynchronous Response (async=true):**
321
- ```json
322
- {
323
- "content": "⏳ PROCESSING | CONSENSUS | consensus_xyz789 | 0/3 | Started: 2023-12-01 10:30:00 | gpt-5,gemini-2.5-pro,grok-4",
324
- "continuation": {
325
- "id": "consensus_xyz789",
326
- "status": "processing"
327
- },
328
- "async_execution": true,
329
- "metadata": {
330
- "total_models": 3,
331
- "successful_models": 0,
332
- "models_list": "gpt-5,gemini-2.5-pro,grok-4"
333
- }
334
- }
335
- ```
336
-
337
- #### Example Usage
338
-
339
- ```json
340
- {
341
- "prompt": "What's the best database solution for a high-traffic social media platform?",
342
- "models": [
343
- {"model": "o3"},
344
- {"model": "gemini-2.5-pro"},
345
- {"model": "grok-4"}
346
- ],
347
- "files": ["/docs/requirements.md", "/docs/current_architecture.md"],
348
- "enable_cross_feedback": true,
349
- "temperature": 0.1,
350
- "reasoning_effort": "high"
351
- }
352
- ```
353
-
354
- ### Conversation Tool
355
-
356
- **Description**: Turn-based multi-model round-table. Unlike consensus (parallel, all models answer the same prompt), models here respond **sequentially in the order given**, and each model sees the full running transcript of every turn before it. One tool call runs exactly **one lap** (one turn per model). The caller drives more laps by passing back the returned `continuation_id`; every lap appends to one shared, accumulating transcript that all models see.
357
-
358
- #### Request Schema
359
-
360
- ```json
361
- {
362
- "type": "object",
363
- "properties": {
364
- "prompt": {
365
- "type": "string",
366
- "description": "The topic or question to open the round-table with. Example: 'Critique this caching strategy and propose improvements.'"
367
- },
368
- "models": {
369
- "type": "array",
370
- "items": {"type": "string"},
371
- "minItems": 1,
372
- "description": "Ordered list of models. ORDER MATTERS: models speak one after another in this exact order, each seeing the transcript of those before it. Example: ['codex', 'gemini', 'claude']"
373
- },
374
- "continuation_id": {
375
- "type": "string",
376
- "description": "Thread continuation ID for running more laps. Auto-generated in the first response; pass it back to run another lap where every model again sees the full accumulated transcript. You MAY change the models list on a resuming lap."
377
- },
378
- "turn_prompt": {
379
- "type": "string",
380
- "description": "Optional custom per-turn instruction appended to the round-table framing each model receives. Example: 'Focus on security implications in your turn.'"
381
- },
382
- "files": {
383
- "type": "array",
384
- "items": {"type": "string"},
385
- "description": "File paths shared with every participant in the lap. Supports line ranges: file.txt{10:50}."
386
- },
387
- "images": {
388
- "type": "array",
389
- "items": {"type": "string"},
390
- "description": "Image paths for visual context (absolute paths or base64)."
391
- },
392
- "temperature": {
393
- "type": "number",
394
- "minimum": 0.0,
395
- "maximum": 1.0,
396
- "default": 0.2,
397
- "description": "Response randomness. Examples: 0.1 (very focused), 0.2 (analytical), 0.5 (balanced)"
398
- },
399
- "reasoning_effort": {
400
- "type": "string",
401
- "enum": ["none", "minimal", "low", "medium", "high", "max"],
402
- "default": "medium",
403
- "description": "Reasoning depth for thinking models."
404
- },
405
- "use_websearch": {
406
- "type": "boolean",
407
- "default": false,
408
- "description": "Enable web search for current information (models that support it)."
409
- },
410
- "async": {
411
- "type": "boolean",
412
- "default": false,
413
- "description": "Execute the lap in background with per-turn progress tracking. Returns continuation_id immediately."
414
- },
415
- "export": {
416
- "type": "boolean",
417
- "default": false,
418
- "description": "Export conversation to disk. Creates folder with continuation_id name containing numbered request/response files and metadata."
419
- }
420
- },
421
- "required": ["prompt", "models"]
422
- }
423
- ```
424
-
425
- #### Response Format
426
-
427
- **Synchronous Response (async=false):**
428
-
429
- The response content begins with a status line and `continuation_id:` line (the status line is omitted in the test environment), followed by a JSON result object:
430
-
431
- ```
432
- ✅ COMPLETED | CONVERSATION | conv_abc123 | 3.2s elapsed | 2/2 turns | codex, gemini
433
- continuation_id: conv_abc123
434
-
435
- {
436
- "status": "conversation_complete",
437
- "models_consulted": 2,
438
- "successful_turns": 2,
439
- "failed_turns": 0,
440
- "turns": [
441
- {
442
- "model": "codex",
443
- "provider": "codex",
444
- "status": "success",
445
- "response": "Opening analysis of the caching strategy...",
446
- "position": 0
447
- },
448
- {
449
- "model": "gemini",
450
- "provider": "gemini-cli",
451
- "status": "success",
452
- "response": "Building on codex's point about TTLs, I'd add...",
453
- "position": 1
454
- }
455
- ],
456
- "continuation": {
457
- "id": "conv_abc123",
458
- "messageCount": 3
459
- },
460
- "settings": {
461
- "temperature": 0.2,
462
- "models_requested": ["codex", "gemini"]
463
- }
464
- }
465
- ```
466
-
467
- A turn that failed is recorded with `"status": "failed"` and an `"error"` note rather than aborting the lap; the response reports `successful_turns`/`models_consulted` accordingly and lists failed models in trailing failure details.
468
-
469
- **Asynchronous Response (async=true):**
470
- ```json
471
- {
472
- "content": "⏳ SUBMITTED | CONVERSATION | conv_xyz789 | 1/1 | Started: 01/12/2023 10:30:00 | \"Caching Round-Table\" | codex, gemini",
473
- "continuation": {
474
- "id": "conv_xyz789",
475
- "status": "processing"
476
- },
477
- "async_execution": true
478
- }
479
- ```
480
-
481
- When complete, `check_status` for the continuation_id renders the full lap transcript (the async result carries a top-level `content` field with the rendered transcript) plus the AI-generated title and final summary.
482
-
483
- #### Example Usage
484
-
485
- **Basic two-model lap:**
486
- ```json
487
- {
488
- "prompt": "Should we adopt event sourcing for the order service?",
489
- "models": ["codex", "gemini"]
490
- }
491
- ```
492
-
493
- **Continuing the round-table (another lap):**
494
- ```json
495
- {
496
- "prompt": "Now focus specifically on the migration path.",
497
- "models": ["codex", "gemini"],
498
- "continuation_id": "conv_abc123"
499
- }
500
- ```
501
-
502
- **Async round-table with a custom per-turn instruction:**
503
- ```json
504
- {
505
- "prompt": "Review this module design.",
506
- "models": ["codex", "gemini", "claude"],
507
- "files": ["/project/src/orders/design.md"],
508
- "turn_prompt": "Call out concrete failure modes you would test for.",
509
- "async": true
510
- }
511
- ```
512
-
513
- ## Supported Models
514
-
515
- ### OpenAI Models
516
-
517
- | Model | Context | Tokens | Features | Use Cases |
518
- |-------|---------|--------|----------|-----------|
519
- | `gpt-5.6-sol` (`gpt-5.6`, `gpt-5`, `sol`) | 1M | 128K | Flagship, default | Frontier reasoning, coding, agentic workflows |
520
- | `gpt-5.6-terra` (`terra`) | 400K | 128K | Lower cost | Strong performance at half the flagship price |
521
- | `gpt-5.6-luna` (`luna`) | 400K | 128K | Fastest | High-volume, latency-sensitive workloads |
522
- | `gpt-5.4` | 1M | 128K | Previous flagship | Complex reasoning, analysis |
523
- | `gpt-5.4-pro` | 1M | 272K | Pro tier | Extended capabilities (expensive) |
524
- | `gpt-5-mini` | 400K | 128K | Fast | Balanced performance/speed |
525
- | `gpt-5-nano` | 400K | 128K | Ultra-fast | Quick responses, simple queries |
526
- | `o3` | 200K | 100K | Reasoning | Logic, analysis, complex problems |
527
- | `o3-pro` | 200K | 100K | Extended reasoning | Deep analysis |
528
- | `o4-mini` | 200K | 100K | Fast reasoning | General purpose, rapid reasoning |
529
- | `gpt-4.1` | 1M | 32K | Large context | Long documents, analysis |
530
-
531
- ### Google/Gemini Models (API-based)
532
-
533
- | Model | Alias | Context | Tokens | Features | Use Cases |
534
- |-------|-------|---------|--------|----------|-----------|
535
- | `gemini-3-pro-preview` | `pro` | 1M | 64K | Thinking levels, enhanced reasoning | Complex problems, deep analysis |
536
- | `gemini-2.5-pro` | `pro 2.5` | 1M | 65K | Thinking mode | Deep reasoning, architecture |
537
- | `gemini-2.5-flash` | `flash` | 1M | 65K | Ultra-fast | Quick analysis, simple queries |
538
-
539
- **Note:** The short model name `gemini` (and `gemini:flash` / `gemini:pro`) routes to the **Antigravity CLI** (`agy`, OAuth-based). For Google API access, use specific model names like `gemini-2.5-pro` or `gemini-2.5-flash` (bare `gemini-pro`/`gemini-flash` also route to the Google API).
540
-
541
- ### X.AI/Grok Models
542
-
543
- | Model | Alias | Context | Tokens | Features | Use Cases |
544
- |-------|-------|---------|--------|----------|-----------|
545
- | `grok-4-0709` | `grok`, `grok-4` | 256K | 256K | Advanced | Latest capabilities |
546
- | `grok-code-fast-1` | `grok-code-fast` | 256K | 256K | Code optimization | Agentic coding |
547
-
548
- ### Anthropic Models
549
-
550
- | Model | Alias | Context | Tokens | Features | Use Cases |
551
- |-------|-------|---------|--------|----------|-----------|
552
- | `claude-fable-5` | `fable`, `fable-5` | 1M | 128K | Adaptive thinking, effort, images, caching, compaction | Most demanding reasoning, long-horizon agentic work |
553
- | `claude-opus-4-8` | `opus`, `opus-4.8` | 200K (1M beta) | 128K | Adaptive thinking, effort, images, caching, compaction | Complex reasoning, agentic coding |
554
- | `claude-opus-4-7` | `opus-4.7` | 200K (1M beta) | 128K | Adaptive thinking, effort, images, caching, compaction | Previous Opus generation |
555
- | `claude-opus-4-6` | `opus-4.6` | 200K (1M beta) | 128K | Adaptive thinking, effort, images, caching, compaction | Previous Opus generation |
556
- | `claude-opus-4-5-20251101` | `opus-4.5` | 200K | 64K | Extended thinking, effort (beta), images, caching | Legacy Opus |
557
- | `claude-opus-4-1-20250805` | `opus-4.1`, `opus-4` | 200K | 32K | Extended thinking, images, caching | Legacy Opus |
558
- | `claude-sonnet-4-6` | `sonnet`, `sonnet-4.6` | 200K (1M beta) | 64K | Adaptive thinking, effort, images, caching, compaction | Best speed/intelligence balance |
559
- | `claude-sonnet-4-5-20250929` | `sonnet-4.5` | 200K (1M beta) | 64K | Extended thinking, images, caching | Legacy Sonnet |
560
- | `claude-haiku-4-5-20251001` | `haiku`, `haiku-4.5` | 200K | 64K | Extended thinking, images, caching | Fast and intelligent |
561
-
562
- **Note:** Claude Fable 5 does not accept the `temperature` parameter (it is silently omitted). Models with adaptive thinking control thinking depth via `reasoning_effort`, which maps to Anthropic's `effort` parameter.
563
-
564
- **Prompt Caching (Always Enabled):**
565
- - System prompts are automatically cached for 1 hour using Anthropic's prompt caching
566
- - Reduces latency and costs for repeated requests with the same system prompt
567
- - Minimum 1024 tokens required for caching (2048 for Haiku models)
568
- - Cache information available in response metadata: `cache_creation_input_tokens` and `cache_read_input_tokens`
569
-
570
- ### DeepSeek Models
571
-
572
- | Model | Alias | Context | Tokens | Features | Use Cases |
573
- |-------|-------|---------|--------|----------|-----------|
574
- | `deepseek-v3` | `deepseek-chat`, `deepseek` | 128K | 64K | Latest model | General purpose AI |
575
- | `deepseek-coder-v2.5` | `deepseek-coder` | 128K | 16K | Code optimization | Programming tasks |
576
-
577
- ### Mistral Models
578
-
579
- | Model | Alias | Context | Tokens | Features | Use Cases |
580
- |-------|-------|---------|--------|----------|-----------|
581
- | `magistral-medium-2506` | `magistral`, `magistral-medium` | 40K | 8K | Reasoning model | Complex reasoning |
582
- | `magistral-small-2506` | `magistral-small` | 40K | 8K | Small reasoning | Fast reasoning |
583
- | `mistral-medium-2505` | `mistral-medium`, `mistral` | 128K | 32K | Multimodal | General + images |
584
-
585
- ### OpenRouter Models
586
-
587
- | Model | Alias | Context | Tokens | Features | Use Cases |
588
- |-------|-------|---------|--------|----------|-----------|
589
- | `kimi/k2` | `k2`, `kimi-k2` | 256K | 128K | Latest Kimi | Large context tasks |
590
- | `qwen/qwen-2.5-coder-32b-instruct` | `qwen-coder` | 32K | 32K | Code focus | Programming |
591
- | `qwen/qwq-32b-preview` | `qwen-thinking`, `qwq` | 32K | 32K | Reasoning | Step-by-step thinking |
592
-
593
- ### Codex Models
594
-
595
- **Codex** is an agentic coding assistant with direct filesystem access:
596
-
597
- - **Model**: `codex`
598
- - **Thread-based sessions**: Persistent conversation history via continuation_id
599
- - **Direct file access**: Reads files from working directory (paths relative to CLIENT_CWD)
600
- - **Response times**: 6-20 seconds typical (complex tasks may take minutes)
601
- - **Authentication**: Requires ChatGPT login OR `CODEX_API_KEY` environment variable
602
-
603
- ### Claude Agent SDK Models
604
-
605
- **Claude** is also available through the Claude Agent SDK, using Claude Code CLI authentication instead of an API key:
606
-
607
- - **Model**: `claude` (aliases: `claude-sdk`, `claude-code`) - defaults to Claude Fable 5
608
- - **Model selection**: `claude:fable` (Claude Fable 5) or `claude:opus` (Claude Opus 4.8); unknown `claude:`-prefixed names pass through to the SDK (e.g. `claude:claude-sonnet-4-6`)
609
- - **Authentication**: Claude Code login (`claude login`) - no `ANTHROPIC_API_KEY` needed
610
- - **Direct file access**: Reads files from working directory
611
- - **Note**: `temperature`, `use_websearch`, and `reasoning_effort` are managed by the SDK (ignored if specified)
612
-
613
- ### Gemini Models via Antigravity CLI (OAuth-based)
614
-
615
- The **Antigravity CLI** (`agy`) provides subscription-based access to Gemini models through Google OAuth:
616
-
617
- - **Models** (text-only): `gemini` (= `gemini:pro`, Gemini 3.1 Pro), `gemini:flash` (Gemini 3.5 Flash)
618
- - **Authentication**: Google OAuth via `agy` (requires one-time interactive login)
619
- - **Setup**: Install the Antigravity CLI and run `agy` once to log in
620
- - **Billing**: Uses your Antigravity subscription/compute allowance instead of API credits
621
- - **Detection**: The provider locates the `agy` binary on PATH or at the platform install location (no credentials file)
622
- - **Reasoning effort**: `low`/`medium`/`high`/`max` select the model variant (e.g. Flash Low/Medium/High; Pro Low/High)
623
- - **Context**: 1M tokens
624
- - **Note**: One-shot responses (no token-level streaming); ~7s minimum per call
625
-
626
- > Replaces the previous `@google/gemini-cli` integration, whose OAuth access Google sunsets on 2026-06-18.
627
-
628
- **Authentication Setup:**
629
- ```bash
630
- # Install the Antigravity CLI (agy)
631
- # Windows (PowerShell):
632
- irm https://antigravity.google/cli/install.ps1 | iex
633
- # macOS/Linux:
634
- curl -fsSL https://antigravity.google/cli/install.sh | bash
635
-
636
- # Run interactive login (one-time) also establishes workspace trust
637
- agy
638
- ```
639
-
640
- **Usage Example:**
641
- ```json
642
- {
643
- "name": "chat",
644
- "arguments": {
645
- "prompt": "Explain the event loop in JavaScript",
646
- "model": "gemini"
647
- }
648
- }
649
- ```
650
-
651
- **Codex-Specific Behavior:**
652
- - `continuation_id` - Required for thread continuation (maintains full conversation history)
653
- - `files` parameter - Files accessed directly from working directory, not passed as message content
654
- - `temperature`, `use_websearch` - Not supported by Codex (ignored if specified)
655
- - Responses significantly longer than API-based providers
656
-
657
- **Configuration (see [Codex Configuration](#codex-configuration) section):**
658
- - `CODEX_SANDBOX_MODE` - Filesystem access control
659
- - `CODEX_SKIP_GIT_CHECK` - Git repository requirement
660
- - `CODEX_APPROVAL_POLICY` - Command approval behavior
661
-
662
- ### Model Selection
663
-
664
- Use `"auto"` for automatic selection or specify exact models:
665
-
666
- ```json
667
- // Automatic selection (recommended)
668
- {"model": "auto"}
669
-
670
- // Specific models
671
- {"model": "gemini-2.5-flash"}
672
- {"model": "o3"}
673
- {"model": "grok-4-0709"}
674
-
675
- // Using aliases
676
- {"model": "flash"} // -> gemini-2.5-flash
677
- {"model": "pro"} // -> gemini-2.5-pro
678
- {"model": "grok"} // -> grok-4-0709
679
- {"model": "grok-4"} // -> grok-4-0709
680
- {"model": "fable"} // -> claude-fable-5 (Anthropic API)
681
- {"model": "opus"} // -> claude-opus-4-8 (Anthropic API)
682
-
683
- // SDK providers (subscription-based)
684
- {"model": "claude"} // -> Claude Agent SDK (Claude Fable 5)
685
- {"model": "claude:opus"} // -> Claude Agent SDK (Claude Opus 4.8)
686
- {"model": "copilot:codex"} // -> GitHub Copilot SDK (gpt-5.3-codex)
687
- ```
688
-
689
- ## Configuration
690
-
691
- ### AI Summarization
692
-
693
- Configure intelligent title and summary generation for better context understanding:
694
-
695
- ```bash
696
- # Environment variables
697
- ENABLE_RESPONSE_SUMMARIZATION=true # Enable AI-powered summarization (default: false)
698
- SUMMARIZATION_MODEL=gpt-5-nano # Model for summarization (default: gpt-5-nano)
699
- ```
700
-
701
- **When Enabled:**
702
- - Automatic title generation (up to 60 chars) for each request
703
- - Status check returns an up-to-date summary of the progress based on the partially streamed response
704
- - Final summaries (1-2 sentences) for completed responses
705
- - Enhanced check_status display with titles and summaries
706
- - Persistent storage of summaries with async jobs
707
-
708
- **Implementation Details:**
709
- - Uses fast models (gpt-5-nano, gemini-2.5-flash) for minimal latency
710
- - Temperature set to 0.3 for consistent, focused summaries
711
- - Graceful fallback to text snippets when disabled or on errors
712
- - Non-blocking - summarization failures don't affect main flow
713
-
714
- ### Codex Configuration
715
-
716
- Control Codex behavior through environment variables:
717
-
718
- **CODEX_SANDBOX_MODE** - Filesystem access control:
719
- - `read-only` (default): Can read files but not modify
720
- - `workspace-write`: Can modify files in workspace only
721
- - `danger-full-access`: Full filesystem access (use in containers only)
722
-
723
- **CODEX_SKIP_GIT_CHECK** - Git repository requirement:
724
- - `true` (default): Works in any directory
725
- - `false`: Requires working directory to be a Git repository
726
-
727
- **CODEX_APPROVAL_POLICY** - Command approval behavior:
728
- - `never` (default): Never prompt for approval (recommended for servers)
729
- - `untrusted`: Prompt for untrusted commands
730
- - `on-failure`: Prompt when commands fail
731
- - `on-request`: Let model decide (may hang in headless mode)
732
-
733
- **Authentication:**
734
- - Requires ChatGPT login (system-wide, persists across restarts)
735
- - Alternative: Set `CODEX_API_KEY` environment variable for headless deployments
736
-
737
- **Example Configuration (.env file):**
738
- ```bash
739
- # Codex authentication (optional if ChatGPT login available)
740
- CODEX_API_KEY=your_codex_api_key_here
741
-
742
- # Codex behavior
743
- CODEX_SANDBOX_MODE=read-only # Default: read-only
744
- CODEX_SKIP_GIT_CHECK=true # Default: true
745
- CODEX_APPROVAL_POLICY=never # Default: never
746
- ```
747
-
748
- ## Context Processing
749
-
750
- ### File Support
751
-
752
- **Supported Text Formats:**
753
- - `.txt`, `.md`, `.js`, `.ts`, `.json`, `.yaml`, `.yml`
754
- - `.py`, `.java`, `.c`, `.cpp`, `.h`, `.css`, `.html`
755
- - `.xml`, `.csv`, `.sql`, `.sh`, `.bat`, `.log`
756
-
757
- **Supported Image Formats:**
758
- - `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.bmp`
759
-
760
- **Size Limits:**
761
- - Text files: 1MB default
762
- - Image files: 10MB default
763
-
764
- ### File Processing
765
-
766
- ```json
767
- {
768
- "files": [
769
- "/absolute/path/to/file.js",
770
- "./relative/path/to/file.md"
771
- ]
772
- }
773
- ```
774
-
775
- **Response includes:**
776
- - File content with line numbers
777
- - Metadata (size, last modified)
778
- - Error handling for inaccessible files
779
-
780
- ### Image Processing
781
-
782
- ```json
783
- {
784
- "images": [
785
- "/path/to/diagram.png",
786
- "data:image/jpeg;base64,/9j/4AAQ..."
787
- ]
788
- }
789
- ```
790
-
791
- **Features:**
792
- - Base64 encoding for AI processing
793
- - MIME type detection
794
- - Size validation
795
- - Security path checking
796
-
797
- ## Continuation System
798
-
799
- ### Creating Conversations
800
-
801
- First request creates a continuation automatically:
802
-
803
- ```json
804
- {
805
- "prompt": "Start a conversation about architecture",
806
- "model": "auto"
807
- }
808
- ```
809
-
810
- Response includes continuation ID:
811
-
812
- ```json
813
- {
814
- "content": "Let's discuss architecture...",
815
- "continuation": {
816
- "id": "conv_abc123",
817
- "provider": "openai",
818
- "model": "gpt-5-mini",
819
- "messageCount": 2
820
- }
821
- }
822
- ```
823
-
824
- ### Continuing Conversations
825
-
826
- Use the continuation ID in subsequent requests:
827
-
828
- ```json
829
- {
830
- "prompt": "What about microservices?",
831
- "continuation_id": "conv_abc123"
832
- }
833
- ```
834
-
835
- **Features:**
836
- - Persistent conversation history
837
- - Provider and model consistency
838
- - Message count tracking
839
- - Automatic expiration
840
-
841
- ### ⚠️ Known Issues
842
-
843
- **Continuation ID Missing (Critical):**
844
- ```json
845
- // Some responses may not include continuation metadata
846
- {
847
- "content": "Response without continuation...",
848
- // Missing: continuation field
849
- }
850
- ```
851
-
852
- **Workaround:** Use single-turn interactions until fixed. Track conversation manually if needed.
853
-
854
- **Status:** Implementation gap identified in integration testing. High priority fix planned.
855
-
856
- ## Error Handling
857
-
858
- ### Common Error Responses
859
-
860
- **Missing API Key:**
861
- ```json
862
- {
863
- "error": "Provider not available. Check API key configuration.",
864
- "code": "PROVIDER_UNAVAILABLE",
865
- "provider": "openai"
866
- }
867
- ```
868
-
869
- **Invalid Model:**
870
- ```json
871
- {
872
- "error": "Model not found: invalid-model",
873
- "code": "MODEL_NOT_FOUND",
874
- "provider": "openai"
875
- }
876
- ```
877
-
878
- **Rate Limiting:**
879
- ```json
880
- {
881
- "error": "OpenAI rate limit exceeded",
882
- "code": "RATE_LIMIT_EXCEEDED",
883
- "provider": "openai",
884
- "retry_after": 60
885
- }
886
- ```
887
-
888
- **Context Too Large:**
889
- ```json
890
- {
891
- "error": "Context length exceeded for model",
892
- "code": "CONTEXT_LENGTH_EXCEEDED",
893
- "max_tokens": 128000,
894
- "provided_tokens": 150000
895
- }
896
- ```
897
-
898
- ## Rate Limits & Quotas
899
-
900
- ### Provider Limits
901
-
902
- **OpenAI:**
903
- - Rate limits vary by model and tier
904
- - Automatic retry with exponential backoff
905
- - Error codes: `rate_limit_error`, `insufficient_quota`
906
-
907
- **Google:**
908
- - Free tier: 50 requests/day
909
- - Paid: Based on quota settings
910
- - Automatic retry for temporary failures
911
-
912
- **X.AI:**
913
- - Based on account tier
914
- - Higher limits for paid accounts
915
- - Standard HTTP 429 handling
916
-
917
- ### Server Limits
918
-
919
- **Default Limits:**
920
- - Max output tokens: 25,000 (configurable to 200,000)
921
- - Request timeout: 5 minutes
922
- - Concurrent requests: Unlimited
923
-
924
- **Configuration:**
925
- ```bash
926
- MAX_MCP_OUTPUT_TOKENS=200000
927
- REQUEST_TIMEOUT_MS=300000
928
- ```
929
-
930
- ## Authentication
931
-
932
- ### API Key Management
933
-
934
- **Environment Variables:**
935
- ```bash
936
- OPENAI_API_KEY=sk-proj-...
937
- GOOGLE_API_KEY=AIzaSy...
938
- XAI_API_KEY=xai-...
939
- ```
940
-
941
- **MCP Client Configuration:**
942
- ```json
943
- {
944
- "env": {
945
- "OPENAI_API_KEY": "sk-proj-...",
946
- "GOOGLE_API_KEY": "AIzaSy...",
947
- "XAI_API_KEY": "xai-..."
948
- }
949
- }
950
- ```
951
-
952
- ### Security
953
-
954
- **Features:**
955
- - API keys never logged or exposed
956
- - Path traversal protection for files
957
- - File access limited to allowed directories
958
- - Input validation on all parameters
959
-
960
- ## Performance
961
-
962
- ### Response Times
963
-
964
- **Typical Performance:**
965
- - Simple chat: 500-2000ms
966
- - Complex reasoning: 2-10 seconds
967
- - Consensus (3 models): 3-15 seconds
968
- - File processing: <100ms per file
969
-
970
- **Optimization:**
971
- - Parallel consensus execution
972
- - Efficient context processing
973
- - Connection pooling
974
- - Response caching for repeated requests
975
-
976
- ### Monitoring
977
-
978
- **Metrics Available:**
979
- - Response times per provider
980
- - Token usage statistics
981
- - Error rates and types
982
- - Request concurrency
983
-
984
- **Logging:**
985
- ```bash
986
- LOG_LEVEL=debug # Detailed operation logs
987
- LOG_LEVEL=info # Standard operation logs
988
- LOG_LEVEL=error # Errors only
989
- ```
990
-
991
- ## Examples
992
-
993
- ### Basic Chat
994
-
995
- ```json
996
- {
997
- "tool": "chat",
998
- "arguments": {
999
- "prompt": "Explain the benefits of TypeScript over JavaScript",
1000
- "model": "gemini-2.5-flash",
1001
- "temperature": 0.3
1002
- }
1003
- }
1004
- ```
1005
-
1006
- ### Chat with Context
1007
-
1008
- ```json
1009
- {
1010
- "tool": "chat",
1011
- "arguments": {
1012
- "prompt": "Review this code for potential security vulnerabilities",
1013
- "model": "o3",
1014
- "files": ["/project/src/auth.js", "/project/src/middleware.js"],
1015
- "reasoning_effort": "high",
1016
- "temperature": 0.1
1017
- }
1018
- }
1019
- ```
1020
-
1021
- ### Simple Consensus
1022
-
1023
- ```json
1024
- {
1025
- "tool": "consensus",
1026
- "arguments": {
1027
- "prompt": "What's the best approach for implementing real-time notifications?",
1028
- "models": [
1029
- {"model": "o3"},
1030
- {"model": "flash"},
1031
- {"model": "grok"}
1032
- ],
1033
- "enable_cross_feedback": false,
1034
- "temperature": 0.2
1035
- }
1036
- }
1037
- ```
1038
-
1039
- ### Advanced Consensus
1040
-
1041
- ```json
1042
- {
1043
- "tool": "consensus",
1044
- "arguments": {
1045
- "prompt": "Design a scalable architecture for a video streaming platform",
1046
- "models": [
1047
- {"model": "o3"},
1048
- {"model": "gemini-2.5-pro"},
1049
- {"model": "grok-4"}
1050
- ],
1051
- "files": [
1052
- "/docs/requirements.md",
1053
- "/docs/current_architecture.md",
1054
- "/docs/performance_goals.md"
1055
- ],
1056
- "images": ["/diagrams/current_system.png"],
1057
- "enable_cross_feedback": true,
1058
- "cross_feedback_prompt": "Focus on scalability and cost optimization in your refinement",
1059
- "temperature": 0.15,
1060
- "reasoning_effort": "max"
1061
- }
1062
- }
1063
- ```
1064
-
1065
- ## Troubleshooting
1066
-
1067
- ### Debug Mode
1068
-
1069
- Enable detailed logging:
1070
-
1071
- ```bash
1072
- LOG_LEVEL=debug npx converse-mcp-server
1073
- ```
1074
-
1075
- ### Test API Keys
1076
-
1077
- ```bash
1078
- # Test OpenAI
1079
- curl -H "Authorization: Bearer $OPENAI_API_KEY" https://api.openai.com/v1/models
1080
-
1081
- # Test Google (replace YOUR_KEY)
1082
- curl "https://generativelanguage.googleapis.com/v1beta/models?key=YOUR_KEY"
1083
-
1084
- # Test X.AI
1085
- curl -H "Authorization: Bearer $XAI_API_KEY" https://api.x.ai/v1/models
1086
- ```
1087
-
1088
- ### Common Issues
1089
-
1090
- **"No providers available":**
1091
- - Check API key environment variables
1092
- - Verify API key format and validity
1093
- - Ensure at least one provider is configured
1094
-
1095
- **"Context length exceeded":**
1096
- - Reduce file content or prompt length
1097
- - Use shorter conversation history
1098
- - Switch to model with larger context window
1099
-
1100
- **Slow responses:**
1101
- - Check network connectivity
1102
- - Verify API service status
1103
- - Consider using faster models (flash, mini variants)
1104
-
1105
- ### 🔍 Integration Test Results & Known Issues
1106
-
1107
- **Provider-Specific Issues:**
1108
-
1109
- **Google Provider:**
1110
- ```json
1111
- {
1112
- "error": "genAI.getGenerativeModel is not a function",
1113
- "status": "connected_with_issues",
1114
- "workaround": "Provider handles gracefully, requests still processed"
1115
- }
1116
- ```
1117
-
1118
- **XAI Provider:**
1119
- ```json
1120
- {
1121
- "error": "grok-beta does not exist or your team does not have access",
1122
- "status": "api_key_limitations",
1123
- "workaround": "Try different model names or contact XAI support"
1124
- }
1125
- ```
1126
-
1127
- **Input Validation:**
1128
- ```json
1129
- {
1130
- "issue": "Missing required parameters may not be rejected",
1131
- "impact": "Some invalid requests may be processed",
1132
- "workaround": "Always provide required parameters like 'prompt'"
1133
- }
1134
- ```
1135
-
1136
- **Performance Benchmarks (From Integration Testing):**
1137
- - **Chat Tool**: 581ms average (OpenAI), excellent performance
1138
- - **Consensus Tool**: 496ms parallel execution (3 providers), excellent
1139
- - **File Processing**: 1779ms for analysis, good performance
1140
- - **Auto Selection**: 1900ms, acceptable for complex selection
1141
- - **Success Rate**: 75% (6/8 tests passing), core functionality working
1142
-
1143
- **Validated Functionality:**
1144
- - ✅ Real API connectivity to all three providers
1145
- - ✅ Chat tool with actual AI responses
1146
- - ✅ Consensus tool with parallel execution
1147
- - ✅ File context processing and analysis
1148
- - ✅ HTTP transport for MCP protocol
1149
- - ✅ Automatic provider selection
1150
- - ✅ Graceful error handling for provider issues
1151
-
1152
- ## 🔧 Extension Guide
1153
-
1154
- ### Adding New Providers
1155
-
1156
- Create a new provider by implementing the standard interface:
1157
-
1158
- ```javascript
1159
- // src/providers/newprovider.js
1160
- export async function invoke(messages, options = {}) {
1161
- // Validate API key availability
1162
- if (!process.env.NEWPROVIDER_API_KEY) {
1163
- throw new Error('NEWPROVIDER_API_KEY not configured');
1164
- }
1165
-
1166
- try {
1167
- // Implement API call logic
1168
- const response = await apiCall(messages, options);
1169
-
1170
- return {
1171
- content: response.text,
1172
- stop_reason: response.stop_reason || 'stop',
1173
- rawResponse: response
1174
- };
1175
- } catch (error) {
1176
- throw new Error(`New Provider error: ${error.message}`);
1177
- }
1178
- }
1179
-
1180
- export function isAvailable() {
1181
- return Boolean(process.env.NEWPROVIDER_API_KEY);
1182
- }
1183
-
1184
- export const supportedModels = ['model-1', 'model-2'];
1185
- export const name = 'newprovider';
1186
- ```
1187
-
1188
- **Registration:**
1189
- Add to `src/providers/index.js`:
1190
- ```javascript
1191
- import * as newprovider from './newprovider.js';
1192
-
1193
- export const providers = {
1194
- // ... existing providers
1195
- newprovider: newprovider
1196
- };
1197
- ```
1198
-
1199
- ### Adding New Tools
1200
-
1201
- Create a new tool following the MCP tool pattern:
1202
-
1203
- ```javascript
1204
- // src/tools/newtool.js
1205
- import { createToolResponse, createToolError } from './index.js';
1206
-
1207
- export async function newTool(args, dependencies) {
1208
- const { config, providers, continuationStore } = dependencies;
1209
-
1210
- try {
1211
- // Validate required arguments
1212
- if (!args.requiredParam) {
1213
- return createToolError('requiredParam is required');
1214
- }
1215
-
1216
- // Implement tool logic
1217
- const result = await processToolLogic(args, dependencies);
1218
-
1219
- return createToolResponse(result);
1220
- } catch (error) {
1221
- return createToolError(`Tool execution failed: ${error.message}`);
1222
- }
1223
- }
1224
-
1225
- // Tool definition for MCP registration
1226
- export const newToolDefinition = {
1227
- name: 'newtool',
1228
- description: 'Description of what the new tool does',
1229
- inputSchema: {
1230
- type: 'object',
1231
- properties: {
1232
- requiredParam: {
1233
- type: 'string',
1234
- description: 'Description of required parameter'
1235
- },
1236
- optionalParam: {
1237
- type: 'boolean',
1238
- default: false,
1239
- description: 'Description of optional parameter'
1240
- }
1241
- },
1242
- required: ['requiredParam']
1243
- }
1244
- };
1245
- ```
1246
-
1247
- **Registration:**
1248
- Add to `src/tools/index.js`:
1249
- ```javascript
1250
- import { newTool, newToolDefinition } from './newtool.js';
1251
-
1252
- export const tools = {
1253
- // ... existing tools
1254
- newtool: newTool
1255
- };
1256
-
1257
- export const toolDefinitions = {
1258
- // ... existing definitions
1259
- newtool: newToolDefinition
1260
- };
1261
- ```
1262
-
1263
- ### Configuration Extensions
1264
-
1265
- Add new configuration options:
1266
-
1267
- ```javascript
1268
- // src/config.js
1269
- export const config = {
1270
- // ... existing config
1271
-
1272
- newFeature: {
1273
- enabled: process.env.NEW_FEATURE_ENABLED === 'true',
1274
- timeout: parseInt(process.env.NEW_FEATURE_TIMEOUT) || 30000,
1275
- customOption: process.env.NEW_FEATURE_OPTION || 'default'
1276
- }
1277
- };
1278
- ```
1279
-
1280
- ### Testing Extensions
1281
-
1282
- Create tests for new components:
1283
-
1284
- ```javascript
1285
- // tests/providers/newprovider.test.js
1286
- import { describe, it, expect } from 'vitest';
1287
- import * as newProvider from '../../src/providers/newprovider.js';
1288
-
1289
- describe('New Provider', () => {
1290
- it('should implement required interface', () => {
1291
- expect(newProvider.invoke).toBeDefined();
1292
- expect(newProvider.isAvailable).toBeDefined();
1293
- expect(newProvider.name).toBe('newprovider');
1294
- });
1295
-
1296
- it('should handle API calls correctly', async () => {
1297
- // Test implementation
1298
- });
1299
- });
1300
- ```
1301
-
1302
- ### Check Status Tool
1303
-
1304
- **Description**: Monitor progress and retrieve results from asynchronous operations.
1305
-
1306
- #### Request Schema
1307
-
1308
- ```json
1309
- {
1310
- "type": "object",
1311
- "properties": {
1312
- "continuation_id": {
1313
- "type": "string",
1314
- "description": "Optional job continuation ID to query. If not provided, returns the 10 most recent jobs."
1315
- },
1316
- "full_history": {
1317
- "type": "boolean",
1318
- "default": false,
1319
- "description": "When used with continuation_id, returns the full conversation history for that continuation ID."
1320
- }
1321
- },
1322
- "additionalProperties": false
1323
- }
1324
- ```
1325
-
1326
- #### Response Format
1327
-
1328
- **Status Check Response:**
1329
- ```json
1330
- {
1331
- "content": {
1332
- "id": "conv_abc123def",
1333
- "status": "completed",
1334
- "tool": "chat",
1335
- "progress": {
1336
- "completed": 1,
1337
- "total": 1,
1338
- "percentage": 100
1339
- },
1340
- "result": {
1341
- "content": "Final AI response...",
1342
- "metadata": {
1343
- "provider": "openai",
1344
- "model": "gpt-5",
1345
- "usage": {
1346
- "input_tokens": 150,
1347
- "output_tokens": 85
1348
- }
1349
- }
1350
- },
1351
- "elapsed_seconds": 4.2,
1352
- "completed_at": "2023-12-01T10:30:04.200Z"
1353
- }
1354
- }
1355
- ```
1356
-
1357
- **Recent Jobs List Response:**
1358
- ```json
1359
- {
1360
- "content": {
1361
- "jobs": [
1362
- {
1363
- "id": "conv_abc123def",
1364
- "status": "completed",
1365
- "tool": "chat",
1366
- "elapsed_seconds": 4.2,
1367
- "completed_at": "2023-12-01T10:30:04.200Z"
1368
- },
1369
- {
1370
- "id": "consensus_xyz789",
1371
- "status": "processing",
1372
- "tool": "consensus",
1373
- "progress": {
1374
- "completed": 2,
1375
- "total": 3,
1376
- "percentage": 67
1377
- },
1378
- "elapsed_seconds": 8.5
1379
- }
1380
- ]
1381
- }
1382
- }
1383
- ```
1384
-
1385
- #### Example Usage
1386
-
1387
- ```json
1388
- // Check specific job
1389
- {
1390
- "continuation_id": "conv_abc123def"
1391
- }
1392
-
1393
- // List recent jobs
1394
- {}
1395
-
1396
- // Get full history for completed job
1397
- {
1398
- "continuation_id": "conv_abc123def",
1399
- "full_history": true
1400
- }
1401
- ```
1402
-
1403
- ### Cancel Job Tool
1404
-
1405
- **Description**: Cancel running asynchronous operations when needed.
1406
-
1407
- #### Request Schema
1408
-
1409
- ```json
1410
- {
1411
- "type": "object",
1412
- "properties": {
1413
- "continuation_id": {
1414
- "type": "string",
1415
- "description": "The continuation_id of the job to cancel"
1416
- }
1417
- },
1418
- "required": ["continuation_id"],
1419
- "additionalProperties": false
1420
- }
1421
- ```
1422
-
1423
- #### Response Format
1424
-
1425
- **Successful Cancellation:**
1426
- ```json
1427
- {
1428
- "content": {
1429
- "status": "cancelled",
1430
- "message": "Job conv_abc123def cancelled successfully",
1431
- "job_id": "conv_abc123def",
1432
- "elapsed_seconds": 2.1,
1433
- "cancelled_at": "2023-12-01T10:30:02.100Z"
1434
- }
1435
- }
1436
- ```
1437
-
1438
- **Already Completed:**
1439
- ```json
1440
- {
1441
- "content": {
1442
- "status": "completed",
1443
- "message": "Job conv_abc123def has already completed and cannot be cancelled",
1444
- "job_id": "conv_abc123def"
1445
- }
1446
- }
1447
- ```
1448
-
1449
- #### Example Usage
1450
-
1451
- ```json
1452
- {
1453
- "continuation_id": "conv_abc123def"
1454
- }
1455
- ```
1456
-
1457
- ## Asynchronous Execution
1458
-
1459
- ### Overview
1460
-
1461
- The Chat, Consensus, and Conversation tools support asynchronous execution mode for long-running operations. When `async: true` is specified:
1462
-
1463
- 1. **Immediate Response**: Returns a `continuation_id` instantly
1464
- 2. **Background Processing**: Job runs in the background with streaming support
1465
- 3. **Status Monitoring**: Use `check_status` tool to monitor progress
1466
- 4. **Result Retrieval**: Full results available when job completes
1467
- 5. **Cancellation**: Use `cancel_job` tool to stop running operations
1468
-
1469
- ### Async Workflow
1470
-
1471
- ```mermaid
1472
- sequenceDiagram
1473
- participant Client
1474
- participant Server
1475
- participant Provider
1476
-
1477
- Client->>Server: chat(prompt, async=true)
1478
- Server-->>Client: continuation_id (immediate)
1479
-
1480
- Server->>Provider: Background execution
1481
- Provider-->>Server: Streaming response
1482
-
1483
- loop Status Checking
1484
- Client->>Server: check_status(continuation_id)
1485
- Server-->>Client: Progress update
1486
- end
1487
-
1488
- Provider->>Server: Final response
1489
- Server->>Server: Cache result
1490
-
1491
- Client->>Server: check_status(continuation_id)
1492
- Server-->>Client: Complete result
1493
- ```
1494
-
1495
- ### Status Types
1496
-
1497
- | Status | Description | Actions Available |
1498
- |--------|-------------|------------------|
1499
- | `processing` | Job is running | Cancel, Check Status |
1500
- | `completed` | Job finished successfully | Get Results |
1501
- | `failed` | Job encountered an error | Check Error Details |
1502
- | `cancelled` | Job was cancelled by user | None |
1503
- | `completed_with_errors` | Partial success (consensus only) | Get Partial Results |
1504
-
1505
- ### Caching System
1506
-
1507
- **Memory Cache (24 hours):**
1508
- - Active jobs and recent completions
1509
- - Fast lookup for status checks
1510
- - Automatic cleanup
1511
-
1512
- **Disk Cache (3 days):**
1513
- - Long-term result storage
1514
- - Survives server restarts
1515
- - Automatic cleanup of old results
1516
-
1517
- ### Performance Considerations
1518
-
1519
- **Async Benefits:**
1520
- - Non-blocking client operations
1521
- - Better resource utilization
1522
- - Parallel processing for consensus
1523
- - Graceful handling of long operations
1524
-
1525
- **When to Use Async:**
1526
- - Long analysis tasks (>30 seconds)
1527
- - Large file processing
1528
- - Multi-model consensus
1529
- - Complex reasoning operations
1530
- - Batch operations
1531
-
1532
- ### Best Practices
1533
-
1534
- **Provider Development:**
1535
- - Always check API key availability in `isAvailable()`
1536
- - Implement consistent error handling
1537
- - Follow the standard response format
1538
- - Add comprehensive logging
1539
- - Handle rate limiting gracefully
1540
-
1541
- **Tool Development:**
1542
- - Validate all input parameters
1543
- - Use dependency injection pattern
1544
- - Return standardized responses
1545
- - Implement proper error handling
1546
- - Add detailed input schema
1547
-
1548
- **Testing:**
1549
- - Write unit tests for core logic
1550
- - Add integration tests with mocked APIs
1551
- - Test error conditions thoroughly
1552
- - Validate input/output formats
1553
-
1554
- **Documentation:**
1555
- - Update API documentation with new tools/providers
1556
- - Add usage examples
1557
- - Document configuration options
1558
- - Include troubleshooting guides
1559
-
1560
- ---
1561
-
1562
- For more examples and integration patterns, see [EXAMPLES.md](EXAMPLES.md).
1
+ # Converse MCP Server - API Reference
2
+
3
+ ## Overview
4
+
5
+ The Converse MCP Server exposes three tools through the Model Context Protocol (MCP):
6
+
7
+ 1. **Chat Tool** (`chat`) a single conversational tool with three execution modes:
8
+ - **`chat`** (default): 1..N models answer independently, in parallel.
9
+ - **`consensus`**: ≥2 models answer in parallel, then refine their answers after seeing each other.
10
+ - **`roundtable`**: models answer sequentially, each building on the running transcript.
11
+ 2. **Check Status Tool** (`check_status`) monitor and retrieve results from asynchronous jobs.
12
+ 3. **Cancel Job Tool** (`cancel_job`) — cancel a running background job.
13
+
14
+ The chat tool runs **synchronously** (immediate response) or **asynchronously** (`async: true`, background processing polled with `check_status`). When AI summarization is enabled, the server generates titles and summaries for better context tracking.
15
+
16
+ ## Transport Protocols
17
+
18
+ The server supports two transport modes:
19
+
20
+ ### HTTP Transport (Default)
21
+ - **Endpoint**: `http://localhost:3157/mcp`
22
+ - **Protocol**: HTTP streaming with JSON-RPC 2.0
23
+ - **Usage**: Best for development, debugging, and web integrations
24
+ - **Features**: Health endpoints, CORS support, session management
25
+
26
+ ### Stdio Transport (Legacy)
27
+ - **Protocol**: Standard input/output with JSON-RPC 2.0
28
+ - **Usage**: Traditional MCP client integrations
29
+ - **Features**: Process-based communication, lower latency
30
+
31
+ **Transport Selection:**
32
+ ```bash
33
+ # Default (HTTP)
34
+ npm start
35
+
36
+ # Explicit HTTP
37
+ npm start -- --transport=http
38
+
39
+ # Stdio transport
40
+ npm start -- --transport=stdio
41
+
42
+ # Environment variable
43
+ MCP_TRANSPORT=stdio npm start
44
+ ```
45
+
46
+ ## Chat Tool
47
+
48
+ **Description**: Talk to one or more AI models. The `mode` parameter selects how the models are orchestrated. Supports files, images, reasoning control, background execution, disk export, and multi-turn threads via `continuation_id`.
49
+
50
+ ### Request Schema
51
+
52
+ ```json
53
+ {
54
+ "type": "object",
55
+ "properties": {
56
+ "prompt": {
57
+ "type": "string",
58
+ "description": "Your question, topic, or task with relevant context. Example: 'How should I structure the authentication module for this Express.js API?'"
59
+ },
60
+ "models": {
61
+ "type": "array",
62
+ "items": { "type": "string" },
63
+ "minItems": 1,
64
+ "description": "Models to use, as plain name strings. Examples: ['auto'], ['codex'], ['codex', 'gemini', 'claude']. Default: ['auto']."
65
+ },
66
+ "mode": {
67
+ "type": "string",
68
+ "enum": ["chat", "consensus", "roundtable"],
69
+ "description": "Execution mode. 'chat' (default): independent parallel answers. 'consensus': >=2 models answer then refine via cross-feedback. 'roundtable': sequential turn-based dialogue in the given model order. Default: 'chat'."
70
+ },
71
+ "continuation_id": {
72
+ "type": "string",
73
+ "description": "Continuation ID for a persistent multi-turn thread. Auto-generated in the first response; pass it back to continue. You MAY change the mode or models on a resuming turn."
74
+ },
75
+ "files": {
76
+ "type": "array",
77
+ "items": { "type": "string" },
78
+ "description": "File paths to include as context (absolute or relative). Supports line ranges: file.txt{10:50}, file.txt{100:}. Example: ['./src/utils/auth.js{50:100}', './config.json']."
79
+ },
80
+ "images": {
81
+ "type": "array",
82
+ "items": { "type": "string" },
83
+ "description": "Image paths for visual context (absolute or relative paths, or base64 data). Example: ['C:\\Users\\username\\diagram.png', './screenshot.jpg', 'data:image/jpeg;base64,/9j/4AAQ...']."
84
+ },
85
+ "reasoning_effort": {
86
+ "type": "string",
87
+ "enum": ["none", "minimal", "low", "medium", "high", "max"],
88
+ "description": "Reasoning depth for thinking models. 'none' (fastest, GPT-5.1+ only), 'minimal', 'low', 'medium' (balanced), 'high', 'max'. Default: 'medium'."
89
+ },
90
+ "async": {
91
+ "type": "boolean",
92
+ "description": "Execute in the background. When true, returns a continuation_id immediately and processes the request asynchronously; poll with check_status. Default: false."
93
+ },
94
+ "export": {
95
+ "type": "boolean",
96
+ "description": "Export the conversation to disk. Creates a folder named for the continuation_id with numbered request/response files and metadata. Default: false."
97
+ }
98
+ },
99
+ "required": ["prompt"]
100
+ }
101
+ ```
102
+
103
+ Only `prompt` is required. `models` defaults to `["auto"]`, `mode` to `"chat"`, and `reasoning_effort` to `"medium"`.
104
+
105
+ ### Validation Rules
106
+
107
+ - `models` must be a non-empty array of non-empty strings.
108
+ - Duplicate model entries are rejected in `chat` and `consensus` modes; they are allowed only in `roundtable` (a model may talk to itself across turns).
109
+ - `consensus` mode requires at least **2 available** models after resolution. A single explicit model is rejected — use `chat` mode instead. `["auto"]` is valid in consensus when 2+ providers are configured (it expands to the first 3 available providers).
110
+
111
+ ### Modes
112
+
113
+ **`chat` (default) — independent parallel answers**
114
+
115
+ Each model is invoked in parallel and answers independently; models never see each other. With a single model (or `["auto"]`), the response is that model's answer, with automatic provider failover for `"auto"` and Codex thread reuse across turns. With multiple models, the response contains one labeled `### <model>:` section per successful model.
116
+
117
+ **`consensus` parallel answers, then cross-feedback refinement**
118
+
119
+ All models answer the prompt in parallel (phase 1). A cross-feedback refinement phase then always runs when at least 2 phase-1 responses succeed: each model sees the others' answers and refines its own. The result reports both the initial and refined responses. A single `["auto"]` spec expands to the first 3 available providers' default models.
120
+
121
+ **`roundtable` — sequential turn-based dialogue**
122
+
123
+ Models respond one after another in the exact order given, and each model sees the full running transcript of every turn before it. One tool call runs exactly **one lap** (one turn per model). Pass the returned `continuation_id` to run more laps; every lap appends to one shared, accumulating transcript. A turn that fails is recorded with a note and does not abort the lap.
124
+
125
+ ### Response Format
126
+
127
+ **Synchronous — `chat` mode:** the content is a status line, a `continuation_id:` line, then the answer (the status line is omitted in the test environment).
128
+
129
+ ```
130
+ COMPLETED | CHAT | conv_abc123 | 2.4s elapsed | openai/gpt-5.6-sol
131
+ continuation_id: conv_abc123
132
+
133
+ <model answer text>
134
+ ```
135
+
136
+ ```json
137
+ {
138
+ "content": "…status line + continuation_id + answer…",
139
+ "continuation": {
140
+ "id": "conv_abc123",
141
+ "messageCount": 2,
142
+ "provider": "openai",
143
+ "model": "gpt-5.6-sol"
144
+ }
145
+ }
146
+ ```
147
+
148
+ For a multi-model `chat` request, the status line reports `N/M succeeded` and lists the models, and `continuation.models` replaces `provider`/`model`.
149
+
150
+ **Synchronous — `consensus` mode:** a status line and `continuation_id:` line, followed by a JSON result object.
151
+
152
+ ```
153
+ ✅ COMPLETED | CONSENSUS | conv_xyz789 | 6.1s elapsed | 3/3 succeeded | gpt-5.6, gemini-2.5-pro, grok-4.5
154
+ continuation_id: conv_xyz789
155
+
156
+ {
157
+ "status": "consensus_complete",
158
+ "models_consulted": 3,
159
+ "successful_initial_responses": 3,
160
+ "failed_responses": 0,
161
+ "refined_responses": 3,
162
+ "phases": {
163
+ "initial": [
164
+ {
165
+ "model": "gpt-5.6",
166
+ "status": "success",
167
+ "response": "Initial analysis…"
168
+ }
169
+ ],
170
+ "refined": [
171
+ {
172
+ "model": "gpt-5.6",
173
+ "status": "success",
174
+ "initial_response": "Initial analysis…",
175
+ "refined_response": "After considering the other perspectives…"
176
+ }
177
+ ],
178
+ "failed": []
179
+ },
180
+ "continuation": {
181
+ "id": "conv_xyz789",
182
+ "messageCount": 3
183
+ },
184
+ "settings": {
185
+ "models_requested": ["gpt-5.6", "gemini-2.5-pro", "grok-4.5"]
186
+ }
187
+ }
188
+ ```
189
+
190
+ **Synchronous `roundtable` mode:** a status line, `continuation_id:` line, and a JSON result object whose top-level `content` holds the rendered transcript.
191
+
192
+ ```
193
+ COMPLETED | ROUNDTABLE | conv_abc123 | 3.2s elapsed | 2/2 turns | codex, gemini
194
+ continuation_id: conv_abc123
195
+
196
+ {
197
+ "status": "roundtable_complete",
198
+ "content": "…full rendered transcript of the lap…",
199
+ "models_consulted": 2,
200
+ "successful_turns": 2,
201
+ "failed_turns": 0,
202
+ "turns": [
203
+ { "model": "codex", "provider": "codex", "status": "success", "response": "Opening analysis…" },
204
+ { "model": "gemini", "provider": "gemini-cli", "status": "success", "response": "Building on codex's point…" }
205
+ ],
206
+ "continuation": {
207
+ "id": "conv_abc123",
208
+ "messageCount": 3
209
+ },
210
+ "settings": {
211
+ "models_requested": ["codex", "gemini"]
212
+ }
213
+ }
214
+ ```
215
+
216
+ **Asynchronous (any mode, `async: true`):**
217
+ ```json
218
+ {
219
+ "content": " SUBMITTED | CONSENSUS | conv_xyz789 | 1/1 | Started: 01/12/2026 10:30:00 | \"Architecture Review\" | gpt-5.6, gemini-2.5-pro, grok-4.5\ncontinuation_id: conv_xyz789",
220
+ "continuation": {
221
+ "id": "conv_xyz789",
222
+ "status": "processing"
223
+ },
224
+ "async_execution": true
225
+ }
226
+ ```
227
+
228
+ Poll with `check_status` using the returned `continuation_id`. When complete, the async result carries the full content (answer or rendered transcript) plus the AI-generated title and final summary.
229
+
230
+ ### Example Usage
231
+
232
+ **Single-model chat:**
233
+ ```json
234
+ {
235
+ "prompt": "Review this authentication function for security issues",
236
+ "models": ["gpt-5.6"],
237
+ "files": ["/project/src/auth.js{1:120}", "/project/config/security.json"],
238
+ "reasoning_effort": "high"
239
+ }
240
+ ```
241
+
242
+ **Multi-model chat (independent answers):**
243
+ ```json
244
+ {
245
+ "prompt": "Suggest a caching strategy for this endpoint",
246
+ "models": ["gpt-5.6", "gemini-2.5-flash", "grok-4.5"],
247
+ "files": ["/project/src/api/routes.js"]
248
+ }
249
+ ```
250
+
251
+ **Consensus:**
252
+ ```json
253
+ {
254
+ "prompt": "Should we use microservices or a monolith for our e-commerce platform?",
255
+ "models": ["gpt-5.6", "gemini-2.5-pro", "grok-4.5"],
256
+ "mode": "consensus",
257
+ "files": ["/docs/requirements.md", "/docs/current_architecture.md"],
258
+ "reasoning_effort": "high"
259
+ }
260
+ ```
261
+
262
+ **Roundtable (one lap):**
263
+ ```json
264
+ {
265
+ "prompt": "Should we adopt event sourcing for the order service?",
266
+ "models": ["codex", "gemini", "claude"],
267
+ "mode": "roundtable"
268
+ }
269
+ ```
270
+
271
+ **Roundtable (another lap on the same thread):**
272
+ ```json
273
+ {
274
+ "prompt": "Now focus specifically on the migration path.",
275
+ "models": ["codex", "gemini", "claude"],
276
+ "mode": "roundtable",
277
+ "continuation_id": "conv_abc123"
278
+ }
279
+ ```
280
+
281
+ **Async chat with conversation export:**
282
+ ```json
283
+ {
284
+ "prompt": "Design a scalable architecture for our system",
285
+ "models": ["gpt-5.6"],
286
+ "async": true,
287
+ "export": true,
288
+ "continuation_id": "conv_architecture_design"
289
+ }
290
+ ```
291
+
292
+ When `export` is enabled, the conversation is saved to disk under a folder named for the `continuation_id`:
293
+ ```
294
+ conv_architecture_design/
295
+ ├── 1_request.txt # First user prompt
296
+ ├── 1_response.txt # First model response
297
+ ├── 2_request.txt # Second user prompt (if continuing)
298
+ ├── 2_response.txt # Second model response
299
+ └── metadata.json # Conversation metadata and settings
300
+ ```
301
+
302
+ ## Check Status Tool
303
+
304
+ **Description**: Query the status and progress of async jobs, or list the most recent jobs.
305
+
306
+ ### Request Schema
307
+
308
+ ```json
309
+ {
310
+ "type": "object",
311
+ "properties": {
312
+ "continuation_id": {
313
+ "type": "string",
314
+ "description": "Optional job continuation ID to query. If not provided, returns the 10 most recent jobs."
315
+ },
316
+ "full_history": {
317
+ "type": "boolean",
318
+ "default": false,
319
+ "description": "When used with continuation_id, returns the full conversation history for that continuation ID. Only use when there are multiple turns and you need the whole conversation."
320
+ }
321
+ },
322
+ "additionalProperties": false
323
+ }
324
+ ```
325
+
326
+ ### Example Usage
327
+
328
+ ```json
329
+ // Check a specific job
330
+ { "continuation_id": "conv_abc123" }
331
+
332
+ // List the 10 most recent jobs
333
+ {}
334
+
335
+ // Get the full conversation history for a thread
336
+ { "continuation_id": "conv_abc123", "full_history": true }
337
+ ```
338
+
339
+ The response renders a human-readable status (start time, elapsed time, turn/model progress, and, when summarization is enabled, an AI-generated title and summary) plus the completed result content when available.
340
+
341
+ ## Cancel Job Tool
342
+
343
+ **Description**: Cancel a queued or running async job. Preserves partial results when available.
344
+
345
+ ### Request Schema
346
+
347
+ ```json
348
+ {
349
+ "type": "object",
350
+ "properties": {
351
+ "continuation_id": {
352
+ "type": "string",
353
+ "description": "The continuation_id of the job to cancel"
354
+ }
355
+ },
356
+ "required": ["continuation_id"],
357
+ "additionalProperties": false
358
+ }
359
+ ```
360
+
361
+ ### Example Usage
362
+
363
+ ```json
364
+ { "continuation_id": "conv_abc123" }
365
+ ```
366
+
367
+ Only jobs in a `queued` or `running` state can be cancelled; already-completed, failed, or cancelled jobs return a non-cancellable status.
368
+
369
+ ## Supported Models
370
+
371
+ Provide models as plain name strings in the `models` array. Bare names and aliases resolve to a provider automatically; use a namespace prefix (`claude:`, `gemini:`, `copilot:`, `openrouter:`) or a full `provider/model` slug for explicit routing.
372
+
373
+ ### OpenAI Models
374
+
375
+ | Model | Aliases | Context | Output | Notes |
376
+ |-------|---------|---------|--------|-------|
377
+ | `gpt-5.6-sol` | `gpt-5.6`, `gpt-5`, `sol` | 1M | 128K | Flagship, default OpenAI model |
378
+ | `gpt-5.6-terra` | `terra` | 400K | 128K | Lower-cost flagship-class tier |
379
+ | `gpt-5.6-luna` | `luna` | 400K | 128K | Fastest, most affordable tier |
380
+ | `gpt-5.4` | | 1M | 128K | Flagship-class reasoning |
381
+ | `gpt-5.4-pro` | `gpt-5-pro` | 1M | 272K | Maximum performance (expensive) |
382
+ | `gpt-5-mini`, `gpt-5-nano` | — | 400K | 128K | Fast, cost-efficient tiers |
383
+ | `gpt-5.4-mini`, `gpt-5.4-nano` | — | 400K | 128K | Fast GPT-5.4 tiers |
384
+ | `o3`, `o3-pro`, `o4-mini` | — | 200K | 100K | Reasoning models |
385
+ | `gpt-4.1` | `gpt-4.1` | 1M | 32K | Large context |
386
+ | `o3-deep-research`, `o4-mini-deep-research` | — | 200K | 100K | Deep research (long runtime) |
387
+
388
+ ### Google / Gemini Models (API-based)
389
+
390
+ | Model | Aliases | Context | Output | Notes |
391
+ |-------|---------|---------|--------|-------|
392
+ | `gemini-3.1-pro-preview` | `pro`, `gemini-pro` | 1M | 64K | Most advanced reasoning, expanded thinking levels |
393
+ | `gemini-3.5-flash` | `gemini-3.5`, `flash-3.5` | 1M | 65K | Frontier agentic/coding at Flash speed |
394
+ | `gemini-2.5-pro` | `pro 2.5` | 1M | 65K | Deep reasoning with thinking budget |
395
+ | `gemini-2.5-flash` | `flash` | 1M | 65K | Ultra-fast |
396
+ | `gemini-2.5-flash-lite` | `flash-lite` | 1M | 65K | Lightweight fast model |
397
+
398
+ **Note:** The short name `gemini` (and `gemini:pro` / `gemini:flash`) routes to the **Antigravity CLI** (`agy`, OAuth-based). For Google API access, use specific model names like `gemini-3.1-pro-preview` or `gemini-2.5-flash` (bare `gemini-pro` / `gemini-flash` also route to the Google API).
399
+
400
+ ### X.AI / Grok Models
401
+
402
+ | Model | Aliases | Context | Notes |
403
+ |-------|---------|---------|-------|
404
+ | `grok-4.5` | `grok`, `grok-4.5-latest`, `grok-build-latest` | 500K | Flagship: image input, reasoning content, native web/X search via Agent Tools |
405
+
406
+ `reasoning_effort` maps to Grok's `low`/`medium`/`high`; Grok 4.5 always reasons and cannot be disabled. Web search is attached automatically and the model decides whether to use it.
407
+
408
+ ### Anthropic Models (API-based)
409
+
410
+ | Model | Aliases | Context | Output | Notes |
411
+ |-------|---------|---------|--------|-------|
412
+ | `claude-fable-5` | `fable`, `fable-5` | 1M | 128K | Most capable, adaptive thinking + effort, images, caching, compaction |
413
+ | `claude-opus-4-8` | `opus`, `opus-4.8` | 200K (1M beta) | 128K | Complex reasoning and agentic coding |
414
+ | `claude-opus-4-7`, `claude-opus-4-6` | `opus-4.7`, `opus-4.6` | 200K (1M beta) | 128K | Previous Opus generations |
415
+ | `claude-opus-4-5-20251101`, `claude-opus-4-1-20250805` | `opus-4.5`, `opus-4.1` | 200K | 64K / 32K | Earlier Opus tiers |
416
+ | `claude-sonnet-4-6` | `sonnet`, `sonnet-4.6` | 200K (1M beta) | 64K | Best speed/intelligence balance, adaptive thinking |
417
+ | `claude-haiku-4-5-20251001` | `haiku`, `haiku-4.5` | 200K | 64K | Fast and intelligent |
418
+
419
+ Models with adaptive thinking control depth via `reasoning_effort`, which maps to Anthropic's `effort` parameter. System prompts are automatically cached for 1 hour; cache stats appear in response metadata as `cache_creation_input_tokens` / `cache_read_input_tokens`.
420
+
421
+ ### Mistral Models
422
+
423
+ | Model | Aliases | Context | Notes |
424
+ |-------|---------|---------|-------|
425
+ | `mistral-medium-3-5` | `mistral`, `mistral-medium` | 256K | Frontier-class multimodal, adjustable reasoning |
426
+ | `mistral-small-2603` | `mistral-small` | 256K | Hybrid multimodal (instruct + reasoning + coding) |
427
+ | `mistral-large-2512` | `mistral-large` | 256K | Open-weight MoE flagship, image-capable, no adjustable reasoning |
428
+
429
+ `reasoning_effort` maps to `high` (any enabled level) or `none` on Medium 3.5 and Small; Large has no adjustable reasoning.
430
+
431
+ ### DeepSeek Models
432
+
433
+ | Model | Aliases | Context | Output | Notes |
434
+ |-------|---------|---------|--------|-------|
435
+ | `deepseek-v4-pro` | `deepseek`, `deepseek-pro` | 1M | 384K | Flagship MoE, thinking mode, text-only |
436
+ | `deepseek-v4-flash` | `deepseek-flash` | 1M | 384K | Faster, lower-cost V4 tier, text-only |
437
+
438
+ `reasoning_effort`: `none` disables thinking; enabled levels use `high`; `max` uses `max`.
439
+
440
+ ### OpenRouter Models
441
+
442
+ | Model | Aliases | Context | Notes |
443
+ |-------|---------|---------|-------|
444
+ | `z-ai/glm-5.2` | `glm`, `glm-5.2` | 1M | Large-scale reasoning, text-only, default OpenRouter model |
445
+ | `deepseek/deepseek-v4-pro`, `deepseek/deepseek-v4-flash` | | 1M | DeepSeek V4 tiers, text-only |
446
+ | `qwen/qwen3.7-max` | `qwen3.7-max` | 1M | Flagship Qwen, text-only |
447
+ | `qwen/qwen3.7-plus` | `qwen3.7-plus` | 1M | Image-capable Qwen |
448
+ | `moonshotai/kimi-k2.7-code` | `kimi-k2.7-code` | 256K | Coding model, image-capable, reasoning always on |
449
+ | `moonshotai/kimi-k2.6` | `kimi-k2.6` | 256K | Image-capable general model |
450
+ | `openrouter/auto` | `auto-router`, `openrouter-auto` | — | Auto-selects the best model for the prompt |
451
+
452
+ Any other model works via its full `provider/model` slug (e.g. `anthropic/claude-sonnet-5`) or the `openrouter:` namespace. Append `:online` to a slug (e.g. `z-ai/glm-5.2:online`) to opt into web search, which adds a real per-request cost.
453
+
454
+ ### Codex (agentic, local)
455
+
456
+ **Codex** is an agentic coding assistant with direct filesystem access:
457
+
458
+ - **Model**: `codex` (underlying model: GPT-5.6)
459
+ - **Thread-based sessions**: persistent conversation history via `continuation_id` in `chat` mode
460
+ - **Direct file access**: reads files from the working directory (paths relative to `CLIENT_CWD`)
461
+ - **Response times**: 6-20 seconds typical (complex tasks may take minutes)
462
+ - **Authentication**: ChatGPT login OR `CODEX_API_KEY` (NOT `OPENAI_API_KEY`)
463
+ - `reasoning_effort` and web search are not applicable — Codex manages its own execution
464
+
465
+ ### Claude Agent SDK (subscription)
466
+
467
+ **Claude** is available through the Claude Agent SDK, using Claude Code CLI authentication instead of an API key:
468
+
469
+ - **Model**: `claude` (aliases: `claude-sdk`, `claude-code`) — defaults to Claude Fable 5
470
+ - **Model selection**: `claude:fable` (Claude Fable 5) or `claude:opus` (Claude Opus 4.8); unknown `claude:`-prefixed names pass through to the SDK (e.g. `claude:claude-sonnet-4-6`)
471
+ - **Authentication**: `claude login` — no `ANTHROPIC_API_KEY` needed
472
+ - **Direct file access**: reads files from the working directory
473
+ - `reasoning_effort` and sampling parameters are managed by the SDK
474
+
475
+ ### Gemini via Antigravity CLI (subscription)
476
+
477
+ The **Antigravity CLI** (`agy`) provides subscription-based access to Gemini models through Google OAuth:
478
+
479
+ - **Models** (text-only): `gemini` (= `gemini:pro`, Gemini 3.1 Pro), `gemini:flash` (Gemini 3.5 Flash)
480
+ - **Authentication**: Google OAuth via `agy` (one-time interactive login)
481
+ - **Setup**: install the Antigravity CLI and run `agy` once to log in
482
+ - **Billing**: uses your Antigravity subscription/compute allowance instead of API credits
483
+ - **Reasoning effort**: `low`/`medium`/`high`/`max` select the model variant
484
+ - **Context**: 1M tokens
485
+ - One-shot responses (no token-level streaming); ~7s minimum per call
486
+
487
+ **Authentication Setup:**
488
+ ```bash
489
+ # Install the Antigravity CLI (agy)
490
+ # Windows (PowerShell):
491
+ irm https://antigravity.google/cli/install.ps1 | iex
492
+ # macOS/Linux:
493
+ curl -fsSL https://antigravity.google/cli/install.sh | bash
494
+
495
+ # Run interactive login (one-time) — also establishes workspace trust
496
+ agy
497
+ ```
498
+
499
+ ### GitHub Copilot SDK (subscription)
500
+
501
+ Reach these with the `copilot:` namespace (e.g. `copilot:gpt-5.6-terra`); uses your GitHub Copilot subscription (`gh auth login`) — no API key needed:
502
+
503
+ - **OpenAI**: `gpt-5.6-sol` (aliases: `gpt-5.6`, `gpt-5`), `gpt-5.6-terra`, `gpt-5.6-luna` (all accept `reasoning_effort`)
504
+ - **Anthropic**: `claude-fable-5` (alias: `fable`), `claude-sonnet-5` (alias: `sonnet`), `claude-opus-4.8` (aliases: `opus`, `claude`)
505
+ - **Google**: `gemini-3.1-pro-preview` (aliases: `gemini`, `gemini-3.1-pro`), `gemini-3.5-flash` (alias: `gemini-flash`)
506
+ - Any other `copilot:<id>` is forwarded to the Copilot backend verbatim
507
+
508
+ ### Model Selection
509
+
510
+ Use `"auto"` for automatic selection, or specify exact models:
511
+
512
+ ```text
513
+ "auto" // First available provider (chat); first 3 (consensus)
514
+ "gpt-5.6" // OpenAI flagship
515
+ "gemini-2.5-flash" // Google API
516
+ "grok-4.5" // X.AI
517
+ "deepseek" // DeepSeek (-> deepseek-v4-pro)
518
+ "mistral" // Mistral (-> mistral-medium-3-5)
519
+ "z-ai/glm-5.2" // OpenRouter (full slug)
520
+ "z-ai/glm-5.2:online" // OpenRouter with web search opt-in
521
+ "fable" // Anthropic API (-> claude-fable-5)
522
+ "opus" // Anthropic API (-> claude-opus-4-8)
523
+ "claude" // Claude Agent SDK (-> Claude Fable 5)
524
+ "claude:opus" // Claude Agent SDK (Claude Opus 4.8)
525
+ "gemini" // Antigravity CLI (Gemini 3.1 Pro)
526
+ "copilot:gpt-5.6-terra" // GitHub Copilot SDK
527
+ ```
528
+
529
+ **Auto behavior:**
530
+ - **chat mode**: `["auto"]` selects the first available provider and uses its default model, with failover to the next provider on error.
531
+ - **consensus mode**: `["auto"]` expands to the first 3 available providers.
532
+
533
+ Provider auto-selection priority (subscription-based CLI/SDK providers first, then API-key providers): `codex`, `gemini-cli`, `claude`, `copilot`, `openai`, `google`, `xai`, `anthropic`, `mistral`, `deepseek`, `openrouter`.
534
+
535
+ ## Configuration
536
+
537
+ ### AI Summarization
538
+
539
+ ```bash
540
+ ENABLE_RESPONSE_SUMMARIZATION=true # Enable AI-generated titles and summaries (default: false)
541
+ SUMMARIZATION_MODEL=gpt-5-nano # Model used for summarization (default: gpt-5-nano)
542
+ ```
543
+
544
+ When enabled: title generation (up to 60 chars) per request, streaming progress summaries during async jobs, 1-2 sentence final summaries, and enhanced `check_status` display. Summarization is non-blocking — failures fall back to text snippets and never affect the main flow.
545
+
546
+ ### Codex Configuration
547
+
548
+ Control Codex behavior through environment variables:
549
+
550
+ - **`CODEX_SANDBOX_MODE`** filesystem access: `read-only` (default), `workspace-write`, `danger-full-access` (containers only)
551
+ - **`CODEX_SKIP_GIT_CHECK`** — `true` (default) works in any directory; `false` requires a Git repository
552
+ - **`CODEX_APPROVAL_POLICY`** `never` (default, recommended for servers), `untrusted`, `on-failure`, `on-request`
553
+ - **`CODEX_MODEL`** underlying model for Codex sessions (default: `gpt-5.6-sol`)
554
+ - **`CODEX_API_KEY`** optional API key for headless deployments (alternative to ChatGPT login)
555
+
556
+ **Example (.env):**
557
+ ```bash
558
+ CODEX_API_KEY=your_codex_api_key_here
559
+ CODEX_SANDBOX_MODE=read-only
560
+ CODEX_SKIP_GIT_CHECK=true
561
+ CODEX_APPROVAL_POLICY=never
562
+ CODEX_MODEL=gpt-5.6-sol
563
+ ```
564
+
565
+ ## Context Processing
566
+
567
+ ### File Support
568
+
569
+ **Supported text formats:** `.txt`, `.md`, `.js`, `.ts`, `.json`, `.yaml`, `.yml`, `.py`, `.java`, `.c`, `.cpp`, `.h`, `.css`, `.html`, `.xml`, `.csv`, `.sql`, `.sh`, `.bat`, `.log`
570
+
571
+ **Supported image formats:** `.jpg`, `.jpeg`, `.png`, `.gif`, `.webp`, `.bmp`
572
+
573
+ **Size limits:** text files 1MB default; image files 10MB default
574
+
575
+ ### File Processing
576
+
577
+ Provide paths in the `files` array. Line ranges are supported: `file.txt{10:50}` for lines 10-50, `file.txt{100:}` from line 100 onward.
578
+
579
+ ```json
580
+ {
581
+ "files": [
582
+ "/absolute/path/to/file.js",
583
+ "./relative/path/to/file.md{1:80}"
584
+ ]
585
+ }
586
+ ```
587
+
588
+ The processed context includes file content with line numbers and metadata (size, last modified) and reports inaccessible files as errors.
589
+
590
+ ### Image Processing
591
+
592
+ ```json
593
+ {
594
+ "images": [
595
+ "/path/to/diagram.png",
596
+ "data:image/jpeg;base64,/9j/4AAQ..."
597
+ ]
598
+ }
599
+ ```
600
+
601
+ Images are base64-encoded and sent to models that support vision. When a request includes images, `"auto"` selection skips text-only providers.
602
+
603
+ ## Continuation System
604
+
605
+ The first request creates a continuation automatically and returns its ID; pass it back on subsequent requests to continue the thread. The continuation persists across modes — you may switch `mode` and `models` on a resuming turn, and the shared transcript is the context. Custom continuation IDs are accepted (letters, numbers, hyphens, underscores; max 128 chars). Conversations expire after 24 hours of inactivity.
606
+
607
+ ```json
608
+ // First request (no continuation_id)
609
+ { "prompt": "Start a discussion about architecture", "models": ["auto"] }
610
+
611
+ // Follow-up (reuse the returned id)
612
+ { "prompt": "What about microservices?", "continuation_id": "conv_abc123" }
613
+ ```
614
+
615
+ ## Asynchronous Execution
616
+
617
+ Set `async: true` on a chat request for long-running work:
618
+
619
+ 1. **Immediate response**: returns a `continuation_id` instantly.
620
+ 2. **Background processing**: the job runs with streaming support.
621
+ 3. **Status monitoring**: poll with `check_status`.
622
+ 4. **Result retrieval**: full results (answer or transcript) available when the job completes.
623
+ 5. **Cancellation**: use `cancel_job` to stop a running job.
624
+
625
+ ### Status Types
626
+
627
+ | Status | Description | Actions Available |
628
+ |--------|-------------|-------------------|
629
+ | `processing` | Job is running | Cancel, Check Status |
630
+ | `completed` | Job finished successfully | Get Results |
631
+ | `failed` | Job encountered an error | Check Error Details |
632
+ | `cancelled` | Job was cancelled | None |
633
+
634
+ ### Caching
635
+
636
+ - **Memory cache (24 hours)**: active jobs and recent completions for fast status lookups.
637
+ - **Disk cache (3 days)**: long-term result storage that survives server restarts.
638
+
639
+ ### When to Use Async
640
+
641
+ - Long analysis tasks (>30 seconds)
642
+ - Large file processing
643
+ - Multi-model consensus or multi-lap roundtables
644
+ - Deep-research and other long-running models
645
+
646
+ ## Error Handling
647
+
648
+ **Missing API key / unavailable provider:**
649
+ ```json
650
+ { "error": "Provider openai is not available. Check API key configuration." }
651
+ ```
652
+
653
+ **Invalid model:**
654
+ ```json
655
+ { "error": "Provider not found for model: invalid-model" }
656
+ ```
657
+
658
+ **All models failed (multi-model chat):** the error lists each model and its failure. In consensus/roundtable, individual model/turn failures are recorded in the result (`failed` entries and trailing failure details) rather than aborting the whole request.
659
+
660
+ ## Authentication
661
+
662
+ **Environment variables:**
663
+ ```bash
664
+ OPENAI_API_KEY=sk-proj-...
665
+ GOOGLE_API_KEY=AIzaSy... # or GEMINI_API_KEY (GEMINI_API_KEY takes priority)
666
+ XAI_API_KEY=xai-...
667
+ ANTHROPIC_API_KEY=sk-ant-...
668
+ MISTRAL_API_KEY=...
669
+ DEEPSEEK_API_KEY=...
670
+ OPENROUTER_API_KEY=sk-or-...
671
+ ```
672
+
673
+ **MCP client configuration:**
674
+ ```json
675
+ {
676
+ "env": {
677
+ "OPENAI_API_KEY": "sk-proj-...",
678
+ "GOOGLE_API_KEY": "AIzaSy...",
679
+ "XAI_API_KEY": "xai-..."
680
+ }
681
+ }
682
+ ```
683
+
684
+ Subscription providers (Codex, Claude Agent SDK, Antigravity CLI, Copilot SDK) use local CLI authentication instead of API keys — see [PROVIDERS.md](PROVIDERS.md).
685
+
686
+ ### Security
687
+
688
+ - API keys are never logged or exposed
689
+ - Path traversal protection for file access
690
+ - File access limited to allowed directories
691
+ - Input validation on all parameters
692
+
693
+ ## Server Limits
694
+
695
+ ```bash
696
+ MAX_MCP_OUTPUT_TOKENS=200000 # Max output tokens (default 25,000)
697
+ ```
698
+
699
+ Response bodies are token-limited to fit the configured MCP output ceiling.
700
+
701
+ ---
702
+
703
+ For usage examples across common scenarios, see [EXAMPLES.md](EXAMPLES.md).