@exaudeus/workrail 0.0.2 → 0.0.4

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 (31) hide show
  1. package/README.md +30 -0
  2. package/dist/cli.js +140 -23
  3. package/dist/cli.js.map +1 -1
  4. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts +50 -0
  5. package/dist/infrastructure/storage/multi-directory-workflow-storage.d.ts.map +1 -0
  6. package/dist/infrastructure/storage/multi-directory-workflow-storage.js +209 -0
  7. package/dist/infrastructure/storage/multi-directory-workflow-storage.js.map +1 -0
  8. package/dist/infrastructure/storage/storage.d.ts +7 -2
  9. package/dist/infrastructure/storage/storage.d.ts.map +1 -1
  10. package/dist/infrastructure/storage/storage.js +15 -2
  11. package/dist/infrastructure/storage/storage.js.map +1 -1
  12. package/dist/utils/config.d.ts +11 -2
  13. package/dist/utils/config.d.ts.map +1 -1
  14. package/dist/utils/config.js +6 -3
  15. package/dist/utils/config.js.map +1 -1
  16. package/package.json +4 -2
  17. package/spec/examples/adaptive-ticket-creation.json +170 -0
  18. package/spec/examples/ai-task-prompt-workflow.json +80 -0
  19. package/spec/examples/coding-task-workflow.json +141 -0
  20. package/spec/examples/conditional-workflow-example.json +216 -0
  21. package/spec/examples/invalid-workflow.json +20 -0
  22. package/spec/examples/valid-workflow.json +118 -0
  23. package/spec/mcp-api-v1.0.md +714 -0
  24. package/spec/mcp-compliance-summary.md +211 -0
  25. package/spec/mcp-protocol-handshake.md +603 -0
  26. package/spec/workflow.schema.json +327 -0
  27. package/workflows/adaptive-ticket-creation.json +257 -0
  28. package/workflows/coding-task-workflow.json +115 -0
  29. package/workflows/mr-review-workflow.json +79 -0
  30. package/workflows/presentation-creation.json +245 -0
  31. package/workflows/workflow-for-workflows.json +74 -0
