git commit -m "fix: improve CLI error handling and standardize option flags

This commit fixes several issues with command line interface error handling:

   1. Fix inconsistent behavior between --no-generate and --skip-generate:
      - Standardized on --skip-generate across all commands
      - Updated bin/task-master.js to use --skip-generate instead of --no-generate
      - Modified add-subtask and remove-subtask commands to use --skip-generate

   2. Enhance error handling for unknown options:
      - Removed .allowUnknownOption() from commands to properly detect unknown options
      - Added global error handler in bin/task-master.js for unknown commands/options
      - Added command-specific error handlers with helpful error messages

   3. Improve user experience with better help messages:
      - Added helper functions to display formatted command help on errors
      - Created command-specific help displays for add-subtask and remove-subtask
      - Show available options when encountering unknown options

   4. Update MCP server configuration:
      - Modified .cursor/mcp.json to use node ./mcp-server/server.js directly
      - Removed npx -y usage for more reliable execution

   5. Other minor improvements:
      - Adjusted column width for task ID display in UI
      - Updated version number in package-lock.json to 0.9.30

   This resolves issues where users would see confusing error messages like
   'error: unknown option --generate' when using an incorrect flag."
This commit is contained in:
Eyal Toledano
2025-03-27 13:32:56 -04:00
parent cea14b55b3
commit 08d3f2db26
7 changed files with 255 additions and 103 deletions

View File

