feat(extension): implement simple solution to --package flag (#1090)

* feat(extension): implement simple solution to --package flag
This commit is contained in:
Ralph Khreish
2025-08-07 15:10:34 +02:00
committed by GitHub
parent 3a852afdae
commit a464e550b8
5 changed files with 100 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
---
"extension": patch
---
Fix issues with some users not being able to connect to Taskmaster MCP server while using the extension

View File

@@ -64,16 +64,16 @@
"properties": { "properties": {
"taskmaster.mcp.command": { "taskmaster.mcp.command": {
"type": "string", "type": "string",
"default": "npx", "default": "node",
"description": "The command or absolute path to execute for the MCP server (e.g., 'npx' or '/usr/local/bin/task-master-ai')." "description": "The command to execute for the MCP server (e.g., 'node' for bundled server or 'npx' for remote)."
}, },
"taskmaster.mcp.args": { "taskmaster.mcp.args": {
"type": "array", "type": "array",
"items": { "items": {
"type": "string" "type": "string"
}, },
"default": ["task-master-ai"], "default": [],
"description": "An array of arguments to pass to the MCP server command." "description": "Arguments for the MCP server (leave empty to use bundled server)."
}, },
"taskmaster.mcp.cwd": { "taskmaster.mcp.cwd": {
"type": "string", "type": "string",
@@ -238,6 +238,9 @@
"watch:css": "npx @tailwindcss/cli -i ./src/webview/index.css -o ./dist/index.css --watch", "watch:css": "npx @tailwindcss/cli -i ./src/webview/index.css -o ./dist/index.css --watch",
"check-types": "tsc --noEmit" "check-types": "tsc --noEmit"
}, },
"dependencies": {
"task-master-ai": "*"
},
"devDependencies": { "devDependencies": {
"@dnd-kit/core": "^6.3.1", "@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/modifiers": "^9.0.0",

View File

@@ -2,7 +2,7 @@
"name": "task-master-hamster", "name": "task-master-hamster",
"displayName": "Taskmaster AI", "displayName": "Taskmaster AI",
"description": "A visual Kanban board interface for Taskmaster projects in VS Code", "description": "A visual Kanban board interface for Taskmaster projects in VS Code",
"version": "0.22.3", "version": "0.23.0",
"publisher": "Hamster", "publisher": "Hamster",
"icon": "assets/icon.png", "icon": "assets/icon.png",
"engines": { "engines": {

View File

@@ -1,6 +1,7 @@
import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'; import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import * as path from 'path';
import { logger } from './logger'; import { logger } from './logger';
export interface MCPConfig { export interface MCPConfig {
@@ -143,7 +144,7 @@ export class MCPClientManager {
// Create the client // Create the client
this.client = new Client( this.client = new Client(
{ {
name: 'taskr-vscode-extension', name: 'task-master-vscode-extension',
version: '1.0.0' version: '1.0.0'
}, },
{ {
@@ -211,6 +212,30 @@ export class MCPClientManager {
}; };
logger.log('MCP client connected successfully'); logger.log('MCP client connected successfully');
// Log Task Master version information after successful connection
try {
const versionResult = await this.callTool('get_tasks', {});
if (versionResult?.content?.[0]?.text) {
const response = JSON.parse(versionResult.content[0].text);
if (response?.version) {
logger.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
logger.log('✅ Task Master MCP Server Connected');
logger.log(` Version: ${response.version.version || 'unknown'}`);
logger.log(
` Package: ${response.version.name || 'task-master-ai'}`
);
if (response.tag) {
logger.log(
` Current Tag: ${response.tag.currentTag || 'master'}`
);
}
logger.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
}
}
} catch (versionError) {
logger.log('Note: Could not retrieve Task Master version information');
}
} catch (error) { } catch (error) {
logger.error('Failed to connect to MCP server:', error); logger.error('Failed to connect to MCP server:', error);
this.status = { this.status = {
@@ -312,6 +337,34 @@ export class MCPClientManager {
'Available MCP tools:', 'Available MCP tools:',
result.tools?.map((t) => t.name) || [] result.tools?.map((t) => t.name) || []
); );
// Try to get version information by calling a simple tool
// The get_tasks tool is lightweight and returns version info
try {
const versionResult = await this.callTool('get_tasks', {});
if (versionResult?.content?.[0]?.text) {
// Parse the response to extract version info
const response = JSON.parse(versionResult.content[0].text);
if (response?.version) {
logger.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
logger.log('📦 Task Master MCP Server Connected');
logger.log(` Version: ${response.version.version || 'unknown'}`);
logger.log(
` Package: ${response.version.name || 'task-master-ai'}`
);
if (response.tag) {
logger.log(
` Current Tag: ${response.tag.currentTag || 'master'}`
);
}
logger.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
}
}
} catch (versionError) {
// Don't fail the connection test if we can't get version info
logger.log('Could not retrieve Task Master version information');
}
return true; return true;
} catch (error) { } catch (error) {
logger.error('Connection test failed:', error); logger.error('Connection test failed:', error);
@@ -345,8 +398,34 @@ export function createMCPConfigFromSettings(): MCPConfig {
); );
const config = vscode.workspace.getConfiguration('taskmaster'); const config = vscode.workspace.getConfiguration('taskmaster');
let command = config.get<string>('mcp.command', 'npx'); let command = config.get<string>('mcp.command', 'node');
const args = config.get<string[]>('mcp.args', ['task-master-ai']); let args = config.get<string[]>('mcp.args', []);
// If using default settings, use the bundled MCP server
if (command === 'node' && args.length === 0) {
try {
// Try to resolve the bundled MCP server
const taskMasterPath = require.resolve('task-master-ai');
const mcpServerPath = path.resolve(
path.dirname(taskMasterPath),
'mcp-server/server.js'
);
// Verify the server file exists
const fs = require('fs');
if (!fs.existsSync(mcpServerPath)) {
throw new Error('MCP server file not found at: ' + mcpServerPath);
}
args = [mcpServerPath];
logger.log(`📦 Using bundled MCP server at: ${mcpServerPath}`);
} catch (error) {
logger.error('❌ Could not find bundled task-master-ai server:', error);
// Fallback to npx
command = 'npx';
args = ['-y', 'task-master-ai'];
}
}
// Use proper VS Code workspace detection // Use proper VS Code workspace detection
const defaultCwd = const defaultCwd =

7
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "task-master-ai", "name": "task-master-ai",
"version": "0.23.0", "version": "0.23.1-rc.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "task-master-ai", "name": "task-master-ai",
"version": "0.23.0", "version": "0.23.1-rc.0",
"license": "MIT WITH Commons-Clause", "license": "MIT WITH Commons-Clause",
"workspaces": [ "workspaces": [
"apps/*", "apps/*",
@@ -86,6 +86,9 @@
}, },
"apps/extension": { "apps/extension": {
"version": "0.23.0", "version": "0.23.0",
"dependencies": {
"task-master-ai": "*"
},
"devDependencies": { "devDependencies": {
"@dnd-kit/core": "^6.3.1", "@dnd-kit/core": "^6.3.1",
"@dnd-kit/modifiers": "^9.0.0", "@dnd-kit/modifiers": "^9.0.0",