Skip to main content
Glama

query_task

Search and retrieve task information by keywords or ID, enabling quick access to abbreviated details with paginated results.

Instructions

Search tasks by keyword or ID, displaying abbreviated task information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
isIdNoSpecify whether it's ID query mode, default is no (keyword mode)
pageNoPage number, default is page 1
pageSizeNoNumber of tasks to display per page, default is 5, maximum 20
queryYesSearch query text, can be task ID or multiple keywords (space separated)

Implementation Reference

  • The main execution handler for the 'query_task' tool. It performs a search on tasks using searchTasksWithCommand, generates a formatted prompt using getQueryTaskPrompt, and returns it as tool content.
    export async function queryTask({
      query,
      isId = false,
      page = 1,
      pageSize = 3,
    }: z.infer<typeof queryTaskSchema>) {
      try {
        // Use system command search function
        const results = await searchTasksWithCommand(query, isId, page, pageSize);
    
        // Use prompt generator to get the final prompt
        const prompt = getQueryTaskPrompt({
          query,
          isId,
          tasks: results.tasks,
          totalTasks: results.pagination.totalResults,
          page: results.pagination.currentPage,
          pageSize,
          totalPages: results.pagination.totalPages,
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: prompt,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text" as const,
              text: `## System Error\n\nError occurred when querying tasks: ${
                error instanceof Error ? error.message : String(error)
              }`,
            },
          ],
          isError: true,
        };
      }
    }
  • Zod input schema defining parameters for query_task: query string, optional isId boolean, page and pageSize numbers.
    export const queryTaskSchema = z.object({
      query: z
        .string()
        .min(1, {
          message: "Query content cannot be empty, please provide task ID or search keywords",
        })
        .describe("Search query text, can be task ID or multiple keywords (space separated)"),
      isId: z
        .boolean()
        .optional()
        .default(false)
        .describe("Specify whether it's ID query mode, default is no (keyword mode)"),
      page: z
        .number()
        .int()
        .positive()
        .optional()
        .default(1)
        .describe("Page number, default is page 1"),
      pageSize: z
        .number()
        .int()
        .positive()
        .min(1)
        .max(20)
        .optional()
        .default(5)
        .describe("Number of tasks to display per page, default is 5, maximum 20"),
    });
  • src/index.ts:304-310 (registration)
    Registration of the query_task tool in the MCP server's ListToolsRequest handler, including name, description from MD file, and JSON schema from Zod.
    {
      name: "query_task",
      description: loadPromptFromTemplate(
        "toolsDescription/queryTask.md"
      ),
      inputSchema: zodToJsonSchema(queryTaskSchema),
    },
  • src/index.ts:528-538 (registration)
    Dispatch case in the CallToolRequest handler that validates input with queryTaskSchema and calls the queryTask handler function.
    case "query_task":
      parsedArgs = await queryTaskSchema.safeParseAsync(
        request.params.arguments
      );
      if (!parsedArgs.success) {
        throw new Error(
          `Invalid arguments for tool ${request.params.name}: ${parsedArgs.error.message}`
        );
      }
      result = await queryTask(parsedArgs.data);
      return result;
  • Helper function that generates the formatted prompt for displaying query results, handling no results case and formatting task details.
    export function getQueryTaskPrompt(params: QueryTaskPromptParams): string {
      const { query, isId, tasks, totalTasks, page, pageSize, totalPages } = params;
    
      if (tasks.length === 0) {
        const notFoundTemplate = loadPromptFromTemplate("queryTask/notFound.md");
        return generatePrompt(notFoundTemplate, {
          query,
        });
      }
    
      const taskDetailsTemplate = loadPromptFromTemplate(
        "queryTask/taskDetails.md"
      );
      let tasksContent = "";
      for (const task of tasks) {
        tasksContent += generatePrompt(taskDetailsTemplate, {
          taskId: task.id,
          taskName: task.name,
          taskStatus: task.status,
          taskDescription:
            task.description.length > 100
              ? `${task.description.substring(0, 100)}...`
              : task.description,
          createdAt: new Date(task.createdAt).toLocaleString(),
        });
      }
    
      const indexTemplate = loadPromptFromTemplate("queryTask/index.md");
      const prompt = generatePrompt(indexTemplate, {
        tasksContent,
        page,
        totalPages,
        pageSize,
        totalTasks,
        query,
      });
    
      // Load possible custom prompt
      return loadPrompt(prompt, "QUERY_TASK");
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'displaying abbreviated task information' which hints at output format, but doesn't describe pagination behavior (implied by parameters), rate limits, authentication requirements, error conditions, or what 'abbreviated' specifically means. For a search tool with no annotation coverage, this leaves significant behavioral gaps.

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 that communicates the core functionality. It's appropriately sized for a search tool, though could potentially be more front-loaded with key differentiators. No wasted words, but could benefit from slightly more structure.

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?

For a search tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'abbreviated information' includes, how results are ordered, error handling, or how this differs from sibling tools. The agent would need to guess about important behavioral aspects despite the good parameter documentation.

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 fully documents all 4 parameters. The description mentions 'keyword or ID' which aligns with the query parameter, and 'abbreviated task information' which relates to output, but adds minimal semantic value beyond what's already in the schema descriptions. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose4/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 as searching tasks by keyword or ID and displaying abbreviated information. It specifies the verb 'search' and resource 'tasks' with search criteria, but doesn't explicitly differentiate from sibling tools like 'list_tasks' or 'get_task_detail'.

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?

The description provides no guidance on when to use this tool versus alternatives like 'list_tasks' (which might list all tasks without search) or 'get_task_detail' (which might retrieve full details for a specific task). There's no mention of prerequisites, limitations, or comparative use cases.

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

Related 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/liorfranko/mcp-chain-of-thought'

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