Don't add task-master-mcp to mcp.json if it already exists (#169)

This commit is contained in:
Joe Danziger
2025-04-11 12:07:58 -04:00
committed by GitHub
parent a3f9deabcf
commit 533f5cdc25
5 changed files with 27 additions and 7 deletions

View File

@@ -33,7 +33,7 @@
- Updated README, added tutorial/examples guide, supported client list documentation.
- Adjusts the MCP server invokation in the mcp.json we ship with `task-master init`. Fully functional now.
- Rename the npx -y command. It's now `npx -y task-master-ai task-master-mcp`
- Rename the npx -y command. It's now `npx -y task-master-mcp`
- Add additional binary alias: `task-master-mcp-server` pointing to the same MCP server script
- **Significant improvements to model configuration:**

View File

@@ -146,7 +146,7 @@ To enable enhanced task management capabilities directly within Cursor using the
4. Configure with the following details:
- Name: "Task Master"
- Type: "Command"
- Command: "npx -y --package task-master-ai task-master-mcp"
- Command: "npx -y task-master-mcp"
5. Save the settings
Once configured, you can interact with Task Master's task management commands directly through Cursor's interface, providing a more integrated experience.

View File

@@ -27,7 +27,7 @@ MCP (Model Control Protocol) provides the easiest way to get started with Task M
"mcpServers": {
"taskmaster-ai": {
"command": "npx",
"args": ["-y", "--package", "task-master-ai", "task-master-mcp"],
"args": ["-y", "task-master-mcp"],
"env": {
"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY_HERE",
"PERPLEXITY_API_KEY": "YOUR_PERPLEXITY_API_KEY_HERE",

View File

@@ -17,7 +17,7 @@ MCP (Model Control Protocol) provides the easiest way to get started with Task M
"mcpServers": {
"taskmaster-ai": {
"command": "npx",
"args": ["-y", "--package", "task-master-ai", "task-master-mcp"],
"args": ["-y", "task-master-mcp"],
"env": {
"ANTHROPIC_API_KEY": "YOUR_ANTHROPIC_API_KEY_HERE",
"PERPLEXITY_API_KEY": "YOUR_PERPLEXITY_API_KEY_HERE",
@@ -132,7 +132,7 @@ You can also set up the MCP server in Cursor settings:
4. Configure with the following details:
- Name: "Task Master"
- Type: "Command"
- Command: "npx -y --package task-master-ai task-master-mcp"
- Command: "npx -y task-master-mcp"
5. Save the settings
Once configured, you can interact with Task Master's task management commands directly through Cursor's interface, providing a more integrated experience.

View File

@@ -909,7 +909,7 @@ function setupMCPConfiguration(targetDir, projectName) {
const newMCPServer = {
'task-master-ai': {
command: 'npx',
args: ['-y', '--package', 'task-master-ai', 'task-master-mcp'],
args: ['-y', 'task-master-mcp'],
env: {
ANTHROPIC_API_KEY: '%ANTHROPIC_API_KEY%',
PERPLEXITY_API_KEY: '%PERPLEXITY_API_KEY%',
@@ -925,7 +925,10 @@ function setupMCPConfiguration(targetDir, projectName) {
// Check if mcp.json already exists
if (fs.existsSync(mcpJsonPath)) {
log('info', 'MCP configuration file already exists, updating...');
log(
'info',
'MCP configuration file already exists, checking for existing task-master-mcp...'
);
try {
// Read existing config
const mcpConfig = JSON.parse(fs.readFileSync(mcpJsonPath, 'utf8'));
@@ -935,6 +938,23 @@ function setupMCPConfiguration(targetDir, projectName) {
mcpConfig.mcpServers = {};
}
// Check if any existing server configuration already has task-master-mcp in its args
const hasMCPString = Object.values(mcpConfig.mcpServers).some(
(server) =>
server.args &&
server.args.some(
(arg) => typeof arg === 'string' && arg.includes('task-master-mcp')
)
);
if (hasMCPString) {
log(
'info',
'Found existing task-master-mcp configuration in mcp.json, leaving untouched'
);
return; // Exit early, don't modify the existing configuration
}
// Add the task-master-ai server if it doesn't exist
if (!mcpConfig.mcpServers['task-master-ai']) {
mcpConfig.mcpServers['task-master-ai'] = newMCPServer['task-master-ai'];