Implement validate-dependencies MCP command for checking dependency validity

This commit is contained in:
Eyal Toledano
2025-03-31 13:55:07 -04:00
parent a6a94e3a18
commit 9730576a03
7 changed files with 127 additions and 24 deletions

View File

@@ -13,9 +13,10 @@
- Implement add-task MCP command for creating new tasks using AI assistance
- Implement add-subtask MCP command for adding subtasks to existing tasks
- Implement remove-subtask MCP command for removing subtasks from parent tasks
- Implement analyze-complexity MCP command for analyzing task complexity and generating recommendations
- Implement expand-all MCP command for expanding all tasks into subtasks
- Implement analyze-complexity MCP command for analyzing task complexity
- Implement clear-subtasks MCP command for clearing subtasks from parent tasks
- Implement expand-all MCP command for expanding all pending tasks with subtasks
- Implement remove-dependency MCP command for removing dependencies from tasks
- Implement validate-dependencies MCP command for checking validity of task dependencies
- Document MCP server naming conventions in architecture.mdc and mcp.mdc files (file names use kebab-case, direct functions use camelCase with Direct suffix, tool registration functions use camelCase with Tool suffix, and MCP tool names use snake_case)
- Enhance task show view with a color-coded progress bar for visualizing subtask completion percentage

View File

@@ -0,0 +1,55 @@
/**
* Direct function wrapper for validateDependenciesCommand
*/
import { validateDependenciesCommand } from '../../../../scripts/modules/dependency-manager.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
import fs from 'fs';
/**
* Validate dependencies in tasks.json
* @param {Object} args - Function arguments
* @param {string} [args.file] - Path to the tasks file
* @param {string} [args.projectRoot] - Project root directory
* @param {Object} log - Logger object
* @returns {Promise<{success: boolean, data?: Object, error?: {code: string, message: string}}>}
*/
export async function validateDependenciesDirect(args, log) {
try {
log.info(`Validating dependencies in tasks...`);
// Determine the tasks file path
const tasksPath = args.file || await findTasksJsonPath(args.projectRoot);
// Verify the file exists
if (!fs.existsSync(tasksPath)) {
return {
success: false,
error: {
code: 'FILE_NOT_FOUND',
message: `Tasks file not found at ${tasksPath}`
}
};
}
// Call the original command function
await validateDependenciesCommand(tasksPath);
return {
success: true,
data: {
message: 'Dependencies validated successfully',
tasksPath
}
};
} catch (error) {
log.error(`Error validating dependencies: ${error.message}`);
return {
success: false,
error: {
code: 'VALIDATION_ERROR',
message: error.message
}
};
}
}

View File

@@ -23,6 +23,7 @@ import { analyzeTaskComplexityDirect } from './direct-functions/analyze-task-com
import { clearSubtasksDirect } from './direct-functions/clear-subtasks.js';
import { expandAllTasksDirect } from './direct-functions/expand-all-tasks.js';
import { removeDependencyDirect } from './direct-functions/remove-dependency.js';
import { validateDependenciesDirect } from './direct-functions/validate-dependencies.js';
// Re-export utility functions
export { findTasksJsonPath } from './utils/path-utils.js';
@@ -46,7 +47,8 @@ export const directFunctions = new Map([
['analyzeTaskComplexityDirect', analyzeTaskComplexityDirect],
['clearSubtasksDirect', clearSubtasksDirect],
['expandAllTasksDirect', expandAllTasksDirect],
['removeDependencyDirect', removeDependencyDirect]
['removeDependencyDirect', removeDependencyDirect],
['validateDependenciesDirect', validateDependenciesDirect]
]);
// Re-export all direct function implementations
@@ -68,5 +70,6 @@ export {
analyzeTaskComplexityDirect,
clearSubtasksDirect,
expandAllTasksDirect,
removeDependencyDirect
removeDependencyDirect,
validateDependenciesDirect
};

View File

@@ -21,12 +21,17 @@ import { registerAnalyzeTool } from "./analyze.js";
import { registerClearSubtasksTool } from "./clear-subtasks.js";
import { registerExpandAllTool } from "./expand-all.js";
import { registerRemoveDependencyTool } from "./remove-dependency.js";
import { registerValidateDependenciesTool } from "./validate-dependencies.js";
/**
* Register all Task Master tools with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerTaskMasterTools(server) {
logger.info("Registering Task Master tools with MCP server");
try {
// Register each tool
registerListTasksTool(server);
registerSetTaskStatusTool(server);
registerParsePRDTool(server);
@@ -44,8 +49,13 @@ export function registerTaskMasterTools(server) {
registerClearSubtasksTool(server);
registerExpandAllTool(server);
registerRemoveDependencyTool(server);
registerValidateDependenciesTool(server);
logger.info("Registered all Task Master tools with MCP server");
logger.info("Successfully registered all Task Master tools");
} catch (error) {
logger.error(`Error registering Task Master tools: ${error.message}`);
throw error;
}
}
export default {

View File

@@ -0,0 +1,34 @@
/**
* tools/validate-dependencies.js
* Tool for validating task dependencies
*/
import { z } from "zod";
import {
handleApiResult,
createErrorResponse
} from "./utils.js";
import { validateDependenciesDirect } from "../core/task-master-core.js";
/**
* Register the validateDependencies tool with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerValidateDependenciesTool(server) {
server.addTool({
name: "validate_dependencies",
description: "Identify invalid dependencies in tasks without fixing them",
parameters: z.object({
file: z.string().optional().describe("Path to the tasks file"),
projectRoot: z.string().optional().describe("Root directory of the project (default: current working directory)")
}),
handler: async ({ file, projectRoot }, { logger }) => {
try {
const result = await validateDependenciesDirect({ file, projectRoot }, logger);
return handleApiResult(result);
} catch (error) {
return createErrorResponse(error);
}
}
});
}

View File

@@ -884,7 +884,7 @@ Analyze and refactor the project root handling mechanism to ensure consistent fi
### Details:
## 41. Implement validate-dependencies MCP command [pending]
## 41. Implement validate-dependencies MCP command [done]
### Dependencies: 23.31, 23.39, 23.40
### Description: Create MCP tool implementation for the validate-dependencies command
### Details:

View File

@@ -1723,7 +1723,7 @@
"title": "Implement validate-dependencies MCP command",
"description": "Create MCP tool implementation for the validate-dependencies command",
"details": "",
"status": "pending",
"status": "done",
"dependencies": [
"23.31",
"23.39",