@riotprompt/riotplan 1.0.4 → 1.0.5

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.
@@ -0,0 +1,211 @@
1
+ # MCP Elicitation Notes
2
+
3
+ ## Understanding MCP Elicitation
4
+
5
+ ### What It Is
6
+
7
+ MCP elicitation (introduced in the 2025-06-18 specification) is a protocol feature that allows **servers** to request structured data from users dynamically during interactions. It uses JSON schemas to validate responses and enables interactive workflows.
8
+
9
+ ### How It Works
10
+
11
+ Servers send `elicitation/create` requests to clients:
12
+
13
+ ```json
14
+ {
15
+ "jsonrpc": "2.0",
16
+ "id": 1,
17
+ "method": "elicitation/create",
18
+ "params": {
19
+ "message": "Please provide your GitHub username",
20
+ "requestedSchema": {
21
+ "type": "object",
22
+ "properties": {
23
+ "name": { "type": "string" }
24
+ },
25
+ "required": ["name"]
26
+ }
27
+ }
28
+ }
29
+ ```
30
+
31
+ Clients respond with:
32
+
33
+ ```json
34
+ {
35
+ "jsonrpc": "2.0",
36
+ "id": 1,
37
+ "result": {
38
+ "action": "accept",
39
+ "content": { "name": "octocat" }
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### Key Limitation for Prompts
45
+
46
+ **Prompts cannot directly trigger elicitation requests.** Prompts are static text templates that return messages to inject into the conversation. They don't have the ability to make protocol-level requests.
47
+
48
+ Only **tools** and **resources** can trigger elicitation by making `elicitation/create` requests during their execution.
49
+
50
+ ## Our Approach: Prompt Arguments + Model Instructions
51
+
52
+ Since prompts can't trigger elicitation directly, we use a hybrid approach:
53
+
54
+ ### 1. Define Prompt Arguments
55
+
56
+ ```typescript
57
+ {
58
+ name: 'create_plan',
59
+ description: 'Create a new plan with AI-generated steps for a complex task',
60
+ arguments: [
61
+ {
62
+ name: 'code',
63
+ description: 'Plan code/identifier',
64
+ required: false,
65
+ },
66
+ {
67
+ name: 'description',
68
+ description: 'Detailed description of what to accomplish',
69
+ required: false,
70
+ },
71
+ {
72
+ name: 'directory',
73
+ description: 'Parent directory where the plan should be created',
74
+ required: false,
75
+ },
76
+ ],
77
+ }
78
+ ```
79
+
80
+ ### 2. Template Variable Substitution
81
+
82
+ The prompt template uses `${code}`, `${description}`, etc.:
83
+
84
+ ```markdown
85
+ ## Step 1: Review Provided Information
86
+
87
+ Check what information has already been provided:
88
+ - **code**: ${code}
89
+ - **description**: ${description}
90
+ - **directory**: ${directory}
91
+ ```
92
+
93
+ When arguments are missing, we substitute with markers like `[code]`, `[description]`:
94
+
95
+ ```typescript
96
+ if (!filledArgs.code) filledArgs.code = '[code]';
97
+ if (!filledArgs.description) filledArgs.description = '[description]';
98
+ ```
99
+
100
+ ### 3. Model Instructions
101
+
102
+ The prompt explicitly tells the model to check for these markers:
103
+
104
+ ```markdown
105
+ ## Step 2: Gather Missing Information
106
+
107
+ For any information marked as "[code]", "[description]", "[directory]",
108
+ ask the user to provide it:
109
+
110
+ 1. **Plan Code** (if missing) - Ask for a short identifier
111
+ 2. **Plan Description** (if missing) - Ask for a detailed description
112
+ 3. **Target Directory** (if missing) - Ask where to create the plan
113
+ ```
114
+
115
+ ## Benefits of This Approach
116
+
117
+ ### Client-Side Elicitation (Future)
118
+
119
+ MCP clients could potentially:
120
+ 1. See that `create_plan` has arguments
121
+ 2. Elicit those arguments from the user BEFORE invoking the prompt
122
+ 3. Pass the collected values when calling the prompt
123
+
124
+ This would provide a form-based UI for gathering information upfront.
125
+
126
+ ### Model-Side Fallback (Current)
127
+
128
+ If the client doesn't elicit arguments:
129
+ 1. The prompt is invoked with missing arguments
130
+ 2. Template substitution marks them as `[code]`, `[description]`, etc.
131
+ 3. The model sees these markers and knows to ask the user
132
+ 4. The model uses natural language to gather information
133
+
134
+ ### Progressive Enhancement
135
+
136
+ - Works today with explicit model instructions
137
+ - Can be enhanced in the future if clients add argument elicitation
138
+ - Provides clear structure for what information is needed
139
+
140
+ ## Alternative: Tool-Based Elicitation
141
+
142
+ Another approach would be to create a tool that triggers elicitation:
143
+
144
+ ```typescript
145
+ {
146
+ name: 'riotplan_elicit_plan_info',
147
+ description: 'Gather plan information from user',
148
+ inputSchema: {
149
+ type: 'object',
150
+ properties: {}
151
+ }
152
+ }
153
+
154
+ async function executeElicitPlanInfo(args, context) {
155
+ // Make elicitation/create request
156
+ const result = await context.elicit({
157
+ message: "Please provide plan information",
158
+ requestedSchema: {
159
+ type: "object",
160
+ properties: {
161
+ code: { type: "string", description: "Plan code" },
162
+ description: { type: "string", description: "What to accomplish" },
163
+ directory: { type: "string", description: "Where to create plan" }
164
+ },
165
+ required: ["code", "description"]
166
+ }
167
+ });
168
+
169
+ return result;
170
+ }
171
+ ```
172
+
173
+ However, this has drawbacks:
174
+ - Requires the model to know to call this tool
175
+ - Adds an extra step (call tool, then call create)
176
+ - Less integrated with the prompt workflow
177
+
178
+ ## Recommendation
179
+
180
+ The **prompt arguments + model instructions** approach is the best solution because:
181
+
182
+ 1. **Works today** - Model instructions ensure it works immediately
183
+ 2. **Future-proof** - Can be enhanced if clients add argument elicitation
184
+ 3. **Clear structure** - Arguments document what's needed
185
+ 4. **Flexible** - Users can provide info upfront OR be prompted
186
+ 5. **Natural** - Model asks in conversational way, not just forms
187
+
188
+ ## Implementation Status
189
+
190
+ ✅ Added prompt arguments to `create_plan`
191
+ ✅ Added template variable substitution
192
+ ✅ Added explicit model instructions
193
+ ✅ Rebuilt MCP server with changes
194
+ ⏳ Waiting for client support for argument elicitation (future enhancement)
195
+
196
+ ## Testing
197
+
198
+ To test the current implementation:
199
+
200
+ 1. Invoke `create_plan` prompt without arguments
201
+ 2. Model should see `[code]`, `[description]`, `[directory]` markers
202
+ 3. Model should ask user for missing information
203
+ 4. Model should use `riotplan_create` tool with collected info
204
+
205
+ To test future client elicitation (when supported):
206
+
207
+ 1. Client sees `create_plan` has arguments
208
+ 2. Client shows form to collect: code, description, directory
209
+ 3. Client invokes prompt with collected values
210
+ 4. Model sees actual values, not markers
211
+ 5. Model proceeds directly to creating the plan
package/MCP-FIXES.md ADDED
@@ -0,0 +1,50 @@
1
+ # MCP Implementation Fixes Needed
2
+
3
+ ## TypeScript Errors to Fix
4
+
5
+ ### 1. Plan.path -> Plan.metadata.path
6
+ - Plan type doesn't have `path` property
7
+ - Use `plan.metadata.path` instead
8
+
9
+ ### 2. PlanStep.file -> PlanStep.filename
10
+ - PlanStep has `filename` not `file`
11
+
12
+ ### 3. PlanState property names
13
+ - `lastCompleted` -> `lastCompletedStep`
14
+ - `lastUpdated` -> `lastUpdatedAt`
15
+
16
+ ### 4. PlanMetadata property names
17
+ - `created` -> `createdAt`
18
+
19
+ ### 5. Blocker[] and Issue[] types
20
+ - StatusResource expects `string[]` but Plan has `Blocker[]` and `Issue[]`
21
+ - Need to convert to strings or update types
22
+
23
+ ### 6. ValidateOptions
24
+ - `fix` property doesn't exist
25
+ - Need to check actual API
26
+
27
+ ### 7. CreatePlanResult
28
+ - Doesn't have `steps` property
29
+ - Check actual return type
30
+
31
+ ### 8. GenerationContext
32
+ - Missing `planName` property
33
+ - Need to provide it
34
+
35
+ ### 9. MCP Build Externals
36
+ - Need to add execution provider packages to externals in build-mcp.js
37
+
38
+ ## Files to Update
39
+
40
+ 1. `src/mcp/resources/plan.ts` - Fix property names
41
+ 2. `src/mcp/resources/status.ts` - Fix property names and types
42
+ 3. `src/mcp/resources/step.ts` - Fix property names
43
+ 4. `src/mcp/resources/steps.ts` - Fix property names
44
+ 5. `src/mcp/tools/status.ts` - Fix property names
45
+ 6. `src/mcp/tools/step.ts` - Fix property names
46
+ 7. `src/mcp/tools/create.ts` - Fix return type handling
47
+ 8. `src/mcp/tools/generate.ts` - Fix GenerationContext
48
+ 9. `src/mcp/tools/validate.ts` - Fix options
49
+ 10. `src/mcp/types.ts` - Update StatusResource type
50
+ 11. `scripts/build-mcp.js` - Add externals
@@ -0,0 +1,207 @@
1
+ # MCP Prompt Fixes
2
+
3
+ ## Problem Summary
4
+
5
+ The MCP prompts in riotplan were written as user documentation rather than as instructions to the AI model. This caused the model to:
6
+
7
+ 1. **Shell out to CLI commands** instead of using MCP tools
8
+ 2. **Not ask about directory placement** for plans
9
+ 3. **Treat prompts as documentation** rather than workflow instructions
10
+
11
+ ## Root Cause
12
+
13
+ The prompt markdown files (`create_plan.md`, `execute_step.md`, `track_progress.md`) were structured as:
14
+ - User-facing documentation explaining how to use the tools
15
+ - Examples showing CLI commands and tool calls
16
+ - Tips and best practices for users
17
+
18
+ When these prompts were invoked by the model, it interpreted them as documentation to reference rather than instructions to follow.
19
+
20
+ ## Solution
21
+
22
+ Rewrote all three prompt files to be **instructions TO the model** rather than documentation FOR users:
23
+
24
+ ### Key Changes
25
+
26
+ 1. **Direct Instructions**: Changed from "Users should..." to "You should..."
27
+ 2. **Explicit Tool Usage**: Added clear instructions to use MCP tools, not shell commands
28
+ 3. **Step-by-Step Workflows**: Provided explicit steps the model should follow
29
+ 4. **Directory Guidance**: Added explicit step to ask user about directory placement
30
+ 5. **Clear Examples**: Showed the model exactly what tool calls to make
31
+
32
+ ### Files Modified
33
+
34
+ #### `src/mcp/prompts/create_plan.md`
35
+
36
+ **Before:**
37
+ ```markdown
38
+ ## Workflow Steps
39
+
40
+ 1. **Define Plan Details**
41
+ - Choose a plan code (short identifier, e.g., "auth-system")
42
+ - Write a clear, detailed description of what you want to accomplish
43
+ ```
44
+
45
+ **After:**
46
+ ```markdown
47
+ ## Step 1: Gather Information
48
+
49
+ First, ask the user for the following information if not already provided:
50
+
51
+ 1. **Plan Code** - A short identifier (e.g., "auth-system", "dark-mode", "refactor-db")
52
+ 2. **Plan Description** - A clear, detailed description of what they want to accomplish
53
+ 3. **Target Directory** - Where to create the plan. Suggest using a `plans/` directory if one exists, or ask if they want to create one. Default to current directory if they don't specify.
54
+ ```
55
+
56
+ Key additions:
57
+ - Explicit instruction to ask about directory
58
+ - Clear guidance on what to suggest
59
+ - Direct instructions to use `riotplan_create` MCP tool
60
+
61
+ #### `src/mcp/prompts/execute_step.md`
62
+
63
+ **Before:**
64
+ ```markdown
65
+ ## Workflow Steps
66
+
67
+ 1. **Check Plan Status**
68
+ - Run `riotplan_status` to see current state
69
+ - Verify prerequisites are met
70
+ ```
71
+
72
+ **After:**
73
+ ```markdown
74
+ ## Step 1: Check Plan Status
75
+
76
+ Use the `riotplan_status` tool to check the current plan state:
77
+
78
+ ```
79
+ {
80
+ "path": "${path}",
81
+ "verbose": false
82
+ }
83
+ ```
84
+
85
+ This will show you:
86
+ - Current step number
87
+ - Progress percentage
88
+ ```
89
+
90
+ Key changes:
91
+ - Direct instructions on which tool to call
92
+ - Exact parameter format
93
+ - Clear explanation of what the tool returns
94
+
95
+ #### `src/mcp/prompts/track_progress.md`
96
+
97
+ Similar transformation from documentation to instructions.
98
+
99
+ ## Important Guidelines Added
100
+
101
+ All prompts now include:
102
+
103
+ ```markdown
104
+ ## Important Guidelines
105
+
106
+ - **Always use MCP tools** - Never shell out to CLI commands
107
+ - **Ask about directory** - Don't assume where the plan should be created
108
+ - **Be specific** - Encourage detailed descriptions for better plan generation
109
+ ```
110
+
111
+ ## Testing
112
+
113
+ After rebuilding with `npm run build`, the updated prompts are now available in:
114
+ - `dist/mcp/prompts/create_plan.md`
115
+ - `dist/mcp/prompts/execute_step.md`
116
+ - `dist/mcp/prompts/track_progress.md`
117
+
118
+ The MCP server loads these files at runtime and sends them to the model when a prompt is invoked.
119
+
120
+ ## Expected Behavior
121
+
122
+ When a user invokes the `create_plan` prompt, the model should now:
123
+
124
+ 1. Ask the user for plan details including directory placement
125
+ 2. Suggest using a `plans/` directory
126
+ 3. Use the `riotplan_create` MCP tool (not shell commands)
127
+ 4. Follow up with `riotplan_status` and `riotplan_validate` tools
128
+ 5. Inform the user the plan is ready for execution
129
+
130
+ ## Elicitation Support (Added)
131
+
132
+ After the initial fixes, I added support for MCP prompt arguments to enable better parameter gathering:
133
+
134
+ ### What is MCP Elicitation?
135
+
136
+ MCP elicitation is a protocol feature that allows servers to request structured data from users dynamically. However, **prompts themselves cannot directly trigger elicitation** - they're static text templates.
137
+
138
+ ### Our Approach
139
+
140
+ Instead of trying to make prompts trigger elicitation (which isn't possible), we:
141
+
142
+ 1. **Added prompt arguments** to `create_plan`:
143
+ - `code` - Plan identifier
144
+ - `description` - What to accomplish
145
+ - `directory` - Where to create the plan
146
+ - `steps` - Number of steps (optional)
147
+
148
+ 2. **Template variable substitution**: The prompt template uses `${code}`, `${description}`, etc., which get replaced with either:
149
+ - The provided argument value, OR
150
+ - `[code]`, `[description]`, etc. if missing
151
+
152
+ 3. **Explicit instructions**: The prompt tells the model to check for `[code]`, `[description]`, etc. markers and ask the user for missing information.
153
+
154
+ ### Benefits
155
+
156
+ - **Client-side elicitation**: MCP clients (like Cursor) can see the prompt arguments and potentially elicit them before invoking the prompt
157
+ - **Model-side fallback**: If arguments aren't provided, the model sees `[code]` markers and knows to ask the user
158
+ - **Better UX**: Users can provide information upfront OR be prompted for it
159
+
160
+ ### Code Changes
161
+
162
+ #### `src/mcp/prompts/index.ts`
163
+
164
+ Added arguments to the `create_plan` prompt definition:
165
+
166
+ ```typescript
167
+ {
168
+ name: 'create_plan',
169
+ description: 'Create a new plan with AI-generated steps for a complex task',
170
+ arguments: [
171
+ {
172
+ name: 'code',
173
+ description: 'Plan code/identifier (e.g., "auth-system", "dark-mode")',
174
+ required: false,
175
+ },
176
+ // ... more arguments
177
+ ],
178
+ }
179
+ ```
180
+
181
+ Updated `getPrompt()` to mark missing arguments with `[code]`, `[description]`, etc.
182
+
183
+ #### `src/mcp/prompts/create_plan.md`
184
+
185
+ Added Step 1 to review provided information:
186
+
187
+ ```markdown
188
+ ## Step 1: Review Provided Information
189
+
190
+ Check what information has already been provided as prompt arguments:
191
+ - **code**: ${code}
192
+ - **description**: ${description}
193
+ - **directory**: ${directory}
194
+ - **steps**: ${steps}
195
+
196
+ ## Step 2: Gather Missing Information
197
+
198
+ For any information marked as "[code]", "[description]", "[directory]", or "[steps]", ask the user to provide it:
199
+ ```
200
+
201
+ ## Next Steps
202
+
203
+ 1. Test the updated prompts with Cursor
204
+ 2. Verify the model now asks about directory placement
205
+ 3. Verify the model uses MCP tools instead of shell commands
206
+ 4. Test if Cursor's MCP client elicits prompt arguments before invoking the prompt
207
+ 5. Consider adding similar explicit instructions to other MCP servers (riotdoc, riotprompt)
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Framework for long-lived, stateful AI workflows (plans).
4
4
 
5
+ **Now available as an MCP server!** Integrate with Cursor and other AI assistants - see [MCP Integration](#mcp-integration) below.
6
+
5
7
  ## What is a Plan?
6
8
 
7
9
  A **plan** is a structured way to manage multi-step AI-assisted tasks that:
@@ -356,6 +358,74 @@ _No issues encountered._
356
358
  - `@riotprompt/execution` - LLM provider interfaces
357
359
  - `@riotprompt/riotplan-commands-*` - Command packages (plan, status, step, feedback)
358
360
 
361
+ ## MCP Integration
362
+
363
+ RiotPlan is available as an MCP (Model Context Protocol) server, allowing AI assistants like Cursor to manage plans directly.
364
+
365
+ ### Setup
366
+
367
+ Add to your Cursor MCP settings (`~/.cursor/mcp.json`):
368
+
369
+ ```json
370
+ {
371
+ "mcpServers": {
372
+ "riotplan": {
373
+ "command": "npx",
374
+ "args": ["-y", "@riotprompt/riotplan", "riotplan-mcp"]
375
+ }
376
+ }
377
+ }
378
+ ```
379
+
380
+ ### MCP Tools
381
+
382
+ - **`riotplan_create`** - Create new plans with AI-generated steps
383
+ - **`riotplan_status`** - Show plan status and progress
384
+ - **`riotplan_step_list`** - List all steps
385
+ - **`riotplan_step_start`** - Mark step as started
386
+ - **`riotplan_step_complete`** - Mark step as completed
387
+ - **`riotplan_step_add`** - Add new steps dynamically
388
+ - **`riotplan_validate`** - Validate plan structure
389
+ - **`riotplan_generate`** - Generate plan content with AI
390
+
391
+ ### MCP Resources
392
+
393
+ Read-only access to plan data:
394
+
395
+ - `riotplan://plan/{path}` - Plan metadata and structure
396
+ - `riotplan://status/{path}` - Current status and progress
397
+ - `riotplan://steps/{path}` - List of all steps
398
+ - `riotplan://step/{path}?number={n}` - Specific step content
399
+
400
+ ### MCP Prompts
401
+
402
+ Workflow templates for common tasks:
403
+
404
+ - **`create_plan`** - Guided plan creation workflow
405
+ - **`execute_step`** - Step execution workflow with status tracking
406
+ - **`track_progress`** - Progress monitoring and status updates
407
+
408
+ ### Example MCP Usage
409
+
410
+ ```typescript
411
+ // AI assistant creates a plan
412
+ riotplan_create({
413
+ code: "user-auth",
414
+ description: "Implement JWT-based authentication",
415
+ steps: 6
416
+ })
417
+
418
+ // Check status
419
+ riotplan_status({ path: "./user-auth" })
420
+
421
+ // Start and complete steps
422
+ riotplan_step_start({ path: "./user-auth", step: 1 })
423
+ // ... do the work ...
424
+ riotplan_step_complete({ path: "./user-auth", step: 1 })
425
+ ```
426
+
427
+ See [guide/mcp.md](./guide/mcp.md) for detailed MCP documentation.
428
+
359
429
  ## Philosophy
360
430
 
361
431
  Plans bridge the gap between:
@@ -374,5 +444,3 @@ A plan provides structure for complex, iterative AI-assisted work where:
374
444
  Apache-2.0
375
445
 
376
446
  <!-- v1.0.0 -->
377
-
378
- TEST