Skip to main content
Glama

Complete Todo

complete_todo
Idempotent

Mark a todo item as completed to track progress in task management. This tool updates completion status within the Todokit MCP Server's local JSON storage.

Instructions

Set completion status for a todo item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okYes
errorNo
resultNo

Implementation Reference

  • The main handler function that processes the complete_todo tool input: resolves the todo selector, calls the storage mutation, and constructs the tool response.
    async function handleCompleteTodo(
      input: CompleteTodoInput
    ): Promise<CallToolResult> {
      const targetCompleted = input.completed ?? true;
      const selector =
        input.id !== undefined ? { id: input.id } : { query: input.query };
      const outcome = await completeTodoBySelector(
        toResolveInput(selector),
        targetCompleted
      );
      return buildOutcomeResponse(outcome, targetCompleted);
    }
  • Zod schema for CompleteTodoInput: union of selector by ID or query, with optional 'completed' boolean.
    const completeTodoSelector = buildSelectorSchemas(
      'The ID of the todo to complete',
      'Search text to find a single todo to complete'
    );
    
    export const CompleteTodoSchema: ZodType<CompleteTodoInput> = z.union([
      completeTodoSelector.byId.extend({
        completed: z
          .boolean()
          .optional()
          .describe('Set completion status (default: true)'),
      }),
      completeTodoSelector.byQuery.extend({
        completed: z
          .boolean()
          .optional()
          .describe('Set completion status (default: true)'),
      }),
    ]);
  • Registers the complete_todo tool on the MCP server with input/output schemas, metadata, and error-handling wrapper around the handler.
    export function registerCompleteTodo(server: McpServer): void {
      server.registerTool(
        'complete_todo',
        {
          title: 'Complete Todo',
          description: 'Set completion status for a todo item',
          inputSchema: CompleteTodoSchema,
          outputSchema: DefaultOutputSchema,
          annotations: {
            readOnlyHint: false,
            idempotentHint: true,
          },
        },
        async (input) => {
          try {
            return await handleCompleteTodo(input);
          } catch (err) {
            return createErrorResponse('E_COMPLETE_TODO', getErrorMessage(err));
          }
        }
      );
    }
  • Storage layer function that resolves the todo selector, toggles completion status if needed, handles 'already' case, and persists changes via withTodos.
    export async function completeTodoBySelector(
      input: ResolveTodoInput,
      completed: boolean
    ): Promise<CompleteTodoOutcome> {
      return withTodos<CompleteTodoOutcome>((todos) => {
        const outcome = unwrapResolution(resolveTodoTargetFromTodos(todos, input));
        if (outcome.kind !== 'match') {
          return { todos, result: outcome };
        }
    
        if (outcome.todo.completed === completed) {
          return { todos, result: { kind: 'already', todo: outcome.todo } };
        }
    
        const updated = applyUpdateToTodos(todos, outcome.todo.id, { completed });
        if (!updated.result) {
          return {
            todos,
            result: createNotFoundOutcome(outcome.todo.id),
          };
        }
    
        return {
          todos: updated.todos,
          result: { kind: 'match', todo: updated.result },
        };
      });
    }

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other 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/j0hanz/todokit-mcp-server'

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