Skip to main content
Glama
danjdewhurst

Todo Markdown MCP Server

by danjdewhurst

update_todo

Modify an existing todo item by updating its text or completion status using its unique ID, ensuring accurate task management in the Todo Markdown MCP Server.

Instructions

Update an existing todo item

Input Schema

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

Implementation Reference

  • The core handler function that finds the todo by ID, updates its text or completion status, rewrites the markdown file, and returns the updated todo item.
    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 interface defining the input parameters for the update_todo tool.
    export interface UpdateTodoRequest { id: string; text?: string; completed?: boolean; }
  • src/index.ts:64-86 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema matching UpdateTodoRequest.
    { 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, }, },
  • MCP server handler for CallToolRequest that validates input, delegates to TodoManager.updateTodo, 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)}`, }, ], }; }

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