From 60211a0c48eccbd1f734840c7c9347cbc082903c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=7BAI=7Df=20D=2E=20M=C3=BCller?= Date: Thu, 10 Jul 2025 13:46:16 +0200 Subject: [PATCH 1/3] Add get_tool_info handler implementation Implements comprehensive tool information handler following existing patterns: - Extends BaseToolHandler with proper error handling and logging - Provides detailed information about all available tools and workflows - Includes core concepts, usage guidelines, and current workflow state - Follows same pattern as list-workflows.ts for consistency - Returns structured JSON response for easy parsing by AI assistants Addresses Issue #24 requirements for better tool discoverability. --- src/server/tool-handlers/get-tool-info.ts | 232 ++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 src/server/tool-handlers/get-tool-info.ts diff --git a/src/server/tool-handlers/get-tool-info.ts b/src/server/tool-handlers/get-tool-info.ts new file mode 100644 index 00000000..fe2c8fc8 --- /dev/null +++ b/src/server/tool-handlers/get-tool-info.ts @@ -0,0 +1,232 @@ +/** + * Get Tool Info Handler + * + * Provides comprehensive information about the responsible-vibe-mcp development + * workflow tools for better tool discoverability and AI integration. + */ + +import { z } from 'zod'; +import { BaseToolHandler } from './base-tool-handler.js'; +import { ServerContext } from '../types.js'; +import { createLogger } from '../../logger.js'; + +const logger = createLogger('GetToolInfoHandler'); + +/** + * Schema for get_tool_info tool arguments + */ +const GetToolInfoArgsSchema = z.object({ + // No input parameters needed +}); + +type GetToolInfoArgs = z.infer; + +/** + * Tool information structure + */ +interface ToolInfo { + name: string; + description: string; + parameters: string[]; + schema?: { + required: string[]; + optional: string[]; + }; +} + +/** + * Workflow information structure + */ +interface WorkflowInfo { + name: string; + displayName: string; + description: string; + phases?: string[]; +} + +/** + * Complete tool information response + */ +interface GetToolInfoResponse { + tool_name: string; + version: string; + purpose: string; + description: string; + + available_tools: ToolInfo[]; + available_workflows: WorkflowInfo[]; + + core_concepts: { + phase_management: string; + plan_file_tracking: string; + conversation_context: string; + workflow_guidance: string; + }; + + usage_guidelines: { + required_pattern: string; + phase_transitions: string; + context_requirements: string; + plan_file_management: string; + }; + + workflow_states?: { + current_phase?: string; + conversation_id?: string; + plan_file_path?: string; + }; +} + +/** + * Tool handler for providing comprehensive tool information + */ +export class GetToolInfoHandler extends BaseToolHandler { + protected readonly argsSchema = GetToolInfoArgsSchema; + + async executeHandler(args: GetToolInfoArgs, context: ServerContext): Promise { + logger.info('Generating comprehensive tool information', { projectPath: context.projectPath }); + + // Get available workflows + const availableWorkflows = context.workflowManager.getAvailableWorkflowsForProject(context.projectPath); + + // Transform workflows to response format + const workflows: WorkflowInfo[] = availableWorkflows.map(workflow => ({ + name: workflow.name, + displayName: workflow.displayName, + description: workflow.description, + phases: this.extractWorkflowPhases(workflow) + })); + + // Define available tools with their information + const tools: ToolInfo[] = [ + { + name: 'start_development', + description: 'Initialize new development project with structured workflow', + parameters: ['workflow', 'commit_behaviour'], + schema: { + required: ['commit_behaviour'], + optional: ['workflow'] + } + }, + { + name: 'whats_next', + description: 'Get phase-specific instructions and guidance for current development state', + parameters: ['context', 'user_input', 'conversation_summary', 'recent_messages'], + schema: { + required: ['context', 'user_input'], + optional: ['conversation_summary', 'recent_messages'] + } + }, + { + name: 'proceed_to_phase', + description: 'Transition to the next development phase when current phase is complete', + parameters: ['target_phase', 'reason'], + schema: { + required: ['target_phase'], + optional: ['reason'] + } + }, + { + name: 'resume_workflow', + description: 'Continue development after a break or conversation restart', + parameters: ['include_system_prompt'], + schema: { + required: [], + optional: ['include_system_prompt'] + } + }, + { + name: 'reset_development', + description: 'Start over with a clean slate by deleting all development progress', + parameters: ['confirm', 'reason'], + schema: { + required: ['confirm'], + optional: ['reason'] + } + }, + { + name: 'list_workflows', + description: 'Get an overview of all available workflows with descriptions', + parameters: [], + schema: { + required: [], + optional: [] + } + }, + { + name: 'get_tool_info', + description: 'Get comprehensive information about all available tools and workflows', + parameters: [], + schema: { + required: [], + optional: [] + } + } + ]; + + // Try to get current workflow state if available + let workflowState: GetToolInfoResponse['workflow_states'] = undefined; + try { + const conversationContext = await context.conversationManager.getConversationContext(); + workflowState = { + current_phase: conversationContext.currentPhase, + conversation_id: conversationContext.conversationId, + plan_file_path: conversationContext.planFilePath + }; + } catch (error) { + // No active conversation - this is fine + logger.debug('No active conversation found for workflow state', { error }); + } + + // Build the complete response + const response: GetToolInfoResponse = { + tool_name: 'Responsible Vibe MCP - Development Workflow Management', + version: '1.0.0', // This should ideally come from package.json + purpose: 'Structured development workflows with guided phase transitions and conversation state management', + description: 'A Model Context Protocol server that acts as an intelligent conversation state manager and development guide for LLMs, providing structured workflows for various development tasks including bug fixes, features, architecture documentation, and more.', + + available_tools: tools, + available_workflows: workflows, + + core_concepts: { + phase_management: 'Structured progression through development phases with entrance criteria and transition conditions', + plan_file_tracking: 'Maintains development state and progress in .vibe/development-plan-*.md files with task tracking', + conversation_context: 'Stateless operation requiring context in each whats_next() call for proper guidance', + workflow_guidance: 'Provides phase-specific instructions and recommendations based on current development state' + }, + + usage_guidelines: { + required_pattern: 'Always call whats_next() after user interactions to get context-appropriate guidance', + phase_transitions: 'Only proceed to next phase when entrance criteria are met and current phase tasks are complete', + context_requirements: 'Provide conversation history and context in whats_next() calls for optimal guidance', + plan_file_management: 'Update plan file with completed tasks [x] and add new tasks as they are identified' + } + }; + + // Add workflow state if available + if (workflowState) { + response.workflow_states = workflowState; + } + + logger.info('Successfully generated tool information', { + toolCount: tools.length, + workflowCount: workflows.length, + hasWorkflowState: !!workflowState + }); + + return response; + } + + /** + * Extract phase names from a workflow configuration + */ + private extractWorkflowPhases(workflow: any): string[] | undefined { + if (workflow.states && typeof workflow.states === 'object') { + return Object.keys(workflow.states); + } + return undefined; + } +} + +// Export type for external use +export type { GetToolInfoArgs, GetToolInfoResponse }; From d77f84a8edce76d581bcb33d371a29b8d59f64f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=7BAI=7Df=20D=2E=20M=C3=BCller?= Date: Thu, 10 Jul 2025 15:06:57 +0200 Subject: [PATCH 2/3] Register get_tool_info handler in tool registry - Import GetToolInfoHandler - Register 'get_tool_info' in createToolRegistry function - Export handler class and types for external use - Follows same pattern as other handlers for consistency --- src/server/tool-handlers/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/tool-handlers/index.ts b/src/server/tool-handlers/index.ts index 5dcb3258..11d4bf5e 100644 --- a/src/server/tool-handlers/index.ts +++ b/src/server/tool-handlers/index.ts @@ -13,6 +13,7 @@ import { StartDevelopmentHandler } from './start-development.js'; import { ResumeWorkflowHandler } from './resume-workflow.js'; import { ResetDevelopmentHandler } from './reset-development.js'; import { ListWorkflowsHandler } from './list-workflows.js'; +import { GetToolInfoHandler } from './get-tool-info.js'; const logger = createLogger('ToolRegistry'); @@ -49,6 +50,7 @@ export function createToolRegistry(): ToolRegistry { registry.register('resume_workflow', new ResumeWorkflowHandler()); registry.register('reset_development', new ResetDevelopmentHandler()); registry.register('list_workflows', new ListWorkflowsHandler()); + registry.register('get_tool_info', new GetToolInfoHandler()); logger.info('Tool registry created with handlers', { handlers: registry.list() @@ -64,6 +66,7 @@ export { StartDevelopmentHandler } from './start-development.js'; export { ResumeWorkflowHandler } from './resume-workflow.js'; export { ResetDevelopmentHandler } from './reset-development.js'; export { ListWorkflowsHandler } from './list-workflows.js'; +export { GetToolInfoHandler } from './get-tool-info.js'; export { BaseToolHandler, ConversationRequiredToolHandler } from './base-tool-handler.js'; // Export argument and result types @@ -72,3 +75,4 @@ export type { ProceedToPhaseArgs, ProceedToPhaseResult } from './proceed-to-phas export type { StartDevelopmentArgs, StartDevelopmentResult } from './start-development.js'; export type { ResumeWorkflowArgs, ResumeWorkflowResult } from './resume-workflow.js'; export type { ResetDevelopmentArgs, ResetDevelopmentResult } from './reset-development.js'; +export type { GetToolInfoArgs, GetToolInfoResponse } from './get-tool-info.js'; From 92c2a817b62e757e1cbd94328e2494475cb3961f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=7BAI=7Df=20D=2E=20M=C3=BCller?= Date: Thu, 10 Jul 2025 17:43:43 +0200 Subject: [PATCH 3/3] Add get_tool_info tool registration to MCP server - Register get_tool_info tool in registerMcpTools function - Provide comprehensive description for tool discoverability - Set appropriate annotations (readOnly, idempotent) - Follow same pattern as other tool registrations - No input schema required (no parameters) Addresses Issue #24 requirement for better tool discoverability. --- src/server/server-config.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/server/server-config.ts b/src/server/server-config.ts index 62e3256f..ef8d4682 100644 --- a/src/server/server-config.ts +++ b/src/server/server-config.ts @@ -285,6 +285,33 @@ export function registerMcpTools( } ); + // Register get_tool_info tool + mcpServer.registerTool( + 'get_tool_info', + { + description: 'Get comprehensive information about the responsible-vibe-mcp development workflow tools for better tool discoverability and AI integration. Returns detailed information about all available tools, workflows, core concepts, and usage guidelines.', + inputSchema: { + // No input parameters needed + }, + annotations: { + title: 'Tool Information Provider', + readOnlyHint: true, + destructiveHint: false, + idempotentHint: true, + openWorldHint: false + } + }, + async (args) => { + const handler = toolRegistry.get('get_tool_info'); + if (!handler) { + return responseRenderer.renderError('Tool handler not found: get_tool_info'); + } + + const result = await handler.handle(args, context); + return responseRenderer.renderToolResponse(result); + } + ); + logger.info('MCP tools registered successfully', { tools: toolRegistry.list() });