Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

fix(add-task): removes stdout in add-task which will crash MCP server (#593)

Eyal Toledano2d520de2694d
diff --git a/.changeset/tidy-seals-rule.md b/.changeset/tidy-seals-rule.md
new file mode 100644
index 00000000..4e2b44f2
--- /dev/null
+++ b/.changeset/tidy-seals-rule.md
@@ -0,0 +1,5 @@
+---
+'task-master-ai': patch
+---
+
+Fix add-task MCP command causing an error
diff --git a/scripts/modules/task-manager/add-task.js b/scripts/modules/task-manager/add-task.js
index efd5595a..1d0e13ec 100644
--- a/scripts/modules/task-manager/add-task.js
+++ b/scripts/modules/task-manager/add-task.js
@@ -852,30 +852,32 @@ async function addTask(
: 0;
}
- // Add a visual transition to show we're moving to AI generation
- console.log(
- boxen(
- chalk.white.bold('AI Task Generation') +
- `\n\n${chalk.gray('Analyzing context and generating task details using AI...')}` +
- `\n${chalk.cyan('Context size: ')}${chalk.yellow(contextTasks.length.toLocaleString())} characters` +
- `\n${chalk.cyan('Dependency detection: ')}${chalk.yellow(numericDependencies.length > 0 ? 'Explicit dependencies' : 'Auto-discovery mode')}` +
- `\n${chalk.cyan('Detailed tasks: ')}${chalk.yellow(
- numericDependencies.length > 0
- ? dependentTasks.length // Use length of tasks from explicit dependency path
- : uniqueDetailedTasks.length // Use length of tasks from fuzzy search path
- )}` +
- (promptCategory
- ? `\n${chalk.cyan('Category detected: ')}${chalk.yellow(promptCategory.label)}`
- : ''),
- {
- padding: { top: 0, bottom: 1, left: 1, right: 1 },
- margin: { top: 1, bottom: 0 },
- borderColor: 'white',
- borderStyle: 'round'
- }
- )
- );
- console.log(); // Add spacing
+ // Add a visual transition to show we're moving to AI generation - only for CLI
+ if (outputFormat === 'text') {
+ console.log(
+ boxen(
+ chalk.white.bold('AI Task Generation') +
+ `\n\n${chalk.gray('Analyzing context and generating task details using AI...')}` +
+ `\n${chalk.cyan('Context size: ')}${chalk.yellow(contextTasks.length.toLocaleString())} characters` +
+ `\n${chalk.cyan('Dependency detection: ')}${chalk.yellow(numericDependencies.length > 0 ? 'Explicit dependencies' : 'Auto-discovery mode')}` +
+ `\n${chalk.cyan('Detailed tasks: ')}${chalk.yellow(
+ numericDependencies.length > 0
+ ? dependentTasks.length // Use length of tasks from explicit dependency path
+ : uniqueDetailedTasks.length // Use length of tasks from fuzzy search path
+ )}` +
+ (promptCategory
+ ? `\n${chalk.cyan('Category detected: ')}${chalk.yellow(promptCategory.label)}`
+ : ''),
+ {
+ padding: { top: 0, bottom: 1, left: 1, right: 1 },
+ margin: { top: 1, bottom: 0 },
+ borderColor: 'white',
+ borderStyle: 'round'
+ }
+ )
+ );
+ console.log(); // Add spacing
+ }
// System Prompt - Enhanced for dependency awareness
const systemPrompt =