Skip to main content
Glama

list_todos

Retrieve and manage tasks by filtering, searching, sorting, and paginating todo items based on status, priority, tags, due dates, and other criteria.

Instructions

List todos with filtering, search, sorting, and pagination

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
completedNoFilter by completion status (deprecated; use status)
statusNoFilter by status
queryNoSearch text in title, description, or tags
priorityNoFilter by priority level
tagNoFilter by tag (must contain)
dueBeforeNoFilter todos due before this date (ISO format)
dueAfterNoFilter todos due after this date (ISO format)
sortByNoSort results by field
orderNoSort order (default: asc)
limitNoMax number of results to return (default: 50)
offsetNoNumber of results to skip

Implementation Reference

  • Main handler function that processes filters, fetches todos, sorts, paginates, computes stats, and returns formatted response.
    async function handleListTodos( filters: ListTodosFilters ): Promise<CallToolResult> { const normalized = normalizeFilters(filters); const allTodos = await getTodos({ completed: normalized.completed, priority: normalized.priority, tag: normalized.tag, dueBefore: normalized.dueBefore, dueAfter: normalized.dueAfter, query: normalized.query, }); const todayIso = getTodayIso(); const counts = computeCounts(allTodos, todayIso); const sorted = sortTodos(allTodos, normalized.sortBy, normalized.order); const paged = paginateTodos(sorted, normalized.offset, normalized.limit); const summary = buildSummary(counts, paged.length); return createToolResponse({ ok: true, result: { items: paged, summary, counts: { total: counts.total, pending: counts.pending, completed: counts.completed, overdue: counts.overdue, }, limit: normalized.limit, offset: normalized.offset, }, }); }
  • Zod schema defining input filters for the list_todos tool, including status, query, priority, tags, dates, sorting, and pagination.
    export const ListTodosFilterSchema = z .object({ completed: z .boolean() .optional() .describe('Filter by completion status (deprecated; use status)'), status: z .enum(['pending', 'completed', 'all']) .optional() .describe('Filter by status'), query: z .string() .min(1) .max(200) .optional() .describe('Search text in title, description, or tags'), priority: z .enum(['low', 'normal', 'high']) .optional() .describe('Filter by priority level'), tag: TagSchema.optional().describe('Filter by tag (must contain)'), dueBefore: IsoDateSchema.optional().describe( 'Filter todos due before this date (ISO format)' ), dueAfter: IsoDateSchema.optional().describe( 'Filter todos due after this date (ISO format)' ), sortBy: SortBySchema.optional().describe('Sort results by field'), order: SortOrderSchema.optional().describe('Sort order (default: asc)'), limit: z .number() .int() .min(1) .max(200) .optional() .describe('Max number of results to return (default: 50)'), offset: z .number() .int() .min(0) .max(10000) .optional() .describe('Number of results to skip'), }) .strict();
  • Registers the 'list_todos' tool with the MCP server, specifying title, description, schemas, annotations, and handler.
    export function registerListTodos(server: McpServer): void { server.registerTool( 'list_todos', { title: 'List Todos', description: 'List todos with filtering, search, sorting, and pagination', inputSchema: ListTodosFilterSchema, outputSchema: DefaultOutputSchema, annotations: { readOnlyHint: true, idempotentHint: true, }, }, async (filters) => { try { return await handleListTodos(filters); } catch (err) { return createErrorResponse('E_LIST_TODOS', getErrorMessage(err)); } } ); }
  • Helper function to normalize and provide defaults for list_todos input filters.
    function normalizeFilters(filters: ListTodosFilters): NormalizedFilters { return { completed: resolveCompletedFilter(filters.status, filters.completed), priority: filters.priority, tag: filters.tag, dueBefore: filters.dueBefore, dueAfter: filters.dueAfter, query: normalizeQuery(filters.query), sortBy: filters.sortBy ?? 'createdAt', order: filters.order ?? 'asc', limit: filters.limit ?? DEFAULT_LIMIT, offset: filters.offset ?? DEFAULT_OFFSET, }; }

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