feat: add TASKMASTER_DOTENV support for custom .env paths#703
Closed
dwayn wants to merge 1 commit intoeyaltoledano:nextfrom
Closed
feat: add TASKMASTER_DOTENV support for custom .env paths#703dwayn wants to merge 1 commit intoeyaltoledano:nextfrom
dwayn wants to merge 1 commit intoeyaltoledano:nextfrom
Conversation
- Add TASKMASTER_DOTENV environment variable support in resolveEnvVariable function - Support both CLI and MCP session environment configuration - Update documentation with usage examples for CLI and MCP - Add comprehensive tests covering all precedence scenarios and error cases - Allow users to manage TaskMaster credentials separately from project env
🦋 Changeset detectedLatest commit: e5e5721 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Crunchyman-ralph
requested changes
Jul 9, 2025
Collaborator
Crunchyman-ralph
left a comment
There was a problem hiding this comment.
small nit pick then ready to merge
| const parsedEnv = dotenv.parse(envFileContent); // Use dotenv to parse | ||
| if (parsedEnv && parsedEnv[key]) { | ||
| // console.log(`DEBUG: Found key ${key} in ${envPath}`); // Optional debug log | ||
| return parsedEnv[key]; |
Collaborator
There was a problem hiding this comment.
why not also use:
require('dotenv').config({ path: '/custom/path/to/.env' })
Collaborator
|
Thanks for this, custom .env paths is a practical feature. Unfortunately it's been sitting with merge conflicts for a long time and the codebase has moved on. Closing this one, but the concept is solid. If you want to reopen against current main, we'd be happy to review. Appreciate your time! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add TASKMASTER_DOTENV support for custom .env file paths
Description
This PR adds support for the
TASKMASTER_DOTENVenvironment variable, allowing users to specify a custom path to their.envfile instead of being limited to the default project root location. This enables better credential management and cost separation between TaskMaster usage and project runtime environments.Motivation
Users often want to manage TaskMaster API keys separately from their project's environment variables to:
Type of Change
Changes Made
Core Implementation
scripts/modules/utils.js: Enhanced theresolveEnvVariablefunction to supportTASKMASTER_DOTENVwith the following precedence order:session.env[key](direct variable lookup in MCP session).envfile fromsession.env.TASKMASTER_DOTENV(MCP session configuration).envfile fromprocess.env.TASKMASTER_DOTENV(shell environment).envfile at project rootprocess.env[key](fallback to system environment)Comprehensive Test Coverage
tests/unit/utils.test.jscovering:Documentation Updates
docs/configuration.md: Added comprehensive documentation including:TASKMASTER_DOTENVfeature in the main configuration section.cursor/mcp.jsonand VS Code.vscode/mcp.json.envfile locationsUsage Examples
CLI Usage
MCP Usage
{ "mcpServers": { "taskmaster-ai": { "command": "npx", "args": ["-y", "--package=task-master-ai", "task-master-ai"], "env": { "TASKMASTER_DOTENV": "/path/to/your/custom/.env" } } } }Testing
Changeset
Backward Compatibility
✅ Fully backward compatible - When TASKMASTER_DOTENV is not set, the system behaves exactly as before, using the project root .env file.
Additional Notes
This implementation provides a clean, flexible solution for credential management that works seamlessly across both CLI and MCP usage patterns. The precedence order ensures that MCP session configurations take priority over system environment
variables, allowing for fine-grained control in multi-session scenarios.
The comprehensive test suite ensures robustness across all edge cases and follows the project's established testing patterns, providing confidence in the feature's reliability.