Skip to main content
Glama
danjdewhurst

Todo Markdown MCP Server

by danjdewhurst

delete_todo

Remove a specific todo item from a markdown-based task list by providing its unique ID to maintain organized and current task management.

Instructions

Delete a todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe todo item ID to delete

Implementation Reference

  • The core handler function that deletes a todo item by ID from the todo markdown file. It parses the file, removes the matching todo, and writes back the updated markdown.
    async deleteTodo(request: DeleteTodoRequest): Promise<void> {
      const todos = (await this.listTodos()).todos;
      const todoIndex = todos.findIndex((todo) => todo.id === request.id);
    
      if (todoIndex === -1) {
        throw new Error(`Todo with id ${request.id} not found`);
      }
    
      todos.splice(todoIndex, 1);
    
      const markdown = this.formatTodoMarkdown(todos);
    
      try {
        await writeFile(this.todoFilePath, markdown, 'utf-8');
      } catch (error) {
        if (error instanceof Error && error.message.includes('EACCES')) {
          throw new Error(
            `Permission denied: Cannot write to ${this.todoFilePath}. Check file permissions or set TODO_FILE_PATH environment variable to a writable location.`
          );
        } else if (error instanceof Error && error.message.includes('EROFS')) {
          throw new Error(
            `Read-only file system: Cannot write to ${this.todoFilePath}. Set TODO_FILE_PATH environment variable to a writable location.`
          );
        }
        throw error;
      }
    }
  • The MCP CallToolRequest handler case for 'delete_todo', which validates the input arguments and delegates to the todoManager.deleteTodo method, returning a success message.
    case 'delete_todo': {
      const args = request.params
        .arguments as unknown as DeleteTodoRequest;
      if (!args?.id || typeof args.id !== 'string') {
        throw new Error('ID is required and must be a string');
      }
    
      await this.todoManager.deleteTodo(args);
      return {
        content: [
          {
            type: 'text',
            text: `Todo with ID ${args.id} deleted successfully`,
          },
        ],
      };
    }
  • src/index.ts:87-101 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the name, description, and input schema for the 'delete_todo' tool.
    {
      name: 'delete_todo',
      description: 'Delete a todo item',
      inputSchema: {
        type: 'object',
        properties: {
          id: {
            type: 'string',
            description: 'The todo item ID to delete',
          },
        },
        required: ['id'],
        additionalProperties: false,
      },
    },
  • TypeScript type definition for the DeleteTodoRequest used by the delete_todo handlers.
    export interface DeleteTodoRequest {
      id: string;
    }

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/danjdewhurst/todo-md-mcp'

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