UNPKG

mcp-sequentialthinking-qa

Version:

A QA-focused adaptation of the MCP Sequential Thinking Server to guide tool usage in verification processes

258 lines (257 loc) 9.7 kB
/** * Process a version verification workflow * This workflow helps verify package versions and compatibility */ export function process_version_verification(params) { // Handle different steps based on thought number switch (params.thought_number) { case 1: return handle_initial_version_check(params); case 2: return handle_documentation_check(params); case 3: return handle_implementation_planning(params); case 4: return handle_validation(params); default: return handle_generic_step(params); } } /** * Initial step: Check installed version */ function handle_initial_version_check(params) { return { ...params, current_step: { step_description: 'Check installed package version', expected_outcome: 'Confirmed package version', recommended_tools: [ { tool_name: 'read_file', confidence: 0.9, rationale: 'Examine package.json to determine installed version', priority: 1, }, { tool_name: 'execute_command', confidence: 0.7, rationale: 'Run npm list or similar command to check installed version', priority: 2, }, ], next_step_conditions: [ 'Version identified', 'Check for breaking changes between versions', ], }, next_thought_needed: true, }; } /** * Second step: Check documentation for the identified version */ function handle_documentation_check(params) { // Simple condition to trigger branching for demonstration if (params.thought_number === 2 && !params.branch_from_thought) { const branch_id = `alternative-docs-${Date.now()}`; // Generate a unique branch ID return { ...params, thought: 'Multiple documentation approaches found (simulated). Branching to explore an alternative.', branch_from_thought: params.thought_number, branch_id: branch_id, next_thought_needed: true, // Update current_step to reflect the branching task current_step: { step_description: 'Explore an alternative documentation approach.', expected_outcome: 'Understanding of an alternative method.', recommended_tools: [ // Recommend tools for exploring alternative docs { tool_name: 'browser_navigate', confidence: 0.9, rationale: 'Navigate to alternative documentation', priority: 1, }, { tool_name: 'use_mcp_tool', confidence: 0.8, rationale: 'Search for alternative documentation', priority: 2, alternatives: [ 'mcp-omnisearch:brave_search', 'mcp-omnisearch:kagi_search', ], }, ], next_step_conditions: [ 'Alternative approach understood', 'Ready to compare or implement', ], }, }; } return { ...params, current_step: { step_description: 'Retrieve current documentation for the identified version', expected_outcome: 'Understanding of correct patterns and APIs', recommended_tools: [ { tool_name: 'use_mcp_tool', confidence: 0.9, rationale: 'Search for official documentation for the identified version using an MCP search tool', priority: 1, alternatives: [ 'mcp-omnisearch:brave_search', 'mcp-omnisearch:kagi_search', ], suggested_inputs: { server_name: 'mcp-omnisearch', tool_name: 'brave_search', arguments: { query: 'package version documentation' }, }, }, { tool_name: 'browser_navigate', confidence: 0.8, rationale: 'Navigate to official documentation sites', priority: 2, }, { tool_name: 'browser_action', confidence: 0.7, rationale: 'Browse documentation site for detailed information', priority: 3, }, ], next_step_conditions: [ 'Current patterns identified', 'Breaking changes noted', ], }, next_thought_needed: true, }; } /** * Third step: Plan implementation based on version information */ function handle_implementation_planning(params) { return { ...params, current_step: { step_description: 'Design implementation approach for the correct version', expected_outcome: 'Version-appropriate implementation plan', recommended_tools: [ { tool_name: 'write_to_file', confidence: 0.8, rationale: 'Create appropriate configuration or implementation files', priority: 1, }, { tool_name: 'replace_in_file', confidence: 0.7, rationale: 'Update existing files to use correct version patterns', priority: 2, }, ], next_step_conditions: [ 'Implementation designed', 'Ready for validation', ], }, next_thought_needed: true, }; } /** * Fourth step: Validate the implementation */ function handle_validation(params) { // Simple condition to trigger revision for demonstration if (params.thought_number === 4 && !params.is_revision) { return { ...params, thought: 'Validation failed (simulated). Revising implementation planning.', is_revision: true, revises_thought: 3, // Suggest revising the Implementation Planning step next_thought_needed: true, // Update current_step to reflect the revision task current_step: { step_description: 'Revise implementation based on simulated validation errors.', expected_outcome: 'Implementation errors resolved.', recommended_tools: [ // Recommend tools for debugging and fixing { tool_name: 'read_file', confidence: 0.9, rationale: 'Examine error logs or code', priority: 1, }, { tool_name: 'replace_in_file', confidence: 0.9, rationale: 'Correct implementation errors', priority: 1, }, ], next_step_conditions: [ 'Implementation errors corrected', 'Ready to re-validate', ], }, }; } // If validation succeeds (or not triggering revision), the workflow is complete return { ...params, current_step: { step_description: 'Test implementation with installed version', expected_outcome: 'Confirmed working implementation', recommended_tools: [ { tool_name: 'execute_command', confidence: 0.9, rationale: 'Run build process or tests to verify implementation', priority: 1, }, { tool_name: 'browser_action', confidence: 0.7, rationale: 'Visually verify implementation if applicable', priority: 2, }, ], next_step_conditions: [], }, next_thought_needed: false, }; } /** * Generic step for any additional steps beyond the standard workflow */ function handle_generic_step(params) { return { ...params, current_step: { step_description: `Additional version verification step ${params.thought_number}`, expected_outcome: 'Further verification of version compatibility', recommended_tools: [ { tool_name: 'execute_command', confidence: 0.8, rationale: 'Run additional verification commands', priority: 1, }, { tool_name: 'read_file', confidence: 0.7, rationale: 'Examine additional files for version compatibility', priority: 2, }, ], next_step_conditions: ['Additional verification complete'], }, next_thought_needed: params.thought_number < params.total_thoughts, }; }