Skip to main content
Glama

taskSearch

Search for tasks using filters like status, priority, tags, due dates, or text content to find specific items in your task management system.

Instructions

根據條件搜索任務

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filterYes

Implementation Reference

  • main.ts:804-834 (registration)
    Registration of the 'taskSearch' MCP tool, including input schema definition and a thin wrapper handler that delegates to TaskManagerTool.searchTasks
    server.tool("taskSearch",
        "根據條件搜索任務",
        {
            filter: z.object({
                status: z.enum([
                    TaskStatus.PENDING,
                    TaskStatus.IN_PROGRESS,
                    TaskStatus.COMPLETED,
                    TaskStatus.CANCELLED
                ]).optional(),
                tags: z.array(z.string()).optional(),
                priority: z.number().optional(),
                dueDateFrom: z.string().optional(),
                dueDateTo: z.string().optional(),
                searchText: z.string().optional()
            })
        },
        async ({ filter }) => {
            try {
                const tasks = await TaskManagerTool.searchTasks(filter);
    
                return {
                    content: [{ type: "text", text: `搜索到 ${tasks.length} 個任務:\n${JSON.stringify(tasks, null, 2)}` }]
                };
            } catch (error) {
                return {
                    content: [{ type: "text", text: `搜索任務失敗: ${error instanceof Error ? error.message : "未知錯誤"}` }]
                };
            }
        }
    );
  • Core implementation of task search logic: reads all tasks and filters them based on status, tags, priority, due dates, and search text across title, description, and steps.
    public static async searchTasks(filter: TaskFilter): Promise<Task[]> {
      const tasks = await this.readTasks();
    
      return tasks.filter(task => {
        // 根據任務狀態過濾
        if (filter.status && task.status !== filter.status) {
          return false;
        }
    
        // 根據標籤過濾
        if (filter.tags && filter.tags.length > 0) {
          const hasAllTags = filter.tags.every(tag => task.tags.includes(tag));
          if (!hasAllTags) {
            return false;
          }
        }
    
        // 根據優先級過濾
        if (filter.priority && task.priority !== filter.priority) {
          return false;
        }
    
        // 根據期限過濾
        if (filter.dueDateFrom && task.dueDate) {
          const dueDateFrom = new Date(filter.dueDateFrom);
          const taskDueDate = new Date(task.dueDate);
          if (taskDueDate < dueDateFrom) {
            return false;
          }
        }
    
        if (filter.dueDateTo && task.dueDate) {
          const dueDateTo = new Date(filter.dueDateTo);
          const taskDueDate = new Date(task.dueDate);
    
          // 根據預計開始時間過濾
          if (filter.plannedStartDateFrom && task.plannedStartDate) {
            const plannedStartDateFrom = new Date(filter.plannedStartDateFrom);
            const taskPlannedStartDate = new Date(task.plannedStartDate);
            if (taskPlannedStartDate < plannedStartDateFrom) {
              return false;
            }
          }
    
          if (filter.plannedStartDateTo && task.plannedStartDate) {
            const plannedStartDateTo = new Date(filter.plannedStartDateTo);
            const taskPlannedStartDate = new Date(task.plannedStartDate);
            if (taskPlannedStartDate > plannedStartDateTo) {
              return false;
            }
          }
          if (taskDueDate > dueDateTo) {
            return false;
          }
        }
    
        // 根據建立時間過濾
        if (filter.createdFrom) {
          const createdFrom = new Date(filter.createdFrom);
          const taskCreatedDate = new Date(task.createdAt);
          if (taskCreatedDate < createdFrom) {
            return false;
          }
        }
    
        if (filter.createdTo) {
          const createdTo = new Date(filter.createdTo);
          const taskCreatedDate = new Date(task.createdAt);
          if (taskCreatedDate > createdTo) {
            return false;
          }
        }
    
        // 根據文本搜索
        if (filter.searchText) {
          const searchText = filter.searchText.toLowerCase();
          const matchesTitle = task.title.toLowerCase().includes(searchText);
          const matchesDescription = task.description.toLowerCase().includes(searchText);
          const matchesSteps = task.steps.some(step =>
            step.description.toLowerCase().includes(searchText)
          );
    
          if (!matchesTitle && !matchesDescription && !matchesSteps) {
            return false;
          }
        }
    
        return true;
      });
    }
  • TypeScript interface defining the TaskFilter type used for task search parameters, matching the tool's input schema.
    export interface TaskFilter {
      status?: TaskStatus;
        plannedStartDateFrom?: string;
        plannedStartDateTo?: string;
      tags?: string[];
      priority?: number;
      dueDateFrom?: string;
      dueDateTo?: string;
      createdFrom?: string;
      createdTo?: string;
      searchText?: string;
    }
  • TaskStatus enum used in the input schema for filtering by task status.
    export enum TaskStatus {
      PENDING = "pending",
      IN_PROGRESS = "in_progress",
      COMPLETED = "completed",
      CANCELLED = "cancelled"
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions '搜索' (search) which implies a read operation, but doesn't disclose behavioral traits such as whether it's paginated, what permissions are needed, or what the return format looks like. The description is minimal and lacks critical operational details.

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

Conciseness4/5

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

The description is a single, efficient sentence in Chinese, making it appropriately concise. However, it's under-specified rather than truly well-structured, as it lacks necessary details for a tool with complex parameters.

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

Completeness2/5

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

Given the complexity (1 parameter with nested object, 0% schema coverage, no output schema, and no annotations), the description is incomplete. It doesn't explain the search behavior, result format, or error handling, leaving significant gaps for an AI agent to understand how to use this tool effectively.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions '條件' (conditions) which hints at the 'filter' parameter, but doesn't explain the semantics of nested properties like 'status', 'tags', or 'dueDateFrom'. The description adds minimal value beyond the schema.

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

Purpose2/5

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

The description '根據條件搜索任務' (Search tasks based on conditions) states the basic purpose but is vague. It doesn't specify what kind of tasks or what system it operates on, and doesn't distinguish from sibling tools like 'taskGetAll' or 'taskGetById'. It's better than a tautology but lacks specificity.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'taskGetAll' (which might retrieve all tasks without filtering) or 'taskGetById' (for specific tasks). The description implies filtering but doesn't clarify context or exclusions.

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/GonTwVn/GonMCPtool'

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