Implement fix-dependencies MCP command for automatically fixing invalid dependencies

This commit is contained in:
Eyal Toledano
2025-03-31 14:01:49 -04:00
parent 535fb5be71
commit d06e45bf12
5 changed files with 97 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
/**
* tools/fix-dependencies.js
* Tool for automatically fixing invalid task dependencies
*/
import { z } from "zod";
import {
handleApiResult,
createErrorResponse
} from "./utils.js";
import { fixDependenciesDirect } from "../core/task-master-core.js";
/**
* Register the fixDependencies tool with the MCP server
* @param {Object} server - FastMCP server instance
*/
export function registerFixDependenciesTool(server) {
server.addTool({
name: "fix_dependencies",
description: "Fix invalid dependencies in tasks automatically",
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 fixDependenciesDirect({ file, projectRoot }, logger);
return handleApiResult(result);
} catch (error) {
return createErrorResponse(error);
}
}
});
}