Skip to main content
Glama
danjdewhurst

Todo Markdown MCP Server

by danjdewhurst

list_todos

Retrieve all todo items from a markdown file for viewing and management within AI assistant workflows.

Instructions

List all todos from the markdown file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that lists todos by checking if the todo file exists, reading and parsing its markdown content, calculating statistics (total, completed, pending), and returning a 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, }; }
  • MCP CallToolRequest handler case for 'list_todos' that delegates to todoManager.listTodos() and returns the result as JSON-formatted text content.
    case 'list_todos': { const result = await this.todoManager.listTodos(); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
  • src/index.ts:40-48 (registration)
    Tool registration in ListToolsRequest handler, defining the 'list_todos' tool name, description, and empty input schema (no parameters required).
    { name: 'list_todos', description: 'List all todos from the markdown file', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, },
  • TypeScript interface defining the structure of the response returned by the list_todos tool.
    export interface ListTodosResponse { todos: TodoItem[]; total: number; completed: number; pending: number; }
  • Helper function to parse TodoItem objects from markdown file content by matching checkbox lines and extracting ID comments.
    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; }

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