fix(mcp): make projectRoot optional in all MCP tools
- Update all tool definitions to use z.string().optional() for projectRoot - Fix direct function implementations to use findTasksJsonPath(args, log) pattern - Enables consistent project root detection without requiring explicit params - Update changeset to document these improvements This change ensures MCP tools work properly with the smart project root detection system, removing the need for explicit projectRoot parameters in client applications. Improves usability and reduces integration friction.
This commit is contained in:
@@ -47,7 +47,7 @@ export async function addSubtaskDirect(args, log) {
|
||||
}
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Parse dependencies if provided
|
||||
let dependencies = [];
|
||||
|
||||
@@ -20,8 +20,8 @@ import { findTasksJsonPath } from '../utils/path-utils.js';
|
||||
*/
|
||||
export async function addTaskDirect(args, log) {
|
||||
try {
|
||||
// Resolve the tasks file path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Check required parameters
|
||||
if (!args.prompt) {
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function analyzeTaskComplexityDirect(args, log) {
|
||||
log.info(`Analyzing task complexity with args: ${JSON.stringify(args)}`);
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Determine output path
|
||||
let outputPath = args.output || 'scripts/task-complexity-report.json';
|
||||
|
||||
@@ -32,7 +32,7 @@ export async function clearSubtasksDirect(args, log) {
|
||||
}
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Check if tasks.json exists
|
||||
if (!fs.existsSync(tasksPath)) {
|
||||
|
||||
@@ -22,7 +22,7 @@ export async function expandAllTasksDirect(args, log) {
|
||||
log.info(`Expanding all tasks with args: ${JSON.stringify(args)}`);
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Parse parameters
|
||||
const numSubtasks = args.num ? parseInt(args.num, 10) : undefined;
|
||||
|
||||
@@ -18,8 +18,8 @@ export async function fixDependenciesDirect(args, log) {
|
||||
try {
|
||||
log.info(`Fixing invalid dependencies in tasks...`);
|
||||
|
||||
// Determine the tasks file path
|
||||
const tasksPath = args.file || await findTasksJsonPath(args.projectRoot);
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Verify the file exists
|
||||
if (!fs.existsSync(tasksPath)) {
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function removeDependencyDirect(args, log) {
|
||||
}
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Format IDs for the core function
|
||||
const taskId = args.id.includes && args.id.includes('.') ? args.id : parseInt(args.id, 10);
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function removeSubtaskDirect(args, log) {
|
||||
}
|
||||
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args.file, args.projectRoot);
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Convert convertToTask to a boolean
|
||||
const convertToTask = args.convert === true;
|
||||
|
||||
@@ -18,8 +18,8 @@ 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);
|
||||
// Find the tasks.json path
|
||||
const tasksPath = findTasksJsonPath(args, log);
|
||||
|
||||
// Verify the file exists
|
||||
if (!fs.existsSync(tasksPath)) {
|
||||
|
||||
Reference in New Issue
Block a user