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"); }

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