Skip to main content
Glama
danjdewhurst

Todo Markdown MCP Server

by danjdewhurst

list_todos

Retrieve and display all todo items from a markdown file, enabling efficient task tracking and management within a structured environment.

Instructions

List all todos from the markdown file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function for list_todos tool. Reads todo.md file, parses markdown checkboxes into TodoItem objects using parseTodoMarkdown, calculates stats, and returns structured ListTodosResponse.
    async listTodos(): Promise<ListTodosResponse> { if (!(await this.fileExists())) { return { todos: [], total: 0, completed: 0, pending: 0, }; } const content = await readFile(this.todoFilePath, 'utf-8'); const todos = this.parseTodoMarkdown(content); const completed = todos.filter((todo) => todo.completed).length; const pending = todos.length - completed; return { todos, total: todos.length, completed, pending, }; }
  • src/index.ts:41-48 (registration)
    Tool registration in ListTools response, including name 'list_todos', description, and empty input schema (no parameters).
    name: 'list_todos', description: 'List all todos from the markdown file', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, },
  • MCP server CallToolRequest handler case for 'list_todos' that delegates to todoManager.listTodos() and returns JSON-stringified result as text content.
    case 'list_todos': { const result = await this.todoManager.listTodos(); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • TypeScript interface defining the output structure returned by listTodos handler.
    export interface ListTodosResponse { todos: TodoItem[]; total: number; completed: number; pending: number; }
  • TypeScript interface for individual todo items parsed from markdown.
    export interface TodoItem { id: string; text: string; completed: boolean; createdAt: Date; completedAt?: Date; }
  • Helper function to parse markdown lines into TodoItem array, matching checkbox format and extracting/comment IDs.
    private parseTodoMarkdown(content: string): TodoItem[] { const lines = content.split('\n'); const todos: TodoItem[] = []; for (const line of lines) { const trimmed = line.trim(); // Match markdown checkbox format: - [ ] text or - [x] text const checkboxMatch = trimmed.match(/^-\s*\[([x\s])\]\s*(.+)$/i); if (checkboxMatch) { const [, checkbox, text] = checkboxMatch; if (!checkbox || !text) continue; const completed = checkbox.toLowerCase() === 'x'; // Extract ID from text if it exists (format: text <!-- id:uuid -->) const idMatch = text.match(/^(.*?)\s*<!--\s*id:([a-f0-9-]+)\s*-->$/); let todoText: string; let id: string; if (idMatch) { todoText = idMatch[1]?.trim() || ''; id = idMatch[2] || randomUUID(); } else { todoText = text.trim(); id = randomUUID(); } todos.push({ id, text: todoText, completed, createdAt: new Date(), ...(completed && { completedAt: new Date() }), }); } } return todos; }

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

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