mcp-sequentialthinking-qa
Version:
A QA-focused adaptation of the MCP Sequential Thinking Server to guide tool usage in verification processes
143 lines (142 loc) • 5.57 kB
JavaScript
import { z } from 'zod';
// Define the schema for recommended tools
const recommended_tool_schema = z.object({
tool_name: z.string(),
confidence: z.number().min(0).max(1),
rationale: z.string(),
priority: z.number().int().positive(),
alternatives: z.array(z.string()).optional(),
suggested_inputs: z.record(z.unknown()).optional(),
});
// Define the schema for current step
const step_recommendation_schema = z.object({
step_description: z.string(),
expected_outcome: z.string(),
recommended_tools: z.array(recommended_tool_schema),
next_step_conditions: z.array(z.string()),
});
// Define the main schema for the sequentialthinking_qa tool
export const SEQUENTIAL_THINKING_TOOL = {
name: 'sequentialthinking_qa',
description: 'A tool for QA-focused sequential thinking with tool recommendations for verification tasks',
inputSchema: {
type: 'object',
properties: {
thought: {
type: 'string',
description: 'Your current thinking step in the QA process',
},
next_thought_needed: {
type: 'boolean',
description: 'Whether another thought step is needed',
},
thought_number: {
type: 'integer',
description: 'Current thought number',
},
total_thoughts: {
type: 'integer',
description: 'Estimated total thoughts needed',
},
verification_target: {
type: 'string',
description: "What's being verified (code, config, etc.)",
},
current_step: {
type: 'object',
description: 'Current step recommendation',
properties: {
step_description: {
type: 'string',
description: 'What needs to be done',
},
recommended_tools: {
type: 'array',
description: 'Array of tool recommendations with confidence scores',
items: {
type: 'object',
properties: {
tool_name: {
type: 'string',
description: 'Name of the recommended tool',
},
confidence: {
type: 'number',
description: 'Confidence score (0-1)',
},
rationale: {
type: 'string',
description: 'Why this tool is recommended',
},
priority: {
type: 'integer',
description: 'Priority level (lower is higher priority)',
},
alternatives: {
type: 'array',
description: 'Alternative tools that could be used',
items: {
type: 'string',
},
},
suggested_inputs: {
type: 'object',
description: 'Suggested inputs for the tool',
},
},
required: [
'tool_name',
'confidence',
'rationale',
'priority',
],
},
},
expected_outcome: {
type: 'string',
description: 'What to expect from this step',
},
next_step_conditions: {
type: 'array',
description: 'Conditions for next step',
items: {
type: 'string',
},
},
},
required: [
'step_description',
'recommended_tools',
'expected_outcome',
],
},
previous_steps: {
type: 'array',
description: 'Steps already recommended',
items: {
type: 'object',
},
},
remaining_steps: {
type: 'array',
description: 'High-level descriptions of upcoming steps',
items: {
type: 'string',
},
},
available_client_tools: {
type: 'array',
description: 'Optional: List of tool names available to the calling LLM',
items: {
type: 'string',
},
},
},
required: [
'thought',
'next_thought_needed',
'thought_number',
'total_thoughts',
],
},
};