Skip to main content
Glama
danjdewhurst

Todo Markdown MCP Server

by danjdewhurst

update_todo

Modify existing todo items by updating text or marking them as completed in a markdown-based todo list.

Instructions

Update an existing todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe todo item ID
textNoNew text for the todo item
completedNoWhether the todo is completed

Implementation Reference

  • The handler function for the 'update_todo' tool within the CallToolRequestSchema request handler. It validates the input arguments, calls the todoManager.updateTodo method, and formats the response.
    case 'update_todo': { const args = request.params .arguments as unknown as UpdateTodoRequest; if (!args?.id || typeof args.id !== 'string') { throw new Error('ID is required and must be a string'); } const todo = await this.todoManager.updateTodo(args); return { content: [ { type: 'text', text: `Todo updated successfully: ${JSON.stringify(todo, null, 2)}`, }, ], }; }
  • src/index.ts:64-86 (registration)
    Registration of the 'update_todo' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: 'update_todo', description: 'Update an existing todo item', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The todo item ID', }, text: { type: 'string', description: 'New text for the todo item', }, completed: { type: 'boolean', description: 'Whether the todo is completed', }, }, required: ['id'], additionalProperties: false, }, },
  • The core implementation of updating a todo item in the TodoManager class. Finds the todo by ID, applies updates to text and/or completed status, regenerates the markdown file, and saves it.
    async updateTodo(request: UpdateTodoRequest): Promise<TodoItem> { 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`); } const todo = todos[todoIndex]!; if (request.text !== undefined) { todo.text = request.text.trim(); } if (request.completed !== undefined) { todo.completed = request.completed; if (request.completed && !todo.completedAt) { todo.completedAt = new Date(); } else if (!request.completed) { delete todo.completedAt; } } todos[todoIndex] = todo; 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; } return todo; }
  • TypeScript type definition for the UpdateTodoRequest used for type-checking the tool arguments.
    export interface UpdateTodoRequest { id: string; text?: string; completed?: boolean; }

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