Skip to main content
Glama
bsmi021

MCP Task Manager Server

by bsmi021

addTask

Creates a new task within a specified project by submitting a description, project ID, and optional details like dependencies, priority, and status. Returns the full task details.

Instructions

Adds a new task to a specified project within the Task Management Server. Requires the project ID and a description for the task. Optionally accepts a list of dependency task IDs, a priority level, and an initial status. Returns the full details of the newly created task upon success.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dependenciesNoAn optional list of task IDs (strings) that must be completed before this task can start (max 50).
descriptionYesThe textual description of the task to be performed (1-1024 characters).
priorityNoOptional task priority. Defaults to 'medium' if not specified.medium
project_idYesThe unique identifier (UUID) of the project to add the task to. This project must already exist.
statusNoOptional initial status of the task. Defaults to 'todo' if not specified.todo

Implementation Reference

  • The main execution handler for the addTask tool. It processes the input arguments, calls the TaskService to add the task, returns the created task as JSON, and handles errors appropriately by throwing MCP-standard errors.
    const processRequest = async (args: AddTaskArgs) => {
        logger.info(`[${TOOL_NAME}] Received request with args:`, args);
        try {
            // Call the service method to add the task
            // The Zod schema handles basic type/format/length validation
            const newTask = await taskService.addTask({
                project_id: args.project_id,
                description: args.description,
                dependencies: args.dependencies, // Pass optional fields
                priority: args.priority,
                status: args.status,
            });
    
            // Format the successful response according to MCP standards
            // Return the full details of the created task as per spec FR-FS-011
            logger.info(`[${TOOL_NAME}] Task added successfully: ${newTask.task_id}`);
            return {
                content: [{
                    type: "text" as const,
                    text: JSON.stringify(newTask) // Return the full task object
                }]
            };
        } catch (error: unknown) {
            // Handle potential errors from the service layer
            logger.error(`[${TOOL_NAME}] Error processing request:`, error);
    
            if (error instanceof NotFoundError) {
                // Specific error if the project wasn't found - map to InvalidParams as project_id is invalid
                throw new McpError(ErrorCode.InvalidParams, error.message);
            } else if (error instanceof ValidationError) {
                // Specific error for validation issues within the service (e.g., dependency check if implemented)
                throw new McpError(ErrorCode.InvalidParams, error.message);
            } else {
                // Generic internal error for database issues or unexpected problems
                const message = error instanceof Error ? error.message : 'An unknown error occurred while adding the task.';
                throw new McpError(ErrorCode.InternalError, message);
            }
        }
    };
  • Zod schema (TOOL_PARAMS) defining the input parameters for the addTask tool, including validation rules, descriptions, defaults, and enums for priority and status.
    export const TOOL_PARAMS = z.object({
        project_id: z.string()
            .uuid("The project_id must be a valid UUID.")
            .describe("The unique identifier (UUID) of the project to add the task to. This project must already exist."), // Required, UUID format
    
        description: z.string()
            .min(1, "Task description cannot be empty.")
            .max(1024, "Task description cannot exceed 1024 characters.")
            .describe("The textual description of the task to be performed (1-1024 characters)."), // Required, length limits
    
        dependencies: z.array(z.string().describe("A task ID that this new task depends on.")) // Allow any string for now, existence checked in service (or deferred)
            .max(50, "A task cannot have more than 50 dependencies.")
            .optional()
            .describe("An optional list of task IDs (strings) that must be completed before this task can start (max 50)."), // Optional, array of strings, count limit
    
        priority: TaskPriorityEnum
            .optional()
            .default('medium') // Default value
            .describe("Optional task priority. Defaults to 'medium' if not specified."), // Optional, enum, default
    
        status: TaskStatusEnum
            .optional()
            .default('todo') // Default value
            .describe("Optional initial status of the task. Defaults to 'todo' if not specified."), // Optional, enum, default
    });
  • The addTaskTool function that registers the tool with the MCP server using server.tool(), providing name, description, schema shape, and handler. This function is invoked from tools/index.ts.
    export const addTaskTool = (server: McpServer, taskService: TaskService): void => {
    
        // Define the asynchronous function that handles the actual tool logic
        const processRequest = async (args: AddTaskArgs) => {
            logger.info(`[${TOOL_NAME}] Received request with args:`, args);
            try {
                // Call the service method to add the task
                // The Zod schema handles basic type/format/length validation
                const newTask = await taskService.addTask({
                    project_id: args.project_id,
                    description: args.description,
                    dependencies: args.dependencies, // Pass optional fields
                    priority: args.priority,
                    status: args.status,
                });
    
                // Format the successful response according to MCP standards
                // Return the full details of the created task as per spec FR-FS-011
                logger.info(`[${TOOL_NAME}] Task added successfully: ${newTask.task_id}`);
                return {
                    content: [{
                        type: "text" as const,
                        text: JSON.stringify(newTask) // Return the full task object
                    }]
                };
            } catch (error: unknown) {
                // Handle potential errors from the service layer
                logger.error(`[${TOOL_NAME}] Error processing request:`, error);
    
                if (error instanceof NotFoundError) {
                    // Specific error if the project wasn't found - map to InvalidParams as project_id is invalid
                    throw new McpError(ErrorCode.InvalidParams, error.message);
                } else if (error instanceof ValidationError) {
                    // Specific error for validation issues within the service (e.g., dependency check if implemented)
                    throw new McpError(ErrorCode.InvalidParams, error.message);
                } else {
                    // Generic internal error for database issues or unexpected problems
                    const message = error instanceof Error ? error.message : 'An unknown error occurred while adding the task.';
                    throw new McpError(ErrorCode.InternalError, message);
                }
            }
        };
    
        // Register the tool with the server, passing the shape of the Zod object
        server.tool(TOOL_NAME, TOOL_DESCRIPTION, TOOL_PARAMS.shape, processRequest);
    
        logger.info(`[${TOOL_NAME}] Tool registered successfully.`);
    };
  • TaskService.addTask helper method that validates the project exists, generates task ID and timestamps, prepares task data, and delegates persistence to the TaskRepository.
    public async addTask(input: AddTaskInput): Promise<TaskData> {
        logger.info(`[TaskService] Attempting to add task to project: ${input.project_id}`);
        const projectExists = this.projectRepository.findById(input.project_id);
        if (!projectExists) {
            logger.warn(`[TaskService] Project not found: ${input.project_id}`);
            throw new NotFoundError(`Project with ID ${input.project_id} not found.`);
        }
    
        const taskId = uuidv4();
        const now = new Date().toISOString();
        const newTaskData: TaskData = {
            task_id: taskId,
            project_id: input.project_id,
            parent_task_id: null,
            description: input.description,
            status: input.status ?? 'todo',
            priority: input.priority ?? 'medium',
            created_at: now,
            updated_at: now,
        };
    
        // TODO: Validate Dependency Existence
    
        try {
            this.taskRepository.create(newTaskData, input.dependencies);
            logger.info(`[TaskService] Successfully added task ${taskId} to project ${input.project_id}`);
            return newTaskData;
        } catch (error) {
            logger.error(`[TaskService] Error adding task to project ${input.project_id}:`, error);
            throw error;
        }
    }
  • Invocation of addTaskTool during overall tools registration in the central index file, passing the server and taskService instance.
    addTaskTool(server, taskService);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions that the tool 'Returns the full details of the newly created task upon success', which adds some behavioral context. However, it lacks details on permissions, error conditions, or side effects (e.g., whether dependencies are validated). For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose, followed by parameter and return details in clear, concise sentences. Every sentence adds value without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (mutation with 5 parameters) and lack of annotations or output schema, the description is moderately complete. It covers the purpose, parameters, and return value, but it could better address behavioral aspects like error handling or dependencies validation. It is adequate but has gaps in transparency.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description lists the parameters ('project ID', 'description', 'dependency task IDs', 'priority level', 'initial status') but does not add meaningful semantics beyond what the schema provides, such as explaining interactions between parameters. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Adds a new task') and the target resource ('to a specified project within the Task Management Server'), which is specific and unambiguous. It distinguishes this tool from sibling tools like 'createProject' (which creates projects) and 'updateTask' (which modifies existing tasks).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by mentioning required parameters ('Requires the project ID and a description'), but it does not explicitly state when to use this tool versus alternatives like 'updateTask' or 'setTaskStatus'. No guidance is provided on prerequisites or exclusions beyond the parameter requirements.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsmi021/mcp-task-manager-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server