@@ -1,10 +1,9 @@
{
"mcpServers": {
"taskmaster-ai": {
"command": "npx",
"command": "node",
"args": [
"-y",
"bin/task-master-mcp-server.js"
"./mcp-server/server.js"
]
}
}

View File

@@ -13,6 +13,7 @@ import { Command } from 'commander';
import { displayHelp, displayBanner } from '../scripts/modules/ui.js';
import { registerCommands } from '../scripts/modules/commands.js';
import { detectCamelCaseFlags } from '../scripts/modules/utils.js';
import chalk from 'chalk';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -167,7 +168,7 @@ function createDevScriptAction(commandName) {
if (value === true) {
args.push(`--${kebabKey}`);
} else if (value === false && key === 'generate') {
args.push('--no-generate');
args.push('--skip-generate');
}
} else {
// Always use kebab-case for option names
@@ -253,7 +254,6 @@ registerInitCommand(program);
program
.command('dev')
.description('Run the dev.js script')
.allowUnknownOption(true)
.action(() => {
const args = process.argv.slice(process.argv.indexOf('dev') + 1);
runDevScript(args);
@@ -273,8 +273,7 @@ tempProgram.commands.forEach(cmd => {
// Create a new command with the same name and description
const newCmd = program
.command(cmd.name())
.description(cmd.description())
.allowUnknownOption(); // Allow any options, including camelCase ones
.description(cmd.description());
// Copy all options
cmd.options.forEach(opt => {
@@ -292,6 +291,39 @@ tempProgram.commands.forEach(cmd => {
// Parse the command line arguments
program.parse(process.argv);
// Add global error handling for unknown commands and options
process.on('uncaughtException', (err) => {
// Check if this is a commander.js unknown option error
if (err.code === 'commander.unknownOption') {
const option = err.message.match(/'([^']+)'/)?.[1];
const commandArg = process.argv.find(arg => !arg.startsWith('-') &&
arg !== 'task-master' &&
!arg.includes('/') &&
arg !== 'node');
const command = commandArg || 'unknown';
console.error(chalk.red(`Error: Unknown option '${option}'`));
console.error(chalk.yellow(`Run 'task-master ${command} --help' to see available options for this command`));
process.exit(1);
}
// Check if this is a commander.js unknown command error
if (err.code === 'commander.unknownCommand') {
const command = err.message.match(/'([^']+)'/)?.[1];
console.error(chalk.red(`Error: Unknown command '${command}'`));
console.error(chalk.yellow(`Run 'task-master --help' to see available commands`));
process.exit(1);
}
// Handle other uncaught exceptions
console.error(chalk.red(`Error: ${err.message}`));
if (process.env.DEBUG === '1') {
console.error(err);
}
process.exit(1);
});
// Show help if no command was provided (just 'task-master' with no args)
if (process.argv.length <= 2) {
displayBanner();

6
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "task-master-ai",
"version": "0.9.18",
"version": "0.9.30",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "task-master-ai",
"version": "0.9.18",
"version": "0.9.30",
"license": "MIT",
"dependencies": {
"@anthropic-ai/sdk": "^0.39.0",
@@ -29,7 +29,7 @@
"bin": {
"task-master": "bin/task-master.js",
"task-master-init": "bin/task-master-init.js",
"task-master-mcp": "mcp-server/server.js"
"task-master-mcp-server": "mcp-server/server.js"
},
"devDependencies": {
"@types/jest": "^29.5.14",

View File

@@ -47,6 +47,14 @@ import {
* @param {Object} program - Commander program instance
*/
function registerCommands(programInstance) {
// Add global error handler for unknown options
programInstance.on('option:unknown', function(unknownOption) {
const commandName = this._name || 'unknown';
console.error(chalk.red(`Error: Unknown option '${unknownOption}'`));
console.error(chalk.yellow(`Run 'task-master ${commandName} --help' to see available options`));
process.exit(1);
});
// Default help
programInstance.on('--help', function() {
displayHelp();
@@ -524,15 +532,16 @@ function registerCommands(programInstance) {
.option('--details <text>', 'Implementation details for the new subtask')
.option('--dependencies <ids>', 'Comma-separated list of dependency IDs for the new subtask')
.option('-s, --status <status>', 'Status for the new subtask', 'pending')
.option('--no-generate', 'Skip regenerating task files')
.option('--skip-generate', 'Skip regenerating task files')
.action(async (options) => {
const tasksPath = options.file;
const parentId = options.parent;
const existingTaskId = options.taskId;
const generateFiles = options.generate;
const generateFiles = !options.skipGenerate;
if (!parentId) {
console.error(chalk.red('Error: --parent parameter is required. Please provide a parent task ID.'));
showAddSubtaskHelp();
process.exit(1);
}
@@ -594,8 +603,36 @@ function registerCommands(programInstance) {
console.error(chalk.red(`Error: ${error.message}`));
process.exit(1);
}
})
.on('error', function(err) {
console.error(chalk.red(`Error: ${err.message}`));
showAddSubtaskHelp();
process.exit(1);
});
// Helper function to show add-subtask command help
function showAddSubtaskHelp() {
console.log(boxen(
chalk.white.bold('Add Subtask Command Help') + '\n\n' +
chalk.cyan('Usage:') + '\n' +
` task-master add-subtask --parent=<id> [options]\n\n` +
chalk.cyan('Options:') + '\n' +
' -p, --parent <id> Parent task ID (required)\n' +
' -i, --task-id <id> Existing task ID to convert to subtask\n' +
' -t, --title <title> Title for the new subtask\n' +
' -d, --description <text> Description for the new subtask\n' +
' --details <text> Implementation details for the new subtask\n' +
' --dependencies <ids> Comma-separated list of dependency IDs\n' +
' -s, --status <status> Status for the new subtask (default: "pending")\n' +
' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' +
' --skip-generate Skip regenerating task files\n\n' +
chalk.cyan('Examples:') + '\n' +
' task-master add-subtask --parent=5 --task-id=8\n' +
' task-master add-subtask -p 5 -t "Implement login UI" -d "Create the login form"',
{ padding: 1, borderColor: 'blue', borderStyle: 'round' }
));
}
// remove-subtask command
programInstance
.command('remove-subtask')
@@ -603,15 +640,16 @@ function registerCommands(programInstance) {
.option('-f, --file <file>', 'Path to the tasks file', 'tasks/tasks.json')
.option('-i, --id <id>', 'Subtask ID to remove in format "parentId.subtaskId" (required)')
.option('-c, --convert', 'Convert the subtask to a standalone task instead of deleting it')
.option('--no-generate', 'Skip regenerating task files')
.option('--skip-generate', 'Skip regenerating task files')
.action(async (options) => {
const tasksPath = options.file;
const subtaskId = options.id;
const convertToTask = options.convert || false;
const generateFiles = options.generate;
const generateFiles = !options.skipGenerate;
if (!subtaskId) {
console.error(chalk.red('Error: --id parameter is required. Please provide a subtask ID in format "parentId.subtaskId".'));
showRemoveSubtaskHelp();
process.exit(1);
}
@@ -645,10 +683,34 @@ function registerCommands(programInstance) {
}
} catch (error) {
console.error(chalk.red(`Error: ${error.message}`));
showRemoveSubtaskHelp();
process.exit(1);
}
})
.on('error', function(err) {
console.error(chalk.red(`Error: ${err.message}`));
showRemoveSubtaskHelp();
process.exit(1);
});
// Helper function to show remove-subtask command help
function showRemoveSubtaskHelp() {
console.log(boxen(
chalk.white.bold('Remove Subtask Command Help') + '\n\n' +
chalk.cyan('Usage:') + '\n' +
` task-master remove-subtask --id=<parentId.subtaskId> [options]\n\n` +
chalk.cyan('Options:') + '\n' +
' -i, --id <id> Subtask ID to remove in format "parentId.subtaskId" (required)\n' +
' -c, --convert Convert the subtask to a standalone task instead of deleting it\n' +
' -f, --file <file> Path to the tasks file (default: "tasks/tasks.json")\n' +
' --skip-generate Skip regenerating task files\n\n' +
chalk.cyan('Examples:') + '\n' +
' task-master remove-subtask --id=5.2\n' +
' task-master remove-subtask --id=5.2 --convert',
{ padding: 1, borderColor: 'blue', borderStyle: 'round' }
));
}
// init command (documentation only, implementation is in init.js)
programInstance
.command('init')

View File

@@ -760,7 +760,7 @@ async function displayTaskById(tasksPath, taskId) {
const availableWidth = process.stdout.columns - 10 || 100; // Default to 100 if can't detect
// Define percentage-based column widths
const idWidthPct = 8;
const idWidthPct = 10;
const statusWidthPct = 15;
const depsWidthPct = 25;
const titleWidthPct = 100 - idWidthPct - statusWidthPct - depsWidthPct;

View File

@@ -1,18 +1,21 @@
# Task ID: 23
# Title: Complete MCP Server Implementation for Task Master using FastMCP
# Status: pending
# Status: in-progress
# Dependencies: 22
# Priority: medium
# Description: Finalize the MCP server functionality for Task Master by leveraging FastMCP's capabilities, transitioning from CLI-based execution to direct function imports, and optimizing performance, authentication, and context management.
# Description: Finalize the MCP server functionality for Task Master by leveraging FastMCP's capabilities, transitioning from CLI-based execution to direct function imports, and optimizing performance, authentication, and context management. Ensure the server integrates seamlessly with Cursor via `mcp.json` and supports proper tool registration, efficient context handling, and transport type handling (focusing on stdio). Additionally, ensure the server can be instantiated properly when installed via `npx` or `npm i -g`. Evaluate and address gaps in the current implementation, including function imports, context management, caching, tool registration, and adherence to FastMCP best practices.
# Details:
This task involves completing the Model Context Protocol (MCP) server implementation for Task Master using FastMCP. Key updates include:
1. Transition from CLI-based execution to direct Task Master function imports for improved performance and reliability.
2. Enhance authentication and authorization mechanisms using FastMCP's built-in capabilities (e.g., API keys, OAuth, or JWT).
1. Transition from CLI-based execution (currently using `child_process.spawnSync`) to direct Task Master function imports for improved performance and reliability.
2. Implement caching mechanisms for frequently accessed contexts to enhance performance, leveraging FastMCP's efficient transport mechanisms (e.g., stdio).
3. Refactor context management to align with best practices for handling large context windows, metadata, and tagging.
4. Optimize server performance by leveraging FastMCP's efficient transport mechanisms (e.g., stdio or SSE) and implementing caching for frequently accessed contexts.
5. Integrate the ModelContextProtocol SDK directly to streamline resource and tool registration.
6. Update documentation to include examples of using the MCP server with FastMCP, detailed setup instructions, and client integration guides.
4. Refactor tool registration in `tools/index.js` to include clear descriptions and parameter definitions, leveraging FastMCP's decorator-based patterns for better integration.
5. Enhance transport type handling to ensure proper stdio communication and compatibility with FastMCP.
6. Ensure the MCP server can be instantiated and run correctly when installed globally via `npx` or `npm i -g`.
7. Integrate the ModelContextProtocol SDK directly to streamline resource and tool registration, ensuring compatibility with FastMCP's transport mechanisms.
8. Identify and address missing components or functionalities to meet FastMCP best practices, such as robust error handling, monitoring endpoints, and concurrency support.
9. Update documentation to include examples of using the MCP server with FastMCP, detailed setup instructions, and client integration guides.
The implementation must ensure compatibility with existing MCP clients and follow RESTful API design principles, while supporting concurrent requests and maintaining robust error handling.
@@ -20,14 +23,17 @@ The implementation must ensure compatibility with existing MCP clients and follo
Testing for the updated MCP server functionality should include:
1. Unit tests:
- Validate direct function imports for Task Master tools.
- Validate direct function imports for Task Master tools, replacing CLI-based execution.
- Test updated authentication and authorization mechanisms.
- Verify context management operations (CRUD, metadata, windowing).
- Test caching mechanisms for frequently accessed contexts.
- Validate proper tool registration with descriptions and parameters.
2. Integration tests:
- Test the MCP server with FastMCP's stdio and SSE transport modes.
- Test the MCP server with FastMCP's stdio transport mode.
- Verify end-to-end request/response cycles for each endpoint.
- Ensure compatibility with the ModelContextProtocol SDK.
- Test the tool registration process in `tools/index.js` for correctness and efficiency.
3. Performance tests:
- Benchmark response times for context operations with large datasets.
@@ -38,7 +44,11 @@ Testing for the updated MCP server functionality should include:
- Validate the robustness of authentication/authorization mechanisms.
- Test for vulnerabilities such as injection attacks, CSRF, and unauthorized access.
5. Documentation validation:
5. Deployment tests:
- Verify proper server instantiation and operation when installed via `npx` or `npm i -g`.
- Test configuration loading from `mcp.json`.
6. Documentation validation:
- Ensure all examples in the documentation are accurate and functional.
- Verify manual testing workflows using tools like curl or Postman.
@@ -112,54 +122,6 @@ Testing approach:
- Test error handling with invalid inputs
- Benchmark endpoint performance
## 4. Implement Authentication and Authorization System [pending]
### Dependencies: 23.1, 23.3
### Description: Create a secure authentication and authorization mechanism for MCP clients to ensure only authorized applications can access the MCP server functionality.
### Details:
Implementation steps:
1. Design authentication scheme (API keys, OAuth, JWT, etc.)
2. Implement authentication middleware for all MCP endpoints
3. Create an API key management system for client applications
4. Develop role-based access control for different operations
5. Implement rate limiting to prevent abuse
6. Add secure token validation and handling
7. Create endpoints for managing client credentials
8. Implement audit logging for authentication events
Testing approach:
- Security testing for authentication mechanisms
- Test access control with various permission levels
- Verify rate limiting functionality
- Test token validation with valid and invalid tokens
- Simulate unauthorized access attempts
- Verify audit logs contain appropriate information
## 5. Optimize Performance and Finalize Documentation [pending]
### Dependencies: 23.1, 23.2, 23.3, 23.4
### Description: Optimize the MCP server implementation for performance, especially for context retrieval operations, and create comprehensive documentation for users.
### Details:
Implementation steps:
1. Profile the MCP server to identify performance bottlenecks
2. Replace CLI-based execution with direct Task Master function imports
3. Implement caching mechanisms for frequently accessed contexts
4. Optimize context serialization and deserialization
5. Leverage FastMCP's efficient transport mechanisms (stdio or SSE)
6. Add connection pooling for database operations (if applicable)
7. Implement request batching for bulk operations
8. Create comprehensive API documentation with examples
9. Add setup and configuration guides to the Task Master documentation
10. Create example client implementations
11. Add monitoring endpoints for server health and metrics
12. Implement graceful degradation under high load
Testing approach:
- Load testing with simulated concurrent clients
- Measure response times for various operations
- Test with large context sizes to verify performance
- Verify documentation accuracy with sample requests
- Test monitoring endpoints
- Perform stress testing to identify failure points
## 6. Refactor MCP Server to Leverage ModelContextProtocol SDK [pending]
### Dependencies: 23.1, 23.2, 23.3
### Description: Integrate the ModelContextProtocol SDK directly into the MCP server implementation to streamline tool registration and resource handling.
@@ -176,3 +138,58 @@ Testing approach:
- Validate compatibility with existing MCP clients.
- Benchmark performance improvements from SDK integration.
## 8. Implement Direct Function Imports and Replace CLI-based Execution [pending]
### Dependencies: None
### Description: Refactor the MCP server implementation to use direct Task Master function imports instead of the current CLI-based execution using child_process.spawnSync. This will improve performance, reliability, and enable better error handling.
### Details:
1. Create a new module to import and expose Task Master core functions directly
2. Modify tools/utils.js to remove executeTaskMasterCommand and replace with direct function calls
3. Update each tool implementation (listTasks.js, showTask.js, etc.) to use the direct function imports
4. Implement proper error handling with try/catch blocks and FastMCP's MCPError
5. Add unit tests to verify the function imports work correctly
6. Test performance improvements by comparing response times between CLI and function import approaches
## 9. Implement Context Management and Caching Mechanisms [pending]
### Dependencies: 23.1
### Description: Enhance the MCP server with proper context management and caching to improve performance and user experience, especially for frequently accessed data and contexts.
### Details:
1. Implement a context manager class that leverages FastMCP's Context object
2. Add caching for frequently accessed task data with configurable TTL settings
3. Implement context tagging for better organization of context data
4. Add methods to efficiently handle large context windows
5. Create helper functions for storing and retrieving context data
6. Implement cache invalidation strategies for task updates
7. Add cache statistics for monitoring performance
8. Create unit tests for context management and caching functionality
## 10. Enhance Tool Registration and Resource Management [pending]
### Dependencies: 23.1
### Description: Refactor tool registration to follow FastMCP best practices, using decorators and improving the overall structure. Implement proper resource management for task templates and other shared resources.
### Details:
1. Update registerTaskMasterTools function to use FastMCP's decorator pattern
2. Implement @mcp.tool() decorators for all existing tools
3. Add proper type annotations and documentation for all tools
4. Create resource handlers for task templates using @mcp.resource()
5. Implement resource templates for common task patterns
6. Update the server initialization to properly register all tools and resources
7. Add validation for tool inputs using FastMCP's built-in validation
8. Create comprehensive tests for tool registration and resource access
## 11. Implement Comprehensive Error Handling [pending]
### Dependencies: 23.1, 23.3
### Description: Implement robust error handling using FastMCP's MCPError, including custom error types for different categories and standardized error responses.
### Details:
1. Create custom error types extending MCPError for different categories (validation, auth, etc.)\n2. Implement standardized error responses following MCP protocol\n3. Add error handling middleware for all MCP endpoints\n4. Ensure proper error propagation from tools to client\n5. Add debug mode with detailed error information\n6. Document error types and handling patterns
## 12. Implement Structured Logging System [pending]
### Dependencies: 23.1, 23.3
### Description: Implement a comprehensive logging system for the MCP server with different log levels, structured logging format, and request/response tracking.
### Details:
1. Design structured log format for consistent parsing\n2. Implement different log levels (debug, info, warn, error)\n3. Add request/response logging middleware\n4. Implement correlation IDs for request tracking\n5. Add performance metrics logging\n6. Configure log output destinations (console, file)\n7. Document logging patterns and usage
## 13. Create Testing Framework and Test Suite [pending]
### Dependencies: 23.1, 23.3, 23.8
### Description: Implement a comprehensive testing framework for the MCP server, including unit tests, integration tests, and end-to-end tests.
### Details:
1. Set up Jest testing framework with proper configuration\n2. Create MCPTestClient for testing FastMCP server interaction\n3. Implement unit tests for individual tool functions\n4. Create integration tests for end-to-end request/response cycles\n5. Set up test fixtures and mock data\n6. Implement test coverage reporting\n7. Document testing guidelines and examples

View File

@@ -1337,14 +1337,14 @@
{
"id": 23,
"title": "Complete MCP Server Implementation for Task Master using FastMCP",
"description": "Finalize the MCP server functionality for Task Master by leveraging FastMCP's capabilities, transitioning from CLI-based execution to direct function imports, and optimizing performance, authentication, and context management.",
"status": "pending",
"description": "Finalize the MCP server functionality for Task Master by leveraging FastMCP's capabilities, transitioning from CLI-based execution to direct function imports, and optimizing performance, authentication, and context management. Ensure the server integrates seamlessly with Cursor via `mcp.json` and supports proper tool registration, efficient context handling, and transport type handling (focusing on stdio). Additionally, ensure the server can be instantiated properly when installed via `npx` or `npm i -g`. Evaluate and address gaps in the current implementation, including function imports, context management, caching, tool registration, and adherence to FastMCP best practices.",
"status": "in-progress",
"dependencies": [
22
],
"priority": "medium",
"details": "This task involves completing the Model Context Protocol (MCP) server implementation for Task Master using FastMCP. Key updates include:\n\n1. Transition from CLI-based execution to direct Task Master function imports for improved performance and reliability.\n2. Enhance authentication and authorization mechanisms using FastMCP's built-in capabilities (e.g., API keys, OAuth, or JWT).\n3. Refactor context management to align with best practices for handling large context windows, metadata, and tagging.\n4. Optimize server performance by leveraging FastMCP's efficient transport mechanisms (e.g., stdio or SSE) and implementing caching for frequently accessed contexts.\n5. Integrate the ModelContextProtocol SDK directly to streamline resource and tool registration.\n6. Update documentation to include examples of using the MCP server with FastMCP, detailed setup instructions, and client integration guides.\n\nThe implementation must ensure compatibility with existing MCP clients and follow RESTful API design principles, while supporting concurrent requests and maintaining robust error handling.",
"testStrategy": "Testing for the updated MCP server functionality should include:\n\n1. Unit tests:\n - Validate direct function imports for Task Master tools.\n - Test updated authentication and authorization mechanisms.\n - Verify context management operations (CRUD, metadata, windowing).\n\n2. Integration tests:\n - Test the MCP server with FastMCP's stdio and SSE transport modes.\n - Verify end-to-end request/response cycles for each endpoint.\n - Ensure compatibility with the ModelContextProtocol SDK.\n\n3. Performance tests:\n - Benchmark response times for context operations with large datasets.\n - Test caching mechanisms and concurrent request handling.\n - Measure memory usage and server stability under load.\n\n4. Security tests:\n - Validate the robustness of authentication/authorization mechanisms.\n - Test for vulnerabilities such as injection attacks, CSRF, and unauthorized access.\n\n5. Documentation validation:\n - Ensure all examples in the documentation are accurate and functional.\n - Verify manual testing workflows using tools like curl or Postman.\n\nAll tests should be automated and integrated into the CI/CD pipeline to ensure consistent quality.",
"details": "This task involves completing the Model Context Protocol (MCP) server implementation for Task Master using FastMCP. Key updates include:\n\n1. Transition from CLI-based execution (currently using `child_process.spawnSync`) to direct Task Master function imports for improved performance and reliability.\n2. Implement caching mechanisms for frequently accessed contexts to enhance performance, leveraging FastMCP's efficient transport mechanisms (e.g., stdio).\n3. Refactor context management to align with best practices for handling large context windows, metadata, and tagging.\n4. Refactor tool registration in `tools/index.js` to include clear descriptions and parameter definitions, leveraging FastMCP's decorator-based patterns for better integration.\n5. Enhance transport type handling to ensure proper stdio communication and compatibility with FastMCP.\n6. Ensure the MCP server can be instantiated and run correctly when installed globally via `npx` or `npm i -g`.\n7. Integrate the ModelContextProtocol SDK directly to streamline resource and tool registration, ensuring compatibility with FastMCP's transport mechanisms.\n8. Identify and address missing components or functionalities to meet FastMCP best practices, such as robust error handling, monitoring endpoints, and concurrency support.\n9. Update documentation to include examples of using the MCP server with FastMCP, detailed setup instructions, and client integration guides.\n\nThe implementation must ensure compatibility with existing MCP clients and follow RESTful API design principles, while supporting concurrent requests and maintaining robust error handling.",
"testStrategy": "Testing for the updated MCP server functionality should include:\n\n1. Unit tests:\n - Validate direct function imports for Task Master tools, replacing CLI-based execution.\n - Test updated authentication and authorization mechanisms.\n - Verify context management operations (CRUD, metadata, windowing).\n - Test caching mechanisms for frequently accessed contexts.\n - Validate proper tool registration with descriptions and parameters.\n\n2. Integration tests:\n - Test the MCP server with FastMCP's stdio transport mode.\n - Verify end-to-end request/response cycles for each endpoint.\n - Ensure compatibility with the ModelContextProtocol SDK.\n - Test the tool registration process in `tools/index.js` for correctness and efficiency.\n\n3. Performance tests:\n - Benchmark response times for context operations with large datasets.\n - Test caching mechanisms and concurrent request handling.\n - Measure memory usage and server stability under load.\n\n4. Security tests:\n - Validate the robustness of authentication/authorization mechanisms.\n - Test for vulnerabilities such as injection attacks, CSRF, and unauthorized access.\n\n5. Deployment tests:\n - Verify proper server instantiation and operation when installed via `npx` or `npm i -g`.\n - Test configuration loading from `mcp.json`.\n\n6. Documentation validation:\n - Ensure all examples in the documentation are accurate and functional.\n - Verify manual testing workflows using tools like curl or Postman.\n\nAll tests should be automated and integrated into the CI/CD pipeline to ensure consistent quality.",
"subtasks": [
{
"id": 1,
@@ -1378,32 +1378,6 @@
"status": "done",
"parentTaskId": 23
},
{
"id": 4,
"title": "Implement Authentication and Authorization System",
"description": "Create a secure authentication and authorization mechanism for MCP clients to ensure only authorized applications can access the MCP server functionality.",
"dependencies": [
1,
3
],
"details": "Implementation steps:\n1. Design authentication scheme (API keys, OAuth, JWT, etc.)\n2. Implement authentication middleware for all MCP endpoints\n3. Create an API key management system for client applications\n4. Develop role-based access control for different operations\n5. Implement rate limiting to prevent abuse\n6. Add secure token validation and handling\n7. Create endpoints for managing client credentials\n8. Implement audit logging for authentication events\n\nTesting approach:\n- Security testing for authentication mechanisms\n- Test access control with various permission levels\n- Verify rate limiting functionality\n- Test token validation with valid and invalid tokens\n- Simulate unauthorized access attempts\n- Verify audit logs contain appropriate information",
"status": "pending",
"parentTaskId": 23
},
{
"id": 5,
"title": "Optimize Performance and Finalize Documentation",
"description": "Optimize the MCP server implementation for performance, especially for context retrieval operations, and create comprehensive documentation for users.",
"dependencies": [
1,
2,
3,
4
],
"details": "Implementation steps:\n1. Profile the MCP server to identify performance bottlenecks\n2. Replace CLI-based execution with direct Task Master function imports\n3. Implement caching mechanisms for frequently accessed contexts\n4. Optimize context serialization and deserialization\n5. Leverage FastMCP's efficient transport mechanisms (stdio or SSE)\n6. Add connection pooling for database operations (if applicable)\n7. Implement request batching for bulk operations\n8. Create comprehensive API documentation with examples\n9. Add setup and configuration guides to the Task Master documentation\n10. Create example client implementations\n11. Add monitoring endpoints for server health and metrics\n12. Implement graceful degradation under high load\n\nTesting approach:\n- Load testing with simulated concurrent clients\n- Measure response times for various operations\n- Test with large context sizes to verify performance\n- Verify documentation accuracy with sample requests\n- Test monitoring endpoints\n- Perform stress testing to identify failure points",
"status": "pending",
"parentTaskId": 23
},
{
"id": 6,
"title": "Refactor MCP Server to Leverage ModelContextProtocol SDK",
@@ -1416,6 +1390,74 @@
"details": "Implementation steps:\n1. Replace manual tool registration with ModelContextProtocol SDK methods.\n2. Use SDK utilities to simplify resource and template management.\n3. Ensure compatibility with FastMCP's transport mechanisms.\n4. Update server initialization to include SDK-based configurations.\n\nTesting approach:\n- Verify SDK integration with all MCP endpoints.\n- Test resource and template registration using SDK methods.\n- Validate compatibility with existing MCP clients.\n- Benchmark performance improvements from SDK integration.",
"status": "pending",
"parentTaskId": 23
},
{
"id": 8,
"title": "Implement Direct Function Imports and Replace CLI-based Execution",
"description": "Refactor the MCP server implementation to use direct Task Master function imports instead of the current CLI-based execution using child_process.spawnSync. This will improve performance, reliability, and enable better error handling.",
"dependencies": [],
"details": "1. Create a new module to import and expose Task Master core functions directly\n2. Modify tools/utils.js to remove executeTaskMasterCommand and replace with direct function calls\n3. Update each tool implementation (listTasks.js, showTask.js, etc.) to use the direct function imports\n4. Implement proper error handling with try/catch blocks and FastMCP's MCPError\n5. Add unit tests to verify the function imports work correctly\n6. Test performance improvements by comparing response times between CLI and function import approaches",
"status": "pending",
"parentTaskId": 23
},
{
"id": 9,
"title": "Implement Context Management and Caching Mechanisms",
"description": "Enhance the MCP server with proper context management and caching to improve performance and user experience, especially for frequently accessed data and contexts.",
"dependencies": [
1
],
"details": "1. Implement a context manager class that leverages FastMCP's Context object\n2. Add caching for frequently accessed task data with configurable TTL settings\n3. Implement context tagging for better organization of context data\n4. Add methods to efficiently handle large context windows\n5. Create helper functions for storing and retrieving context data\n6. Implement cache invalidation strategies for task updates\n7. Add cache statistics for monitoring performance\n8. Create unit tests for context management and caching functionality",
"status": "pending",
"parentTaskId": 23
},
{
"id": 10,
"title": "Enhance Tool Registration and Resource Management",
"description": "Refactor tool registration to follow FastMCP best practices, using decorators and improving the overall structure. Implement proper resource management for task templates and other shared resources.",
"dependencies": [
1
],
"details": "1. Update registerTaskMasterTools function to use FastMCP's decorator pattern\n2. Implement @mcp.tool() decorators for all existing tools\n3. Add proper type annotations and documentation for all tools\n4. Create resource handlers for task templates using @mcp.resource()\n5. Implement resource templates for common task patterns\n6. Update the server initialization to properly register all tools and resources\n7. Add validation for tool inputs using FastMCP's built-in validation\n8. Create comprehensive tests for tool registration and resource access",
"status": "pending",
"parentTaskId": 23
},
{
"id": 11,
"title": "Implement Comprehensive Error Handling",
"description": "Implement robust error handling using FastMCP's MCPError, including custom error types for different categories and standardized error responses.",
"details": "1. Create custom error types extending MCPError for different categories (validation, auth, etc.)\\n2. Implement standardized error responses following MCP protocol\\n3. Add error handling middleware for all MCP endpoints\\n4. Ensure proper error propagation from tools to client\\n5. Add debug mode with detailed error information\\n6. Document error types and handling patterns",
"status": "pending",
"dependencies": [
"23.1",
"23.3"
],
"parentTaskId": 23
},
{
"id": 12,
"title": "Implement Structured Logging System",
"description": "Implement a comprehensive logging system for the MCP server with different log levels, structured logging format, and request/response tracking.",
"details": "1. Design structured log format for consistent parsing\\n2. Implement different log levels (debug, info, warn, error)\\n3. Add request/response logging middleware\\n4. Implement correlation IDs for request tracking\\n5. Add performance metrics logging\\n6. Configure log output destinations (console, file)\\n7. Document logging patterns and usage",
"status": "pending",
"dependencies": [
"23.1",
"23.3"
],
"parentTaskId": 23
},
{
"id": 13,
"title": "Create Testing Framework and Test Suite",
"description": "Implement a comprehensive testing framework for the MCP server, including unit tests, integration tests, and end-to-end tests.",
"details": "1. Set up Jest testing framework with proper configuration\\n2. Create MCPTestClient for testing FastMCP server interaction\\n3. Implement unit tests for individual tool functions\\n4. Create integration tests for end-to-end request/response cycles\\n5. Set up test fixtures and mock data\\n6. Implement test coverage reporting\\n7. Document testing guidelines and examples",
"status": "pending",
"dependencies": [
"23.1",
"23.3",
"23.8"
],
"parentTaskId": 23
}
]
},