Commit 1e9b556
committed
Feat: Implement MCP protocol-compliant progress notifications for agentic workflows
Implements real-time progress tracking for multi-step agentic analysis tools using
the MCP protocol's native progress notification system.
## Changes
### AgenticOrchestrator (crates/codegraph-mcp/src/agentic_orchestrator.rs)
- Added ProgressCallback type alias for async notification callbacks
- Added optional progress_callback field to AgenticOrchestrator struct
- Updated all constructors (new, new_with_override, with_config) to accept progress_callback
- Implemented progress notifications at two key points:
* Step start: progress = step_number (e.g., 1.0, 2.0, 3.0)
* Tool completion: progress = step_number + 0.5 (e.g., 1.5, 2.5, 3.5)
- Progress total is set to max_steps from tier configuration
### MCP Server (crates/codegraph-mcp/src/official_server.rs)
- Added rmcp imports: ProgressNotification, ProgressNotificationParam, ServerNotification
- Created create_progress_callback() helper function that:
* Accepts Peer<RoleServer> and ProgressToken
* Returns Arc<Fn> callback for sending MCP progress notifications
* Wraps notifications in ServerNotification::ProgressNotification
* Handles notification errors gracefully (non-blocking)
- Updated execute_agentic_workflow() to:
* Accept peer: Peer<RoleServer> and meta: Meta parameters
* Extract progress_token from meta or auto-generate UUID-based token
* Create and pass progress callback to orchestrator
- Updated all 7 agentic tool handlers to extract and pass peer/meta:
* agentic_code_search
* agentic_dependency_analysis
* agentic_call_chain_analysis
* agentic_architecture_analysis
* agentic_api_surface_analysis
* agentic_context_builder
* agentic_semantic_question
### Configuration
- Added minimal config/default.toml for compilation
## Progress Notification Format
Clients receive MCP progress notifications during workflow execution:
```json
{
"jsonrpc": "2.0",
"method": "notifications/progress",
"params": {
"progressToken": "agentic-<uuid>",
"progress": 1.5,
"total": 10.0
}
}
```
Progress values:
- Step 1 start: 1.0 / 10.0
- Step 1 tool done: 1.5 / 10.0
- Step 2 start: 2.0 / 10.0
- ... continues through max_steps
## Architecture Decisions
1. **Non-blocking notifications**: Notification failures don't interrupt workflows
2. **Auto-generated tokens**: UUID-based tokens when client doesn't provide one
3. **Granular progress**: Half-step increments show both reasoning and tool execution phases
4. **MCP protocol compliance**: Uses official rmcp types and ServerNotification wrapping
## Testing
Compilation verified with:
```bash
cargo check -p codegraph-mcp --features ai-enhanced
```
Runtime testing requires SurrealDB and can be performed with test_agentic_tools.py1 parent 553239f commit 1e9b556
File tree
3 files changed
+152
-65
lines changed- config
- crates/codegraph-mcp/src
3 files changed
+152
-65
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 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 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
47 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
| |||
202 | 207 | | |
203 | 208 | | |
204 | 209 | | |
| 210 | + | |
| 211 | + | |
205 | 212 | | |
206 | 213 | | |
207 | 214 | | |
| |||
211 | 218 | | |
212 | 219 | | |
213 | 220 | | |
214 | | - | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | | - | |
| 224 | + | |
218 | 225 | | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
222 | 229 | | |
| 230 | + | |
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
226 | 234 | | |
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
| 238 | + | |
230 | 239 | | |
231 | 240 | | |
232 | 241 | | |
233 | | - | |
| 242 | + | |
234 | 243 | | |
235 | 244 | | |
236 | 245 | | |
237 | 246 | | |
238 | 247 | | |
| 248 | + | |
239 | 249 | | |
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
243 | 253 | | |
244 | 254 | | |
| 255 | + | |
245 | 256 | | |
246 | 257 | | |
247 | 258 | | |
| |||
273 | 284 | | |
274 | 285 | | |
275 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
276 | 294 | | |
277 | 295 | | |
278 | 296 | | |
| |||
322 | 340 | | |
323 | 341 | | |
324 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
325 | 350 | | |
326 | 351 | | |
327 | 352 | | |
| |||
0 commit comments