mcp-sequentialthinking-qa
Version:
A QA-focused adaptation of the MCP Sequential Thinking Server to guide tool usage in verification processes
225 lines (224 loc) • 8.3 kB
JavaScript
/**
* Process a compatibility check workflow
* This workflow helps verify compatibility between different versions or components
*/
export function process_compatibility_check(params) {
// Handle different steps based on thought number
switch (params.thought_number) {
case 1:
return handle_initial_compatibility_assessment(params);
case 2:
return handle_breaking_changes_research(params);
case 3:
return handle_compatibility_implementation(params);
case 4:
return handle_compatibility_testing(params);
default:
return handle_generic_step(params);
}
}
/**
* Initial step: Assess compatibility requirements
*/
function handle_initial_compatibility_assessment(params) {
return {
...params,
current_step: {
step_description: 'Assess compatibility requirements and constraints',
expected_outcome: 'Clear understanding of compatibility needs',
recommended_tools: [
{
tool_name: 'read_file',
confidence: 0.9,
rationale: 'Examine configuration and dependency files',
priority: 1,
},
{
tool_name: 'search_files',
confidence: 0.8,
rationale: 'Find usage patterns across the codebase',
priority: 2,
},
],
next_step_conditions: [
'Compatibility requirements identified',
'Component relationships understood',
],
},
next_thought_needed: true,
};
}
/**
* Second step: Research breaking changes
*/
function handle_breaking_changes_research(params) {
// Simple condition to trigger branching for demonstration
if (params.thought_number === 2 && !params.branch_from_thought) {
const branch_id = `alternative-compat-${Date.now()}`; // Generate a unique branch ID
return {
...params,
thought: 'Multiple compatibility solutions 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 compatibility solution.',
expected_outcome: 'Understanding of an alternative method.',
recommended_tools: [
// Recommend tools for exploring alternative solutions
{
tool_name: 'use_mcp_tool',
confidence: 0.9,
rationale: 'Search for details on the alternative solution',
priority: 1,
alternatives: [
'mcp-omnisearch:brave_search',
'mcp-omnisearch:kagi_search',
],
},
{
tool_name: 'read_file',
confidence: 0.8,
rationale: 'Examine example implementations',
priority: 2,
},
],
next_step_conditions: [
'Alternative solution understood',
'Ready to compare or implement',
],
},
};
}
return {
...params,
current_step: {
step_description: 'Research breaking changes and compatibility issues',
expected_outcome: 'Comprehensive list of potential compatibility issues',
recommended_tools: [
{
tool_name: 'use_mcp_tool',
confidence: 0.9,
rationale: 'Search for breaking changes documentation and migration guides 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: 'breaking changes compatibility' },
},
},
{
tool_name: 'browser_navigate',
confidence: 0.8,
rationale: 'Navigate to relevant documentation sites',
priority: 2,
},
{
tool_name: 'browser_action',
confidence: 0.7,
rationale: 'Browse release notes and documentation for compatibility information',
priority: 3,
},
],
next_step_conditions: [
'Breaking changes identified',
'Compatibility solutions researched',
],
},
next_thought_needed: true,
};
}
/**
* Third step: Implement compatibility solutions
*/
function handle_compatibility_implementation(params) {
return {
...params,
current_step: {
step_description: 'Implement compatibility solutions',
expected_outcome: 'Code updated to ensure compatibility',
recommended_tools: [
{
tool_name: 'replace_in_file',
confidence: 0.9,
rationale: 'Update code to address compatibility issues',
priority: 1,
},
{
tool_name: 'write_to_file',
confidence: 0.7,
rationale: 'Create compatibility layers or adapters if needed',
priority: 2,
},
],
next_step_conditions: [
'Compatibility solutions implemented',
'Ready for testing',
],
},
next_thought_needed: true,
};
}
/**
* Fourth step: Test compatibility
*/
function handle_compatibility_testing(params) {
return {
...params,
current_step: {
step_description: 'Test compatibility across required environments',
expected_outcome: 'Verified compatibility in all required contexts',
recommended_tools: [
{
tool_name: 'execute_command',
confidence: 0.9,
rationale: 'Run tests in different environments or with different versions',
priority: 1,
},
{
tool_name: 'browser_action',
confidence: 0.7,
rationale: 'Verify visual or interactive compatibility 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 compatibility check step ${params.thought_number}`,
expected_outcome: 'Further verification of compatibility',
recommended_tools: [
{
tool_name: 'execute_command',
confidence: 0.8,
rationale: 'Run additional compatibility tests',
priority: 1,
},
{
tool_name: 'read_file',
confidence: 0.7,
rationale: 'Examine additional files for compatibility issues',
priority: 2,
},
],
next_step_conditions: [
'Additional compatibility verification complete',
],
},
next_thought_needed: params.thought_number < params.total_thoughts,
};
}