@@ -0,0 +1,603 @@
1
+ # MCP Protocol Specification for Workflow Orchestration
2
+
3
+ > 🤝 **Model Context Protocol Implementation for Workflow Orchestration System**
4
+
5
+ [![Status](https://img.shields.io/badge/status-specification-orange.svg)](https://github.com/yourusername/workflow-orchestration-system)
6
+ [![MCP Version](https://img.shields.io/badge/MCP-2024--11--05-blue.svg)](https://modelcontextprotocol.org)
7
+ [![Protocol](https://img.shields.io/badge/protocol-JSON--RPC%202.0-green.svg)](https://www.jsonrpc.org/specification)
8
+
9
+ ---
10
+
11
+ ## Purpose & Scope
12
+
13
+ This specification defines the MCP (Model Context Protocol) handshake and initialization protocol for the Workflow Orchestration System's `workflowlookup` server. It covers server initialization, tool discovery, error handling, communication framing, and lifecycle requirements for MCP-compliant servers and clients.
14
+
15
+ This document is normative for all implementations of the workflowlookup MCP server and any client wishing to interoperate with it.
16
+
17
+ ## Normative Language
18
+
19
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://datatracker.ietf.org/doc/html/rfc2119).
20
+
21
+ ---
22
+
23
+ ## Overview
24
+
25
+ This document specifies the MCP (Model Context Protocol) implementation for the workflowlookup server. The server follows the MCP standard for server initialization, tool discovery, and communication.
26
+
27
+ **Protocol Version**: `2024-11-05`
28
+ **Base Protocol**: JSON-RPC 2.0
29
+ **Transport**: stdio (standard input/output)
30
+ **Encoding**: UTF-8
31
+ **Framing**: Newline-delimited JSON messages (one message per line)
32
+
33
+ ## Server Initialization
34
+
35
+ ### Initialize Request
36
+
37
+ The client must send an `initialize` request to establish the connection:
38
+
39
+ ```json
40
+ {
41
+ "jsonrpc": "2.0",
42
+ "id": 1,
43
+ "method": "initialize",
44
+ "params": {
45
+ "protocolVersion": "2024-11-05",
46
+ "capabilities": {
47
+ "tools": {}
48
+ },
49
+ "clientInfo": {
50
+ "name": "claude-desktop",
51
+ "version": "1.0.0"
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ **Parameters:**
58
+ - `protocolVersion` (required): MCP protocol version being used
59
+ - `capabilities` (required): Client capabilities object
60
+ - `clientInfo` (optional): Client information
61
+ - `name`: Client name (e.g., "claude-desktop", "firebender")
62
+ - `version`: Client version string
63
+
64
+ ### Initialize Response
65
+
66
+ The server responds with its capabilities and information:
67
+
68
+ ```json
69
+ {
70
+ "jsonrpc": "2.0",
71
+ "id": 1,
72
+ "result": {
73
+ "protocolVersion": "2024-11-05",
74
+ "capabilities": {
75
+ "tools": {
76
+ "listChanged": false,
77
+ "notifyProgress": false
78
+ },
79
+ "resources": {
80
+ "listChanged": false
81
+ }
82
+ },
83
+ "serverInfo": {
84
+ "name": "workflowlookup",
85
+ "version": "1.0.0",
86
+ "description": "Workflow Orchestration System MCP Server"
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ **Response Fields:**
93
+ - `protocolVersion`: Confirms the protocol version being used
94
+ - `capabilities`: Server capabilities
95
+ - `tools.listChanged`: Whether server supports tool list change notifications
96
+ - `tools.notifyProgress`: Whether server supports progress notifications
97
+ - `resources.listChanged`: Whether server supports resource list change notifications
98
+ - `serverInfo`: Information about the server
99
+ - `name`: Server name identifier
100
+ - `version`: Server version following semantic versioning
101
+ - `description`: Human-readable server description
102
+
103
+ ### Initialize Error Cases
104
+
105
+ ```json
106
+ // Unsupported protocol version
107
+ {
108
+ "jsonrpc": "2.0",
109
+ "id": 1,
110
+ "error": {
111
+ "code": -32000,
112
+ "message": "Unsupported protocol version",
113
+ "data": {
114
+ "supportedVersions": ["2024-11-05"],
115
+ "requestedVersion": "2024-10-01"
116
+ }
117
+ }
118
+ }
119
+
120
+ // Invalid initialization parameters
121
+ {
122
+ "jsonrpc": "2.0",
123
+ "id": 1,
124
+ "error": {
125
+ "code": -32602,
126
+ "message": "Invalid params",
127
+ "data": {
128
+ "details": "protocolVersion is required"
129
+ }
130
+ }
131
+ }
132
+ ```
133
+
134
+ ## Tool Discovery
135
+
136
+ ### Tools List Request
137
+
138
+ After successful initialization, the client requests available tools:
139
+
140
+ ```json
141
+ {
142
+ "jsonrpc": "2.0",
143
+ "id": 2,
144
+ "method": "tools/list",
145
+ "params": {}
146
+ }
147
+ ```
148
+
149
+ ### Tools List Response
150
+
151
+ The server responds with all available tools, their schemas, and metadata:
152
+
153
+ ```json
154
+ {
155
+ "jsonrpc": "2.0",
156
+ "id": 2,
157
+ "result": {
158
+ "tools": [
159
+ {
160
+ "name": "workflow_list",
161
+ "description": "Lists all available workflows",
162
+ "inputSchema": {
163
+ "type": "object",
164
+ "properties": {},
165
+ "required": [],
166
+ "additionalProperties": false
167
+ },
168
+ "outputSchema": {
169
+ "type": "object",
170
+ "properties": {
171
+ "workflows": {
172
+ "type": "array",
173
+ "items": {
174
+ "type": "object",
175
+ "properties": {
176
+ "id": {"type": "string"},
177
+ "name": {"type": "string"},
178
+ "description": {"type": "string"},
179
+ "category": {"type": "string"},
180
+ "version": {"type": "string"}
181
+ },
182
+ "required": ["id", "name", "description", "category", "version"]
183
+ }
184
+ }
185
+ },
186
+ "required": ["workflows"]
187
+ },
188
+ "examples": {
189
+ "request": {"method": "workflow_list", "params": {}},
190
+ "response": {"workflows": [{"id": "ai-task-implementation", "name": "AI Task Prompt Workflow", "description": "Guides through task understanding → planning → implementation → verification", "category": "development", "version": "1.0.0"}]}
191
+ }
192
+ },
193
+ {
194
+ "name": "workflow_get",
195
+ "description": "Retrieves a specific workflow by ID",
196
+ "inputSchema": {
197
+ "type": "object",
198
+ "properties": {
199
+ "id": {
200
+ "type": "string",
201
+ "description": "The workflow ID to retrieve",
202
+ "pattern": "^[a-z0-9-]+$",
203
+ "minLength": 3,
204
+ "maxLength": 64
205
+ }
206
+ },
207
+ "required": ["id"],
208
+ "additionalProperties": false
209
+ },
210
+ "outputSchema": {
211
+ "$ref": "workflow.schema.json"
212
+ },
213
+ "examples": {
214
+ "request": {"method": "workflow_get", "params": {"id": "ai-task-implementation"}},
215
+ "response": {"id": "ai-task-implementation", "name": "AI Task Prompt Workflow", "description": "Complete task implementation with verification", "preconditions": ["Task description is clear and complete"], "steps": [{"id": "understand", "title": "Deep understanding of task and codebase", "prompt": "Analyze the task description...", "requireConfirmation": true}]}
216
+ }
217
+ },
218
+ {
219
+ "name": "workflow_next",
220
+ "description": "Gets the next step guidance based on workflow state",
221
+ "inputSchema": {
222
+ "type": "object",
223
+ "properties": {
224
+ "workflowId": {
225
+ "type": "string",
226
+ "description": "The workflow ID",
227
+ "pattern": "^[a-z0-9-]+$",
228
+ "minLength": 3,
229
+ "maxLength": 64
230
+ },
231
+ "currentStep": {
232
+ "type": "string",
233
+ "description": "Current step ID (optional)",
234
+ "pattern": "^[a-z0-9-]+$",
235
+ "minLength": 3,
236
+ "maxLength": 64
237
+ },
238
+ "completedSteps": {
239
+ "type": "array",
240
+ "description": "Array of completed step IDs",
241
+ "items": {"type": "string", "pattern": "^[a-z0-9-]+$"},
242
+ "uniqueItems": true
243
+ },
244
+ "context": {
245
+ "type": "object",
246
+ "description": "Optional execution context for evaluating step conditions. Can contain variables like taskScope, userExpertise, complexity, etc.",
247
+ "additionalProperties": true
248
+ }
249
+ },
250
+ "required": ["workflowId", "completedSteps"],
251
+ "additionalProperties": false
252
+ },
253
+ "outputSchema": {
254
+ "type": "object",
255
+ "properties": {
256
+ "step": {"type": "object"},
257
+ "guidance": {"type": "object"},
258
+ "isComplete": {"type": "boolean"}
259
+ },
260
+ "required": ["step", "guidance", "isComplete"]
261
+ },
262
+ "examples": {
263
+ "request": {"method": "workflow_next", "params": {"workflowId": "ai-task-implementation", "completedSteps": [], "context": {"taskId": "TASK-123"}}},
264
+ "response": {"step": {"id": "understand", "title": "Understand the task", "prompt": "Analyze the requirements..."}, "guidance": {"prompt": "PREP: ... IMPLEMENT: ... VERIFY: ..."}, "isComplete": false}
265
+ }
266
+ },
267
+ {
268
+ "name": "workflow_validate",
269
+ "description": "Validates step output against workflow requirements",
270
+ "inputSchema": {
271
+ "type": "object",
272
+ "properties": {
273
+ "workflowId": {
274
+ "type": "string",
275
+ "description": "The workflow ID",
276
+ "pattern": "^[a-z0-9-]+$",
277
+ "minLength": 3,
278
+ "maxLength": 64
279
+ },
280
+ "stepId": {
281
+ "type": "string",
282
+ "description": "The step ID to validate",
283
+ "pattern": "^[a-z0-9-]+$",
284
+ "minLength": 3,
285
+ "maxLength": 64
286
+ },
287
+ "output": {
288
+ "type": "string",
289
+ "description": "The step output to validate",
290
+ "minLength": 1
291
+ }
292
+ },
293
+ "required": ["workflowId", "stepId", "output"],
294
+ "additionalProperties": false
295
+ },
296
+ "outputSchema": {
297
+ "type": "object",
298
+ "properties": {
299
+ "valid": {"type": "boolean"},
300
+ "issues": {"type": "array", "items": {"type": "string"}},
301
+ "suggestions": {"type": "array", "items": {"type": "string"}}
302
+ },
303
+ "required": ["valid"]
304
+ },
305
+ "examples": {
306
+ "request": {"method": "workflow_validate", "params": {"workflowId": "ai-task-implementation", "stepId": "understand", "output": "I have analyzed the requirements."}},
307
+ "response": {"valid": true, "issues": [], "suggestions": []}
308
+ }
309
+ }
310
+ ]
311
+ }
312
+ }
313
+ ```
314
+
315
+ ## Error Handling
316
+
317
+ ### MCP Standard Error Codes
318
+
319
+ | Code | Message | Description |
320
+ |------|---------|-------------|
321
+ | -32700 | Parse error | Invalid JSON was received |
322
+ | -32600 | Invalid Request | The JSON sent is not a valid Request object |
323
+ | -32601 | Method not found | The method does not exist |
324
+ | -32602 | Invalid params | Invalid method parameter(s) |
325
+ | -32603 | Internal error | Internal JSON-RPC error |
326
+ | -32000 | Server error | Server-specific error |
327
+ | -32001 | Workflow not found | The specified workflow ID does not exist |
328
+ | -32002 | Invalid workflow | The workflow file is malformed or invalid |
329
+ | -32003 | Step not found | The specified step ID does not exist |
330
+
331
+ ### Error Response Format
332
+
333
+ ```json
334
+ {
335
+ "jsonrpc": "2.0",
336
+ "id": number | string | null,
337
+ "error": {
338
+ "code": number,
339
+ "message": string,
340
+ "data": any
341
+ }
342
+ }
343
+ ```
344
+
345
+ ### Error Response Examples
346
+
347
+ ```json
348
+ // Parse error
349
+ {
350
+ "jsonrpc": "2.0",
351
+ "id": null,
352
+ "error": {
353
+ "code": -32700,
354
+ "message": "Parse error",
355
+ "data": {"details": "Unexpected token in JSON"}
356
+ }
357
+ }
358
+
359
+ // Method not found
360
+ {
361
+ "jsonrpc": "2.0",
362
+ "id": 3,
363
+ "error": {
364
+ "code": -32601,
365
+ "message": "Method not found",
366
+ "data": {"method": "non_existent_tool"}
367
+ }
368
+ }
369
+
370
+ // Invalid params
371
+ {
372
+ "jsonrpc": "2.0",
373
+ "id": 4,
374
+ "error": {
375
+ "code": -32602,
376
+ "message": "Invalid params",
377
+ "data": {"details": "workflowId is required"}
378
+ }
379
+ }
380
+
381
+ // Workflow not found
382
+ {
383
+ "jsonrpc": "2.0",
384
+ "id": 5,
385
+ "error": {
386
+ "code": -32001,
387
+ "message": "Workflow not found",
388
+ "data": {"workflowId": "nonexistent-workflow"}
389
+ }
390
+ }
391
+
392
+ // Step not found
393
+ {
394
+ "jsonrpc": "2.0",
395
+ "id": 6,
396
+ "error": {
397
+ "code": -32003,
398
+ "message": "Step not found",
399
+ "data": {"stepId": "nonexistent-step"}
400
+ }
401
+ }
402
+ ```
403
+
404
+ ## Communication Protocol
405
+
406
+ - **Encoding**: UTF-8
407
+ - **Framing**: One JSON-RPC message per line (newline-delimited)
408
+ - **Transport**: stdio (stdin/stdout)
409
+ - **Buffering**: Each message must be a single line, no embedded newlines
410
+ - **Order**: Messages must be processed in the order received
411
+
412
+ ## Server Lifecycle
413
+
414
+ ### Startup
415
+ - Server starts and waits for `initialize` request
416
+ - No tool calls are processed before initialization
417
+
418
+ ### Shutdown
419
+ - Server should implement a `shutdown` method:
420
+
421
+ ```json
422
+ {
423
+ "jsonrpc": "2.0",
424
+ "id": 99,
425
+ "method": "shutdown",
426
+ "params": {}
427
+ }
428
+ ```
429
+
430
+ - Server responds with:
431
+
432
+ ```json
433
+ {
434
+ "jsonrpc": "2.0",
435
+ "id": 99,
436
+ "result": null
437
+ }
438
+ ```
439
+
440
+ - After responding, the server should exit gracefully
441
+
442
+ ### Keepalive/Heartbeat
443
+ - Not required for stdio transport, but server should handle long periods of inactivity gracefully
444
+
445
+ ### Error Recovery
446
+ - On fatal error, server should emit an error response and exit with nonzero status
447
+ - On recoverable error, server should emit an error response and continue processing
448
+
449
+ ## Complete Handshake Example
450
+
451
+ ```json
452
+ // 1. Client sends initialize request
453
+ {
454
+ "jsonrpc": "2.0",
455
+ "id": 1,
456
+ "method": "initialize",
457
+ "params": {
458
+ "protocolVersion": "2024-11-05",
459
+ "capabilities": {"tools": {}},
460
+ "clientInfo": {"name": "claude-desktop", "version": "1.0.0"}
461
+ }
462
+ }
463
+
464
+ // 2. Server responds with capabilities
465
+ {
466
+ "jsonrpc": "2.0",
467
+ "id": 1,
468
+ "result": {
469
+ "protocolVersion": "2024-11-05",
470
+ "capabilities": {"tools": {"listChanged": false, "notifyProgress": false}, "resources": {"listChanged": false}},
471
+ "serverInfo": {"name": "workflowlookup", "version": "1.0.0", "description": "Workflow Orchestration System MCP Server"}
472
+ }
473
+ }
474
+
475
+ // 3. Client requests tool list
476
+ {
477
+ "jsonrpc": "2.0",
478
+ "id": 2,
479
+ "method": "tools/list",
480
+ "params": {}
481
+ }
482
+
483
+ // 4. Server provides tool schemas (all tools shown)
484
+ {
485
+ "jsonrpc": "2.0",
486
+ "id": 2,
487
+ "result": {
488
+ "tools": [
489
+ {"name": "workflow_list", ...},
490
+ {"name": "workflow_get", ...},
491
+ {"name": "workflow_next", ...},
492
+ {"name": "workflow_validate", ...}
493
+ ]
494
+ }
495
+ }
496
+
497
+ // 5. Client can now call tools
498
+ {
499
+ "jsonrpc": "2.0",
500
+ "id": 3,
501
+ "method": "workflow_list",
502
+ "params": {}
503
+ }
504
+
505
+ // 6. Server responds with tool result
506
+ {
507
+ "jsonrpc": "2.0",
508
+ "id": 3,
509
+ "result": {
510
+ "workflows": [
511
+ {"id": "ai-task-implementation", "name": "AI Task Prompt Workflow", "description": "Guides through task understanding → planning → implementation → verification", "category": "development", "version": "1.0.0"}
512
+ ]
513
+ }
514
+ }
515
+ ```
516
+
517
+ ## Implementation Requirements
518
+
519
+ ### Server Implementation Checklist
520
+
521
+ - [ ] **Protocol Compliance**
522
+ - Implement JSON-RPC 2.0 message handling
523
+ - Support MCP protocol version `2024-11-05`
524
+ - Handle stdio communication correctly
525
+
526
+ - [ ] **Initialization**
527
+ - Respond to `initialize` requests
528
+ - Provide server capabilities
529
+ - Validate protocol version compatibility
530
+
531
+ - [ ] **Tool Discovery**
532
+ - Implement `tools/list` method
533
+ - Provide complete tool schemas (input/output)
534
+ - Validate tool input parameters
535
+
536
+ - [ ] **Error Handling**
537
+ - Use standard MCP error codes
538
+ - Provide meaningful error messages
539
+ - Include error context in data field
540
+
541
+ ### Testing Requirements
542
+
543
+ - [ ] **Protocol Tests**
544
+ - Test initialization handshake
545
+ - Test tool discovery
546
+ - Test error handling
547
+
548
+ - [ ] **Schema Tests**
549
+ - Validate tool input/output schemas
550
+ - Test parameter validation
551
+ - Test error responses
552
+
553
+ ## Versioning & Compatibility
554
+
555
+ - **Protocol Version**: `2024-11-05`
556
+ - **Specification Version**: 1.0.0
557
+ - The server MUST reject initialization requests with unsupported protocol versions.
558
+ - Backward-incompatible changes will increment the protocol version.
559
+ - Workflows and clients SHOULD specify the minimum compatible server version if applicable.
560
+
561
+ ---
562
+
563
+ ## Conformance
564
+
565
+ An implementation is conformant if it:
566
+ - Implements all required request/response structures as specified
567
+ - Handles all error cases as described
568
+ - Follows the communication, encoding, and framing requirements
569
+ - Passes all protocol and schema tests outlined in this document
570
+
571
+ Non-conformant implementations MUST NOT claim MCP compatibility.
572
+
573
+ ---
574
+
575
+ ## Glossary
576
+
577
+ - **MCP**: Model Context Protocol
578
+ - **Stdio**: Standard input/output (process communication channel)
579
+ - **Tool**: An API method exposed by the MCP server
580
+ - **Handshake**: The initialization exchange between client and server
581
+ - **Capabilities**: Features supported by the client or server, exchanged during initialization
582
+
583
+ ---
584
+
585
+ ## Changelog
586
+
587
+ - **2024-11-05**: Initial version, complete handshake, tool discovery, error handling, and lifecycle specification.
588
+
589
+ ---
590
+
591
+ ## References
592
+
593
+ - [Model Context Protocol](https://modelcontextprotocol.org)
594
+ - [JSON-RPC 2.0 Specification](https://www.jsonrpc.org/specification)
595
+ - [MCP Server Implementation Guide](https://modelcontextprotocol.io/docs/server-implementation)
596
+ - [Workflow API Specification](mcp-api-v1.0.md)
597
+ - [Workflow Schema](workflow.schema.json)
598
+
599
+ ---
600
+
601
+ **Last Updated**: 2024-01-15
602
+ **Specification Version**: 1.0.0
603
+ **MCP Protocol Version**: 2024-11-05