Skip to main content
Glama

search_tasks_using_and

Find Todoist tasks containing all specified search terms using AND logic. Filter tasks by multiple criteria simultaneously to locate relevant items.

Instructions

Search for tasks in Todoist using AND logic - all search terms must be present. 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. All terms must be present in matching tasks. Examples: ["meeting", "team"], ["weekly", "report", "friday"]

Implementation Reference

  • The async handler function that executes the 'search_tasks_using_and' tool logic by calling the core searchTasksUsingAnd function and returning formatted JSON response.
    handler: async (args: { search_terms: string[] }) => {
      console.error('Executing search_tasks_using_and...');
      const result = await searchTasksUsingAnd(args.search_terms);
      console.error('search_tasks_using_and completed successfully');
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    },
  • Input schema and metadata definition for the 'search_tasks_using_and' tool, specifying the name, description, and required search_terms array.
    schema: {
      name: 'search_tasks_using_and',
      description:
        'Search for tasks in Todoist using AND logic - all search terms must be present. 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. All terms must be present in matching tasks. Examples: ["meeting", "team"], ["weekly", "report", "friday"]',
          },
        },
        required: ['search_terms'],
      },
    },
  • Core helper function implementing the AND search logic using Todoist API filter with 'search:term1 & search:term2' syntax, mapping responses and caching task names.
    export async function searchTasksUsingAnd(
      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 and search tasks: ${getErrorMessage(error)}`);
      }
    }
  • Registration of the tool's handler in the toolsWithArgs registry for execution dispatching.
    search_tasks_using_and: searchTasksUsingAndTool.handler,
  • src/index.ts:101-101 (registration)
    Registration of the tool's schema in the list of available tools for the MCP server.
    searchTasksUsingAndTool.schema,
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by specifying the search logic behavior, providing concrete query examples, and describing the return format ('structured JSON data with task details including id, content, description...'). It doesn't mention rate limits, authentication needs, or pagination, but provides substantial behavioral context.

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 perfectly structured and concise - first sentence states purpose and logic, second provides concrete examples, third describes return format. Every sentence earns its place with zero wasted words, and key information is front-loaded.

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 1 parameter, 100% schema coverage, and no output schema, the description provides excellent context: search logic, query examples, and return data structure. It could mention pagination or result limits, but covers the essential information needed to use the tool effectively.

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?

Schema description coverage is 100%, so the schema already fully documents the 'search_terms' parameter. The description adds value by providing query examples ('meeting', '*report*', "buy groceries") that illustrate different search syntaxes, but doesn't add semantic meaning beyond what the schema's examples already provide.

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 with specific verb ('Search for tasks') and resource ('in Todoist'), and explicitly distinguishes it from sibling tools by specifying 'AND logic - all search terms must be present'. This differentiates it from 'search_tasks' and 'search_tasks_using_or' which likely use different logic.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool by stating 'all search terms must be present', which directly contrasts with the 'search_tasks_using_or' sibling tool. This gives clear context for choosing between AND vs OR search logic alternatives.

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