mcp-sequentialthinking-qa
Version:
A QA-focused adaptation of the MCP Sequential Thinking Server to guide tool usage in verification processes
202 lines (201 loc) • 7 kB
JavaScript
/**
* Process a test workflow
* This workflow helps test the sequential thinking QA system
*/
export function process_test_workflow(params) {
// Handle different steps based on thought number
switch (params.thought_number) {
case 1:
return handle_initial_test_step(params);
case 2:
return handle_second_test_step(params);
case 3:
return handle_third_test_step(params);
case 4:
return handle_final_test_step(params);
default:
return handle_generic_step(params);
}
}
/**
* Initial step: Set up the test
*/
function handle_initial_test_step(params) {
// Simple condition to trigger branching for demonstration
if (params.thought_number === 1 && !params.branch_from_thought) {
const branch_id = `alternative-test-${Date.now()}`; // Generate a unique branch ID
return {
...params,
thought: 'Multiple testing approaches identified (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 testing approach.',
expected_outcome: 'Understanding of an alternative method.',
recommended_tools: [
// Recommend tools for exploring alternative approaches
{
tool_name: 'use_mcp_tool',
confidence: 0.9,
rationale: 'Search for details on the alternative approach',
priority: 1,
alternatives: [
'mcp-omnisearch:brave_search',
'mcp-omnisearch:kagi_search',
],
},
{
tool_name: 'read_file',
confidence: 0.8,
rationale: 'Examine documentation or examples',
priority: 2,
},
],
next_step_conditions: [
'Alternative approach understood',
'Ready to compare or implement',
],
},
};
}
return {
...params,
current_step: {
step_description: 'Set up the test environment',
expected_outcome: 'Test environment ready for verification',
recommended_tools: [
{
tool_name: 'read_file',
confidence: 0.9,
rationale: 'Examine configuration files to understand test requirements',
priority: 1,
},
{
tool_name: 'execute_command',
confidence: 0.8,
rationale: 'Run setup commands to prepare test environment',
priority: 2,
},
],
next_step_conditions: [
'Test environment configured',
'Test parameters identified',
],
},
next_thought_needed: true,
};
}
/**
* Second step: Execute the test
*/
function handle_second_test_step(params) {
return {
...params,
current_step: {
step_description: 'Execute the test cases',
expected_outcome: 'Test results collected',
recommended_tools: [
{
tool_name: 'execute_command',
confidence: 0.9,
rationale: 'Run test commands to execute test cases',
priority: 1,
},
{
tool_name: 'browser_action',
confidence: 0.7,
rationale: 'Interact with web interface for UI tests if applicable',
priority: 2,
},
],
next_step_conditions: ['Tests executed', 'Results collected'],
},
next_thought_needed: true,
};
}
/**
* Third step: Analyze test results
*/
function handle_third_test_step(params) {
return {
...params,
current_step: {
step_description: 'Analyze test results',
expected_outcome: 'Test results interpreted and issues identified',
recommended_tools: [
{
tool_name: 'read_file',
confidence: 0.9,
rationale: 'Examine test output files to analyze results',
priority: 1,
},
{
tool_name: 'search_files',
confidence: 0.8,
rationale: 'Search for patterns in test logs',
priority: 2,
},
],
next_step_conditions: ['Results analyzed', 'Issues identified'],
},
next_thought_needed: true,
};
}
/**
* Fourth step: Report test results
*/
function handle_final_test_step(params) {
return {
...params,
current_step: {
step_description: 'Report test results',
expected_outcome: 'Comprehensive test report generated',
recommended_tools: [
{
tool_name: 'write_to_file',
confidence: 0.9,
rationale: 'Create test report document',
priority: 1,
},
{
tool_name: 'execute_command',
confidence: 0.7,
rationale: 'Generate test summary or metrics',
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 test step ${params.thought_number}`,
expected_outcome: 'Further test verification',
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 verification',
priority: 2,
},
],
next_step_conditions: ['Additional verification complete'],
},
next_thought_needed: params.thought_number < params.total_thoughts,
};
}