Skip to main content
Glama

search_tasks_using_or

Search Todoist tasks using OR logic to find items matching any specified term, wildcard patterns, or exact phrases. Returns structured task details including content, status, labels, and due dates.

Instructions

Search for tasks in Todoist using OR logic - any search term can match. Search query examples: meeting (basic text search), report (wildcard search), "buy groceries" (quoted, exact phrase search). Returns structured JSON data with task details including id, content, description, completion status, labels, priority, due date, and comment count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
search_termsYesArray of search terms. Any term can be present in matching tasks. Examples: ["meeting", "team"], ["weekly", "report", "friday"]

Implementation Reference

  • The handler function for the 'search_tasks_using_or' tool. It takes search_terms, calls the core searchTasksUsingOr function, and returns formatted JSON response.
    handler: async (args: { search_terms: string[] }) => {
      console.error('Executing search_tasks_using_or...');
      const result = await searchTasksUsingOr(args.search_terms);
      console.error('search_tasks_using_or completed successfully');
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    },
  • The schema definition for the 'search_tasks_using_or' tool, specifying name, description, and input schema requiring search_terms array.
    schema: {
      name: 'search_tasks_using_or',
      description:
        'Search for tasks in Todoist using OR logic - any search term can match. Search query examples: meeting (basic text search), *report* (wildcard search), "buy groceries" (quoted, exact phrase search). Returns structured JSON data with task details including id, content, description, completion status, labels, priority, due date, and comment count.',
      inputSchema: {
        type: 'object',
        properties: {
          search_terms: {
            type: 'array',
            items: {
              type: 'string',
            },
            description:
              'Array of search terms. Any term can be present in matching tasks. Examples: ["meeting", "team"], ["weekly", "report", "friday"]',
          },
        },
        required: ['search_terms'],
      },
    },
  • Core helper function implementing the OR search logic using Todoist API filter with 'search:term1 | search:term2' syntax, processes tasks, caches names, returns structured TasksResponse.
    export async function searchTasksUsingOr(
      searchTerms: string[]
    ): Promise<TasksResponse> {
      if (searchTerms.length === 0) {
        throw new Error('At least one search term is required');
      }
    
      // Validate that all search terms are non-empty after trimming
      const trimmedTerms = searchTerms.map((term) => term.trim());
      if (trimmedTerms.some((term) => term === '')) {
        throw new Error('All search terms must be non-empty');
      }
    
      const todoistClient = getTodoistClient();
    
      try {
        // Build the filter string by joining terms with " | " operator
        const filterString = trimmedTerms
          .map((term) => `search:${term}`)
          .join(' | ');
    
        const response = await todoistClient.get<TodoistTask[]>(
          `/tasks?filter=${encodeURIComponent(filterString)}`
        );
    
        const tasks = response.data.map((task) => ({
          id: parseInt(task.id),
          content: task.content,
          description: task.description,
          is_completed: task.is_completed,
          labels: task.labels,
          priority: task.priority,
          due_date: task.due?.date || null,
          url: task.url,
          comment_count: task.comment_count,
        }));
    
        // Store task names in cache
        tasks.forEach((task) => {
          setTaskName(task.id.toString(), task.content);
        });
    
        return {
          tasks,
          total_count: tasks.length,
        };
      } catch (error) {
        throw new Error(`Failed to or search tasks: ${getErrorMessage(error)}`);
      }
    }
  • Registration of the tool handler in the toolsWithArgs dispatch map used by handleToolRequest.
    const toolsWithArgs: Record<string, (args: any) => Promise<ToolResponse>> = {
      get_task_comments: getTaskCommentsTool.handler,
      create_project_label: createProjectLabelTool.handler,
      create_task_comment: createTaskCommentTool.handler,
      update_task: updateTaskTool.handler,
      create_task: createTaskTool.handler,
      move_task: moveTaskTool.handler,
      get_tasks_with_label: getTasksWithLabelTool.handler,
      complete_task: completeTaskTool.handler,
      uncomplete_task: uncompleteTaskTool.handler,
      search_tasks: searchTasksTool.handler,
      search_tasks_using_and: searchTasksUsingAndTool.handler,
      search_tasks_using_or: searchTasksUsingOrTool.handler,
      complete_becky_task: completeBeckyTaskTool.handler,
    };
  • src/index.ts:31-102 (registration)
    Import of the tool for use in the MCP server.
      searchTasksUsingOrTool,
      getChoresDueTodayTool,
      getTasksDueTomorrowTool,
      getTasksDueThisWeekTool,
      getTicklerTasksTool,
      listGtdProjectsTool,
      getWaitingTasksTool,
      getRecentMediaTool,
      getAreasOfFocusTool,
      getShoppingListTool,
      completeBeckyTaskTool,
      listBrianTimeSensitiveTasksTool,
      listBeckyTimeSensitiveTasksTool,
    } from './tools';
    import { handleToolRequest } from './handlers/tool-request-handler';
    import { join } from 'path';
    import { dirname } from 'path';
    import { fileURLToPath } from 'url';
    
    const __filename = fileURLToPath(import.meta.url);
    const __dirname = dirname(__filename);
    const envPath = join(__dirname, '..', '.env');
    
    console.error('Loading .env file from:', envPath);
    config({ path: envPath });
    
    // Validate required environment variables
    const requiredEnvVars = ['TODOIST_API_TOKEN'];
    const missingVars = requiredEnvVars.filter((varName) => !process.env[varName]);
    
    if (missingVars.length > 0) {
      console.error(
        'Missing required environment variables:',
        missingVars.join(', ')
      );
      console.error('Please create a .env file with the required variables.');
      process.exit(1);
    }
    
    const server = new Server({
      name: 'todoist-mcp',
      version: '1.0.0',
      capabilities: {
        tools: {},
      },
    });
    
    // List tools
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          getTaskCommentsTool.schema,
          listPersonalInboxTasksTool.schema,
          listBrianInboxPerBeckyTasksTool.schema,
          listBeckyInboxPerBrianTasksTool.schema,
          listNextActionsTool.schema,
          getBrianOnlyProjectsTool.schema,
          getBrianSharedProjectsTool.schema,
          getBeckySharedProjectsTool.schema,
          getInboxProjectsTool.schema,
          createProjectLabelTool.schema,
          createTaskCommentTool.schema,
          updateTaskTool.schema,
          createTaskTool.schema,
          moveTaskTool.schema,
          getContextLabelsTool.schema,
          getTasksWithLabelTool.schema,
          completeTaskTool.schema,
          uncompleteTaskTool.schema,
          searchTasksTool.schema,
          searchTasksUsingAndTool.schema,
          searchTasksUsingOrTool.schema,
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the search logic (OR-based matching), provides concrete query examples with syntax variations, and details the return format (structured JSON with specific task fields). This gives the agent good operational context beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: the first states the purpose and logic, the second provides examples and return format. Every element serves a clear purpose with zero wasted words, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with no annotations and no output schema, the description does well by explaining the OR logic, providing query syntax examples, and detailing the return data structure. However, it doesn't mention potential limitations like result pagination, rate limits, or authentication requirements that would be helpful for comprehensive agent understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the 'search_terms' parameter as an array of strings with examples. The description adds value by showing practical search term formats (wildcards, quoted phrases) in context, but doesn't significantly expand on the parameter's semantics beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search for tasks in Todoist using OR logic - any search term can match.' It specifies the verb (search), resource (tasks in Todoist), and the distinctive OR logic approach, differentiating it from sibling tools like 'search_tasks' and 'search_tasks_using_and'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool by explaining the OR logic behavior ('any search term can match') and offering search query examples. However, it doesn't explicitly state when NOT to use it or directly name alternatives like 'search_tasks_using_and' for comparison.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/bkotos/todoist-mcp'

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