Refactors parse-prd MCP tool to properly handle project root and path resolution, fixing the 'Input file not found: /scripts/prd.txt' error.
Key changes include: Made projectRoot a required parameter, prioritized args.projectRoot over session-derived paths, added validation to prevent parsing in invalid directories (/, home dir), improved error handling with detailed messages, and added creation of output directory if needed.
This resolves issues similar to those fixed in initialize-project, where the tool was incorrectly resolving paths when session context was incomplete.
Refactors the initialize_project MCP tool to call a dedicated direct function (initializeProjectDirect) instead of executing the CLI command. This improves reliability and aligns it with other MCP tools.
Key changes include: Modified initialize-project.js to call initializeProjectDirect, required projectRoot parameter, implemented handleApiResult for MCP response formatting, enhanced direct function to prioritize args.projectRoot over session-derived paths, added validation to prevent initialization in invalid directories, forces yes:true for non-interactive use, ensures process.chdir() targets validated directory, and added isSilentMode() checks to suppress console output during MCP operations.
This resolves issues where the tool previously failed due to incorrect fallback directory resolution when session context was incomplete.
Centralizes init command logic within the main CLI structure. The action handler in commands.js now directly calls initializeProject from the init.js module, resolving issues with argument parsing (like -y) and removing the need for the separate bin/task-master-init.js executable. Updates package.json and bin/task-master.js accordingly.
Change threshold parameter in analyze_project_complexity from union type to coerce.number with min/max validation. Fix Invalid type error that occurred with certain input formats. Add test implementation to avoid real API calls and proper tests for parameter validation.
Added detailed next_step guidance to the initialize-project MCP tool response,
providing clear instructions about creating a PRD file and using parse-prd
after initialization. This helps users understand the workflow better after
project initialization.
Also added comprehensive unit tests for the initialize-project MCP tool that:
- Verify tool registration with correct parameters
- Test command construction with proper argument formatting
- Check special character escaping in command arguments
- Validate success response formatting including the new next_step field
- Test error handling and fallback mechanisms
- Verify logging behavior
The tests follow the same pattern as other MCP tool tests in the codebase.
- Add support for --title/-t and --description/-d flags in add-task command
- Fix validation for manual creation mode (title + description)
- Implement proper testing for both prompt and manual creation modes
- Update testing documentation with Commander.js testing best practices
- Add guidance on handling variable hoisting and module initialization issues
Changeset: brave-doors-open.md
- Add custom processTaskResponse function to get-task.js to filter response data
- Significantly reduce MCP response size by returning only the requested task
- Preserve allTasks in CLI/UI for dependency status formatting
- Update changeset with documentation of optimization
This change maintains backward compatibility while making MCP responses
more efficient, addressing potential context overflow issues in AI clients.
- Refactor for more reliable project root detection, particularly when running within integrated environments like Cursor IDE. Includes deriving root from script path and avoiding fallback to '/'.
- Enhance error handling in :
- Add detailed debug information (paths searched, CWD, etc.) to the error message when is not found in the provided project root.
- Improve clarity of error messages and potential solutions.
- Add verbose logging in to trace session object content and the finally resolved project root path, aiding in debugging path-related issues.
- Add default values for and to the example environment configuration.
This commit refactors how the MCP server determines the project root directory, prioritizing the path provided by the client session (e.g., Cursor) for increased reliability and simplification.
Previously, project root discovery relied on a complex chain of fallbacks (environment variables, CWD searching, package path checks) within `findTasksJsonPath`. This could be brittle and less accurate when running within an integrated environment like Cursor.
Key changes:
- **Prioritize Session Roots:** MCP tools (`add-task`, `add-dependency`, etc.) now first attempt to extract the project root URI directly from `session.roots[0].uri`.
- **New Utility `getProjectRootFromSession`:** Added a utility function in `mcp-server/src/tools/utils.js` to encapsulate the logic for extracting and decoding the root URI from the session object.
- **Refactor MCP Tools:** Updated tools (`add-task.js`, `add-dependency.js`) to use `getProjectRootFromSession`.
- **Simplify `findTasksJsonPath`:** Prioritized `args.projectRoot`, removed checks for `TASK_MASTER_PROJECT_ROOT` env var and package directory fallback. Retained CWD search and cache check for CLI compatibility.
- **Fix `reportProgress` Usage:** Corrected parameters in `add-dependency.js`.
This change makes project root determination more robust for the MCP server while preserving discovery mechanisms for the standalone CLI.
- 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.
Overhauls the project root detection system with a hierarchical precedence mechanism that intelligently locates tasks.json and identifies project roots. This improves user experience by reducing the need for explicit path parameters and enhances cross-platform compatibility.
Key Improvements:
- Implement hierarchical precedence for project root detection:
* Environment variable override (TASK_MASTER_PROJECT_ROOT)
* Explicitly provided --project-root parameter
* Cached project root from previous successful operations
* Current directory with project markers
* Parent directory traversal to find tasks.json
* Package directory as fallback
- Create comprehensive PROJECT_MARKERS detection system with 20+ common indicators:
* Task Master specific files (tasks.json, tasks/tasks.json)
* Version control directories (.git, .svn)
* Package manifests (package.json, pyproject.toml, Gemfile, go.mod, Cargo.toml)
* IDE/editor configurations (.cursor, .vscode, .idea)
* Dependency directories (node_modules, venv, .venv)
* Configuration files (.env, tsconfig.json, webpack.config.js)
* CI/CD files (.github/workflows, .gitlab-ci.yml, .circleci/config.yml)
- DRY refactoring of path utilities:
* Centralize path-related functions in core/utils/path-utils.js
* Export PROJECT_MARKERS as a single source of truth
* Add caching via lastFoundProjectRoot for performance optimization
- Enhanced user experience:
* Improve error messages with specific troubleshooting guidance
* Add detailed logging to indicate project root detection source
* Update tool parameter descriptions for better clarity
* Add recursive parent directory searching for tasks.json
Testing:
- Verified in local dev environment
- Added unit tests for the progress bar visualization
- Updated "automatically detected" description in MCP tools
This commit addresses Task #38: Implement robust project root handling for file paths.
- Create direct function wrapper in add-task.js with prompt and dependency handling
- Add MCP tool integration for creating new tasks via AI
- Update task-master-core.js to expose addTaskDirect function
- Update changeset to document the new command
- Create direct function wrapper in expand-task.js with error handling
- Add MCP tool integration for breaking down tasks into subtasks
- Update task-master-core.js to expose expandTaskDirect function
- Update changeset to document the new command
- Parameter support for subtask generation options (num, research, prompt, force)
- Create direct function wrapper in next-task.js with error handling and caching
- Add MCP tool integration for finding the next task to work on
- Update task-master-core.js to expose nextTaskDirect function
- Update changeset to document the new command
- Create direct function wrapper in show-task.js with error handling and caching
- Add MCP tool integration for displaying detailed task information
- Update task-master-core.js to expose showTaskDirect function
- Update changeset to document the new command
- Follow kebab-case/camelCase/snake_case naming conventions