mirror of
https://github.com/eyaltoledano/claude-task-master.git
synced 2026-04-02 15:59:31 -06:00
task-master-ai add-task fails with 401 auth error when run by Cursor AI agent #1045
Labels
No labels
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:ai-models
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:cli
area:installation
area:installation
area:installation
area:installation
area:installation
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:mcp
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:task-management
area:vscode-extension
area:vscode-extension
area:vscode-extension
area:vscode-extension
area:vscode-extension
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
bug
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
documentation
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
duplicate
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
enhancement
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
feedback
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
good first issue
help wanted
help wanted
help wanted
help wanted
help wanted
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
high-priority
integration request
integration request
integration request
integration request
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
invalid
low-priority
low-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
medium-priority
provider:anthropic
provider:anthropic
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:claude-code
provider:gemini-cli
provider:openai
provider:perplexity
question
question
question
question
question
question
question
question
question
question
question
question
question
question
refactor
refactor
wontfix
wontfix
wontfix
wontfix
wontfix
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github/claude-task-master#1045
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @endlessblink on 4/6/2025
When using task-master-ai (previously claude-task-master) via the Cursor AI agent's terminal interaction feature, commands that require interaction with the Anthropic API (like add-task) fail with a 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}. This occurs even though the same command works correctly when run directly in my own terminal, and the ANTHROPIC_API_KEY is correctly configured (e.g., in .env). Commands that don't require the API key (like list or next) work fine via the Cursor agent when bypassing the PowerShell execution policy.
It seems the execution environment used by the Cursor agent's terminal tool does not correctly access or load the ANTHROPIC_API_KEY environment variable.
Steps to Reproduce:
Install task-master-ai locally (npm install --save-dev task-master-ai). (Note: Global installation was also tried).
Ensure ANTHROPIC_API_KEY is correctly set in the project's .env file.
Use the Cursor AI IDE (Version: [Please fill in your Cursor version]) with its AI agent.
Ask the agent to run a command requiring the API key via its terminal tool, for example:
Apply to .env
Run
(Optional but necessary on Windows PowerShell) Prepend Set-ExecutionPolicy Bypass -Scope Process -Force; to bypass execution policy:
Apply to .env
Run
Expected Behavior:
The add-task command should successfully authenticate with the Anthropic API using the provided ANTHROPIC_API_KEY, generate the task details, and update the tasks/tasks.json file.
Actual Behavior:
The command fails. Debug logs (enabled via $env:DEBUG='true'; $env:LOG_LEVEL='debug';) show the API request failing:
Apply to .env
(Also encountered npm error could not determine executable to run when trying various npx combinations, suggesting issues finding the executable in the tool's environment).
Environment:
OS: Windows 10 (Build 10.0.26100)
task-master-ai Version: Latest as of 2025-04-06 (installed locally via npm)
Node.js Version: v22.13.0
PowerShell Version: 5.1.26100.2161
Cursor Version: [Please fill in your Cursor version]
Execution Context: Cursor AI agent's integrated terminal tool feature.
Troubleshooting Steps Attempted:
Confirmed commands work in user's standard PowerShell terminal.
Confirmed ANTHROPIC_API_KEY is set in .env.
Used Set-ExecutionPolicy Bypass -Scope Process -Force; to successfully run non-API commands (list, next).
Tried global vs. local installation of task-master-ai.
Tried running via npx task-master-ai and npx task-master-ai@latest.
Tried explicitly loading .env via node -r dotenv/config scripts/dev.js add-task (but add-task isn't available in scripts/dev.js).
Enabled debug logs ($env:DEBUG='true'; $env:LOG_LEVEL='debug';) which revealed the 401 error.
Checked README for Cursor MCP configuration (npx -y --package task-master-ai task-master-mcp), ensured it was set up in Cursor settings, but the direct command execution still fails authentication.
Hypothesis:
The environment used by the Cursor agent's terminal tool is isolated and does not inherit/load environment variables (specifically ANTHROPIC_API_KEY) from the user's session or .env file in the same way a standard terminal does, preventing successful API authentication for relevant task-master-ai commands.