Skip to main content
Glama

Add TODO Task

add_todo_task

Add new tasks to an existing TODO list with full markdown support, code examples, and logical sequencing. Use to expand, clarify, or append tasks in project workflows on the Knowledge MCP Server.

Instructions

Add a new task to an existing TODO list with full markdown support.

When to use this tool:

  • Expanding existing TODO with new tasks

  • Adding discovered subtasks during work

  • Including additional requirements

  • Appending follow-up tasks

  • Adding clarifications or details

Key features:

  • Full markdown support in content

  • Can include code blocks and examples

  • Auto-incrementing task numbers

  • Preserves existing task order

  • Rich formatting capabilities

You should:

  1. Verify TODO exists first

  2. Use clear, actionable task titles (max 200 chars)

  3. Include implementation details in content

  4. Add code examples where helpful

  5. Position task logically in sequence

  6. Keep task scope focused

  7. Use markdown formatting effectively

DO NOT use when:

  • TODO doesn't exist

  • Task duplicates existing one

  • Task is too vague or broad

Returns: {success: bool, task_number: int, message: str, error?: str}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentNoFull markdown content with implementation details, code examples, etc.
project_idYesThe project identifier
titleYesBrief task title (max 200 chars, used in filename)
todo_numberYesThe TODO list number

Implementation Reference

  • Executes the 'add_todo_task' tool logic: validates input, ensures project and TODO exist, generates next task number and filename, creates markdown task file with YAML frontmatter metadata (created/updated timestamps, incomplete status), title header, and optional content, auto-commits changes to git storage.
    async addTodoTaskAsync(params: {
      project_id: z.infer<typeof secureProjectIdSchema>;
      todo_number: z.infer<typeof secureTodoNumberSchema>;
      title: z.infer<typeof secureTaskTitleSchema>;
      content?: z.infer<typeof secureTaskContentSchema>;
    }): Promise<string> {
      const context = this.createContext('add_todo_task', params);
    
      try {
        const { project_id, todo_number, title, content = '' } = params;
        const [, projectPath] = await createProjectEntryAsync(this.storagePath, project_id);
        const todoDir = join(projectPath, 'TODO', todo_number.toString());
    
        // Check if TODO exists
        try {
          await access(todoDir);
        } catch {
          throw new MCPError(MCPErrorCode.TODO_NOT_FOUND, `TODO #${todo_number} not found`, {
            project_id,
            todo_number,
            traceId: context.traceId,
          });
        }
    
        // Get next task number
        const taskNumber = await this.getNextTaskNumberAsync(todoDir);
        const taskFilename = `TASK-${taskNumber.toString().padStart(3, '0')}-${slugify(title, { lower: true, strict: true })}.md`;
    
        // Create task metadata
        const metadata: TaskMetadata = {
          completed: false,
          created: new Date().toISOString(),
          updated: new Date().toISOString(),
        };
    
        // Write task file
        const frontmatter = yaml.dump(metadata);
        const taskContent = `---\n${frontmatter}---\n\n# ${title}\n\n${content || ''}`;
        await writeFile(join(todoDir, taskFilename), taskContent);
    
        // Auto-commit
        await autoCommitAsync(this.storagePath, `Add task "${title}" to TODO #${todo_number}`);
    
        this.logSuccess(
          'add_todo_task',
          { project_id, todo_number, task_number: taskNumber },
          context
        );
        return this.formatSuccessResponse({
          task_number: taskNumber,
          message: `Added task #${taskNumber} to TODO #${todo_number}`,
        });
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.FILE_SYSTEM_ERROR,
                `Failed to add task: ${error instanceof Error ? error.message : String(error)}`,
                {
                  project_id: params.project_id,
                  todo_number: params.todo_number,
                  traceId: context.traceId,
                }
              );
        this.logError('add_todo_task', params, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • Registers the MCP tool 'add_todo_task' with input schema validation, human-readable title and detailed description, delegating execution to TodoToolHandler.addTodoTaskAsync method and formatting response as MCP content.
      'add_todo_task',
      {
        title: 'Add TODO Task',
        description: TOOL_DESCRIPTIONS.add_todo_task,
        inputSchema: {
          project_id: secureProjectIdSchema.describe('The project identifier'),
          todo_number: secureTodoNumberSchema.describe('The TODO list number'),
          title: secureTaskTitleSchema.describe('Brief task title (max 200 chars, used in filename)'),
          content: secureTaskContentSchema.describe(
            'Full markdown content with implementation details, code examples, etc.'
          ),
        },
      },
      async (params) => {
        const result = await todoHandler.addTodoTaskAsync(params);
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      }
    );
  • Zod schemas for input validation specific to TODO tasks: secureTodoNumberSchema (positive integer), secureTaskTitleSchema (1-200 chars, trimmed, no null bytes), secureTaskContentSchema (optional up to 100KB markdown, no null bytes). Used in tool inputSchema and method signatures.
    export const secureTodoNumberSchema = z
      .number()
      .int('TODO number must be an integer')
      .positive('TODO number must be positive')
      .max(99999, 'TODO number too large');
    
    export const secureTodoDescriptionSchema = z
      .string()
      .min(1, 'TODO description cannot be empty')
      .max(500, 'TODO description too long (max 500 characters)')
      .refine((val) => !val.includes('\0'), 'TODO description cannot contain null bytes')
      .refine((val) => val.trim() === val, 'TODO description cannot have leading/trailing spaces');
    
    // Task title for brief identification (used in filenames)
    export const secureTaskTitleSchema = z
      .string()
      .min(1, 'Task title cannot be empty')
      .max(200, 'Task title too long (max 200 characters)')
      .refine((val) => !val.includes('\0'), 'Task title cannot contain null bytes')
      .refine((val) => val.trim() === val, 'Task title cannot have leading/trailing spaces');
    
    // Full markdown content for task details
    export const secureTaskContentSchema = z
      .string()
      .max(100 * 1024, 'Task content too large (max 100KB)')
      .refine((val) => !val.includes('\0'), 'Task content cannot contain null bytes')
      .optional();
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the tool auto-increments task numbers, preserves existing task order, supports rich formatting, and returns a structured response with success status, task number, and messages. It also implies mutation (adding tasks) and includes implementation guidance. The only minor gap is lack of explicit mention of permissions or rate limits.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, usage guidelines, features, instructions, exclusions, returns) and front-loaded key information. While comprehensive, some sections like the 7-point 'You should' list could be more concise. Overall, most sentences earn their place by adding value.

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

Completeness5/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 operation with 4 parameters, no annotations, no output schema), the description provides excellent completeness. It covers purpose, usage scenarios, behavioral traits, parameter guidance, exclusions, and return format. The explicit return format description compensates for the lack of output schema, making this highly complete for agent use.

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 four parameters thoroughly. The description adds some context about parameter usage (e.g., 'Use clear, actionable task titles (max 200 chars)' for the title parameter, 'Include implementation details in content' for content), but doesn't provide significant semantic value beyond what's in the schema. This meets the baseline for high schema coverage.

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 tool's purpose with specific verb ('Add') and resource ('new task to an existing TODO list'), distinguishing it from siblings like 'create_todo' (creates new TODO lists) and 'complete_todo_task' (marks tasks as done). The mention of 'full markdown support' adds further specificity.

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

Usage Guidelines5/5

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

The description provides explicit guidance with dedicated 'When to use this tool' and 'DO NOT use when' sections, listing specific scenarios for use (e.g., 'Expanding existing TODO with new tasks') and clear exclusions (e.g., 'TODO doesn't exist', 'Task duplicates existing one'). This gives comprehensive context for when to choose this tool over alternatives.

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/sven-borkert/knowledge-mcp'

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