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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
//! Core and additional tool definitions for the registry.
//!
//! Extracted from `definitions.rs` to maintain the ≤500 LOC invariant.
use crate::types::Tool;
use serde_json::json;
/// Create additional extended tools from tool_definitions.rs
/// These tools are loaded on-demand and not in the core set
pub(super) fn create_additional_extended_tools() -> Vec<Tool> {
vec![
// Advanced pattern analysis tool
crate::mcp::tools::advanced_pattern_analysis::AdvancedPatternAnalysisTool::tool_definition(
),
// Quality metrics tool
crate::mcp::tools::quality_metrics::QualityMetricsTool::tool_definition(),
// Embedding configuration and query tools
crate::mcp::tools::embeddings::configure_embeddings_tool(),
crate::mcp::tools::embeddings::query_semantic_memory_tool(),
crate::mcp::tools::embeddings::test_embeddings_tool(),
// New embedding tools
crate::mcp::tools::embeddings::generate_embedding_tool(),
crate::mcp::tools::embeddings::search_by_embedding_tool(),
crate::mcp::tools::embeddings::embedding_provider_status_tool(),
// External signal provider tools
crate::mcp::tools::external_signals::configure_agentfs_tool(),
crate::mcp::tools::external_signals::external_signal_status_tool(),
crate::mcp::tools::external_signals::test_agentfs_connection_tool(),
// Pattern search tool
Tool::new(
"search_patterns".to_string(),
"Search for patterns semantically similar to a query using multi-signal ranking"
.to_string(),
json!({
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Natural language query describing what pattern to search for"
},
"domain": {
"type": "string",
"description": "Domain to search in (e.g., 'web-api', 'cli', 'data-processing')"
},
"tags": {
"type": "array",
"items": {"type": "string"},
"description": "Optional tags for filtering",
"default": []
},
"limit": {
"type": "integer",
"description": "Maximum number of results (default: 5)",
"default": 5
},
"min_relevance": {
"type": "number",
"description": "Minimum relevance score 0.0-1.0 (default: 0.3)",
"default": 0.3
},
"filter_by_domain": {
"type": "boolean",
"description": "Whether to filter by domain (default: false)",
"default": false
}
},
"required": ["query", "domain"]
}),
),
// Pattern recommendation tool
Tool::new(
"recommend_patterns".to_string(),
"Get pattern recommendations for a specific task with high-quality filtering"
.to_string(),
json!({
"type": "object",
"properties": {
"task_description": {
"type": "string",
"description": "Description of the task you're working on"
},
"domain": {
"type": "string",
"description": "Domain of the task (e.g., 'web-api', 'cli')"
},
"tags": {
"type": "array",
"items": {"type": "string"},
"description": "Optional context tags",
"default": []
},
"limit": {
"type": "integer",
"description": "Maximum number of recommendations (default: 3)",
"default": 3
}
},
"required": ["task_description", "domain"]
}),
),
// ADR-044 Feature 1: Playbook recommendation tool
Tool::new(
"recommend_playbook".to_string(),
"Get an actionable playbook with step-by-step guidance for a task (ADR-044 Feature 1)"
.to_string(),
json!({
"type": "object",
"properties": {
"task_description": {
"type": "string",
"description": "Description of the task to perform"
},
"domain": {
"type": "string",
"description": "Domain of the task (e.g., 'web-api', 'testing', 'data-processing')"
},
"task_type": {
"type": "string",
"enum": ["code_generation", "debugging", "refactoring", "testing", "analysis", "documentation"],
"description": "Type of task being performed",
"default": "code_generation"
},
"max_steps": {
"type": "integer",
"description": "Maximum number of steps to include (default: 5)",
"default": 5
},
"language": {
"type": "string",
"description": "Programming language (optional)",
"default": null
},
"framework": {
"type": "string",
"description": "Framework being used (optional)",
"default": null
},
"tags": {
"type": "array",
"items": {"type": "string"},
"description": "Additional context tags",
"default": []
}
},
"required": ["task_description", "domain"]
}),
),
// ADR-044 Feature 1: Pattern explanation tool
Tool::new(
"explain_pattern".to_string(),
"Get a human-readable explanation of a pattern including when to use it and expected outcomes"
.to_string(),
json!({
"type": "object",
"properties": {
"pattern_id": {
"type": "string",
"description": "UUID of the pattern to explain",
"format": "uuid"
}
},
"required": ["pattern_id"]
}),
),
// ADR-044 Feature 2: Recommendation feedback tools
Tool::new(
"record_recommendation_session".to_string(),
"Record a recommendation session when patterns/playbooks are suggested to an agent"
.to_string(),
json!({
"type": "object",
"properties": {
"episode_id": {
"type": "string",
"description": "Episode ID for which recommendations are made"
},
"recommended_pattern_ids": {
"type": "array",
"items": {"type": "string"},
"description": "Pattern IDs that were recommended",
"default": []
},
"recommended_playbook_ids": {
"type": "array",
"items": {"type": "string"},
"description": "Playbook IDs that were recommended",
"default": []
}
},
"required": ["episode_id"]
}),
),
Tool::new(
"record_recommendation_feedback".to_string(),
"Record feedback about which recommendations were used and the outcome".to_string(),
json!({
"type": "object",
"properties": {
"session_id": {
"type": "string",
"description": "Session ID from the recommendation session"
},
"applied_pattern_ids": {
"type": "array",
"items": {"type": "string"},
"description": "Pattern IDs that were actually applied",
"default": []
},
"consulted_episode_ids": {
"type": "array",
"items": {"type": "string"},
"description": "Episode IDs that were consulted",
"default": []
},
"outcome": {
"type": "object",
"description": "Final outcome of the task",
"properties": {
"type": {
"type": "string",
"enum": ["success", "partial_success", "failure"]
},
"verdict": {"type": "string"},
"reason": {"type": "string"},
"artifacts": {
"type": "array",
"items": {"type": "string"},
"default": []
}
},
"required": ["type"]
},
"agent_rating": {
"type": "number",
"description": "Optional rating of recommendation quality (0.0-1.0)",
"minimum": 0.0,
"maximum": 1.0
}
},
"required": ["session_id", "outcome"]
}),
),
Tool::new(
"get_recommendation_stats".to_string(),
"Get statistics about recommendation effectiveness and adoption rates".to_string(),
json!({
"type": "object",
"properties": {}
}),
),
// ADR-044 Feature 3: Checkpoint tools
crate::mcp::tools::checkpoint::CheckpointTools::checkpoint_episode_tool(),
crate::mcp::tools::checkpoint::CheckpointTools::get_handoff_pack_tool(),
crate::mcp::tools::checkpoint::CheckpointTools::resume_from_handoff_tool(),
]
}
/// Create core tools that are always loaded
pub(super) fn create_core_tools() -> Vec<Tool> {
vec![
// Memory query
Tool::new(
"query_memory".to_string(),
"Query episodic memory for relevant past experiences and learned patterns".to_string(),
json!({
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Search query describing the task or context"
},
"domain": {
"type": "string",
"description": "Task domain (e.g., 'web-api', 'data-processing')"
},
"task_type": {
"type": "string",
"enum": ["code_generation", "debugging", "refactoring", "testing", "analysis", "documentation"],
"description": "Type of task being performed"
},
"limit": {
"type": "integer",
"default": 10,
"description": "Maximum number of episodes to retrieve"
},
"sort": {
"type": "string",
"enum": ["relevance", "newest", "oldest", "duration", "success"],
"default": "relevance",
"description": "Sort order for results"
},
"fields": {
"type": "array",
"items": {"type": "string"},
"description": "Fields to return (e.g., ['episodes.id', 'episodes.task_description', 'patterns.success_rate'])",
"default": null
}
},
"required": ["query", "domain"]
}),
),
// Health and monitoring
Tool::new(
"health_check".to_string(),
"Check the health status of the MCP server and its components".to_string(),
json!({"type": "object", "properties": {}}),
),
Tool::new(
"get_metrics".to_string(),
"Get comprehensive monitoring metrics and statistics".to_string(),
json!({
"type": "object",
"properties": {
"metric_type": {
"type": "string",
"enum": ["all", "performance", "episodes", "system"],
"default": "all",
"description": "Type of metrics to retrieve"
}
}
}),
),
// Core pattern analysis
Tool::new(
"analyze_patterns".to_string(),
"Analyze patterns from past episodes to identify successful strategies".to_string(),
json!({
"type": "object",
"properties": {
"task_type": {
"type": "string",
"description": "Type of task to analyze patterns for"
},
"min_success_rate": {
"type": "number",
"default": 0.7,
"description": "Minimum success rate for patterns (0.0-1.0)"
},
"limit": {
"type": "integer",
"default": 20,
"description": "Maximum number of patterns to return"
},
"fields": {
"type": "array",
"items": {"type": "string"},
"description": "Fields to return (e.g., ['patterns.tool_sequence', 'statistics.most_common_tools'])",
"default": null
}
},
"required": ["task_type"]
}),
),
// Episode lifecycle
Tool::new(
"create_episode".to_string(),
"Create a new episode to track task execution programmatically".to_string(),
json!({
"type": "object",
"properties": {
"task_description": {
"type": "string",
"description": "Clear description of the task to be performed"
},
"domain": {
"type": "string",
"description": "Task domain (e.g., 'web-api', 'cli', 'data-processing')"
},
"task_type": {
"type": "string",
"enum": ["code_generation", "debugging", "refactoring", "testing", "analysis", "documentation"],
"description": "Type of task being performed"
},
"complexity": {
"type": "string",
"enum": ["simple", "moderate", "complex"],
"default": "moderate",
"description": "Task complexity level"
},
"tags": {
"type": "array",
"items": {"type": "string"},
"description": "Optional context tags"
}
},
"required": ["task_description", "domain", "task_type"]
}),
),
Tool::new(
"add_episode_step".to_string(),
"Add an execution step to an ongoing episode to track progress".to_string(),
json!({
"type": "object",
"properties": {
"episode_id": {
"type": "string",
"description": "UUID of the episode",
"format": "uuid"
},
"step_number": {
"type": "integer",
"description": "Sequential step number"
},
"tool": {
"type": "string",
"description": "Name of the tool/component performing the action"
},
"action": {
"type": "string",
"description": "Description of the action taken"
},
"parameters": {
"type": "object",
"description": "Optional parameters used in this step"
},
"result": {
"type": "object",
"description": "Optional result of the step"
}
},
"required": ["episode_id", "step_number", "tool", "action"]
}),
),
Tool::new(
"complete_episode".to_string(),
"Complete an episode with an outcome and trigger the learning cycle".to_string(),
json!({
"type": "object",
"properties": {
"episode_id": {
"type": "string",
"description": "UUID of the episode",
"format": "uuid"
},
"outcome_type": {
"type": "string",
"enum": ["success", "partial_success", "failure"],
"description": "Type of outcome"
},
"verdict": {
"type": "string",
"description": "Description of the outcome (required for success/partial_success)"
},
"completed": {
"type": "array",
"items": {"type": "string"},
"description": "Array of completed items (required for partial_success)"
},
"failed": {
"type": "array",
"items": {"type": "string"},
"description": "Array of failed items (required for partial_success)"
},
"reason": {
"type": "string",
"description": "Failure reason (required for failure)"
},
"artifacts": {
"type": "array",
"items": {"type": "string"},
"description": "Array of artifact names (optional, for success)"
}
},
"required": ["episode_id", "outcome_type"]
}),
),
// Get episode details
Tool::new(
"get_episode".to_string(),
"Get complete details of an episode including steps, outcome, reflection, and patterns"
.to_string(),
json!({
"type": "object",
"properties": {
"episode_id": {
"type": "string",
"description": "UUID of the episode to retrieve",
"format": "uuid"
},
"fields": {
"type": "array",
"items": {"type": "string"},
"description": "Fields to return (e.g., ['episode.id', 'episode.task_description', 'episode.outcome'])",
"default": null
}
},
"required": ["episode_id"]
}),
),
]
}