interactive_feedback
Request interactive feedback on project code and context to enable human-in-the-loop AI development workflows.
Instructions
Request interactive feedback for a given project directory and summary
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_directory | Yes | Path to the project directory | |
| summary | Yes | Summary of the request or context |
Implementation Reference
- server.js:115-144 (handler)The primary handler function for the 'interactive_feedback' MCP tool. It validates the OpenAI API key, cleans the input parameters (project directory and summary), and invokes launchFeedbackUI to spawn the web UI process and retrieve user feedback.async function interactiveFeedback(projectDirectory, summary) { // Validate OPENAI_API_KEY before proceeding if (!process.env.OPENAI_API_KEY) { const error = new Error('OpenAI API key not configured. Please set OPENAI_API_KEY in your .env file.'); console.error('❌ API Key Validation Failed:', error.message); console.error(' Expected .env path:', path.join(__dirname, '.env')); console.error(' Current working directory:', process.cwd()); console.error(' Script directory (__dirname):', __dirname); throw error; } // Validate API key format const apiKey = process.env.OPENAI_API_KEY; if (!apiKey.startsWith('sk-') || apiKey.length < 20) { const error = new Error('Invalid OpenAI API key format. Key should start with "sk-" and be at least 20 characters long.'); console.error('❌ API Key Format Validation Failed:', error.message); console.error(' Key length:', apiKey.length); console.error(' Key prefix:', apiKey.substring(0, 3)); throw error; } console.log('✅ API Key validation passed for interactive feedback'); // Apply firstLine only to projectDirectory to ensure it's a valid path // Keep summary intact to preserve multi-line content const cleanProjectDirectory = firstLine(projectDirectory); const cleanSummary = summary || 'I implemented the changes you requested.'; return await launchFeedbackUI(cleanProjectDirectory, cleanSummary); }
- server.js:157-176 (registration)Tool registration in MCPServer constructor, defining the 'interactive_feedback' tool with its description, input schema, and handler reference.this.tools = { interactive_feedback: { description: 'Request interactive feedback for a given project directory and summary', inputSchema: { type: 'object', properties: { project_directory: { type: 'string', description: 'Path to the project directory' }, summary: { type: 'string', description: 'Summary of the request or context' } }, required: ['project_directory', 'summary'] }, handler: interactiveFeedback } };
- server.js:160-173 (schema)Input schema for the 'interactive_feedback' tool, specifying required parameters: project_directory (string) and summary (string).inputSchema: { type: 'object', properties: { project_directory: { type: 'string', description: 'Path to the project directory' }, summary: { type: 'string', description: 'Summary of the request or context' } }, required: ['project_directory', 'summary'] },
- server.js:50-107 (helper)Key helper function called by the handler. Spawns the web-ui.js process with project directory, prompt/summary, and output file arguments. Waits for completion, reads JSON result from temp file, cleans up, and returns the feedback object containing command_logs and interactive_feedback.async function launchFeedbackUI(projectDirectory, summary) { // Create temporary file for result const tempDir = os.tmpdir(); const uuid = crypto.randomUUID(); const outputFile = path.join(tempDir, `feedback-${uuid}.json`); try { // Get path to web-ui.js const scriptDir = __dirname; const webUIPath = path.join(scriptDir, 'web-ui.js'); // Prepare arguments for web UI process const args = [ webUIPath, '--project-directory', projectDirectory, '--prompt', summary, '--output-file', outputFile ]; // Spawn Web UI process const childProcess = spawn('node', args, { stdio: ['ignore', 'ignore', 'ignore'], detached: false }); // Wait for process completion await new Promise((resolve, reject) => { childProcess.on('close', (code) => { if (code === 0) { resolve(); } else { reject(new Error(`Web UI process exited with code ${code}`)); } }); childProcess.on('error', (error) => { reject(error); }); }); // Read result from temp file const result = await fs.readJson(outputFile); // Cleanup temp file await fs.unlink(outputFile); return result; } catch (error) { // Cleanup temp file if error occurs try { await fs.unlink(outputFile); } catch (cleanupError) { // Ignore cleanup errors } throw error; } }