{"record":{"id":"a0ad56af96755327","repo":"eyaltoledano/claude-task-master","slug":"no-task-master-project-detected-in-current-directo","errorCode":null,"errorMessage":"No task-master project detected in current directory. Using ${currentDir} as project root.","messagePattern":"No task-master project detected in current directory\\. Using (.+?) as project root\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mcp-server/src/tools/utils.js","lineNumber":160,"sourceCode":"\t\treturn lastFoundProjectRoot;\n\t}\n\n\t// 4. Check if the current directory has any indicators of being a task-master project\n\tconst currentDir = process.cwd();\n\tif (\n\t\tPROJECT_MARKERS.some((marker) => {\n\t\t\tconst markerPath = path.join(currentDir, marker);\n\t\t\treturn fs.existsSync(markerPath);\n\t\t})\n\t) {\n\t\tlog.info(\n\t\t\t`Using current directory as project root (found project markers): ${currentDir}`\n\t\t);\n\t\treturn currentDir;\n\t}\n\n\t// 5. Default to current working directory but warn the user\n\tlog.warn(\n\t\t`No task-master project detected in current directory. Using ${currentDir} as project root.`\n\t);\n\tlog.warn(\n\t\t'Consider using --project-root to specify the correct project location or set TASK_MASTER_PROJECT_ROOT environment variable.'\n\t);\n\treturn currentDir;\n}\n\n/**\n * Extracts and normalizes the project root path from the MCP session object.\n * @param {Object} session - The MCP session object.\n * @param {Object} log - The MCP logger object.\n * @returns {string|null} - The normalized absolute project root path or null if not found/invalid.\n */\nfunction getProjectRootFromSession(session, log) {\n\ttry {\n\t\t// Add detailed logging of session structure\n\t\tlog.info(","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/tools/utils.js#L142-L178","documentation":"getProjectRoot walks up from the current directory looking for project markers (e.g. .taskmaster, tasks.json, .git, package.json). When none are found it falls back to the current working directory and warns that no task-master project was detected. Tools will then operate on ${currentDir}, which likely has no task data.","triggerScenarios":"Running an MCP tool from a directory outside any task-master project, e.g. launching the MCP server with cwd set to $HOME, /tmp, or a fresh folder without .taskmaster/ or tasks.json.","commonSituations":"MCP client starts the server with the wrong cwd; project nested deeper than the walk-up search; user forgot to run task-master init in the folder; using TASK_MASTER_PROJECT_ROOT unset in containers/CI.","solutions":["Set the TASK_MASTER_PROJECT_ROOT environment variable to the absolute project path.","Pass --project-root (or the tool's projectRoot argument) explicitly.","Start the MCP server from inside the task-master project, or run task-master init to create markers.","Add a marker file (.taskmaster directory or tasks.json) to the intended root."],"exampleFix":"// before (mcp config)\n{ \"command\": \"task-master-mcp\", \"cwd\": \"/home/user\" }\n// after\n{ \"command\": \"task-master-mcp\", \"env\": { \"TASK_MASTER_PROJECT_ROOT\": \"/home/user/my-project\" } }","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nimport path from 'path';\nfunction findProjectRoot(startDir) {\n  let dir = startDir;\n  while (dir !== path.parse(dir).root) {\n    if (fs.existsSync(path.join(dir, '.taskmaster')) || fs.existsSync(path.join(dir, 'tasks.json')))\n      return dir;\n    dir = path.dirname(dir);\n  }\n  return process.env.TASK_MASTER_PROJECT_ROOT || null; // null => configure explicitly\n}","typeGuard":"function hasValidProjectRoot(root) {\n  return typeof root === 'string' && fs.existsSync(path.join(root, '.taskmaster'));\n}","tryCatchPattern":"null","preventionTips":["Always set TASK_MASTER_PROJECT_ROOT in MCP server / CI env config.","Launch the server from inside the project directory.","Run task-master init in new projects so markers exist.","Check startup logs for this warning and fix root resolution before issuing tool calls."],"tags":["mcp","project-root","configuration","working-directory"],"backgroundTag":"project-root-not-detected","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}