search_tasks
Search for tasks by title with optional filters for project, tag, completion status, and source to quickly find specific tasks.
Instructions
Searches tasks by title text and optional filters.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Text to search for in the task title | |
| projectId | No | Filter by project ID | |
| projectName | No | Filter by project name | |
| tagId | No | Filter by tag ID | |
| tagName | No | Filter by tag name | |
| includeDone | No | Include completed tasks | |
| source | No | Which task source to query |
Implementation Reference
- src/tools/tasks.ts:98-120 (handler)The handler function that executes the search_tasks tool logic: resolves filter IDs (project/tag) and calls SpClient.getTasks with the query and optional filters, returning the results.
server.tool( "search_tasks", "Searches tasks by title text and optional filters.", { query: nonEmptyString.describe("Text to search for in the task title"), projectId: nonEmptyString.optional().describe("Filter by project ID"), projectName: nonEmptyString.optional().describe("Filter by project name"), tagId: nonEmptyString.optional().describe("Filter by tag ID"), tagName: nonEmptyString.optional().describe("Filter by tag name"), includeDone: z.boolean().optional().describe("Include completed tasks"), source: z.enum(["active", "archived", "all"]).optional().describe("Which task source to query"), }, async ({ query, projectId, projectName, tagId, tagName, includeDone, source }) => { const resolved = await resolveTaskFilterIds({ projectId, projectName, tagId, tagName }); const tasks = await SpClient.getTasks({ query, projectId: resolved.projectId, tagId: resolved.tagId, includeDone, source, }); return ok(tasks); } - src/tools/tasks.ts:98-109 (schema)Input schema for search_tasks defining parameters: query (required non-empty string), projectId, projectName, tagId, tagName (optional strings), includeDone (optional boolean), source (optional enum: active/archived/all).
server.tool( "search_tasks", "Searches tasks by title text and optional filters.", { query: nonEmptyString.describe("Text to search for in the task title"), projectId: nonEmptyString.optional().describe("Filter by project ID"), projectName: nonEmptyString.optional().describe("Filter by project name"), tagId: nonEmptyString.optional().describe("Filter by tag ID"), tagName: nonEmptyString.optional().describe("Filter by tag name"), includeDone: z.boolean().optional().describe("Include completed tasks"), source: z.enum(["active", "archived", "all"]).optional().describe("Which task source to query"), }, - src/tools/tasks.ts:98-120 (registration)Registration of the search_tasks tool via server.tool() on the McpServer instance.
server.tool( "search_tasks", "Searches tasks by title text and optional filters.", { query: nonEmptyString.describe("Text to search for in the task title"), projectId: nonEmptyString.optional().describe("Filter by project ID"), projectName: nonEmptyString.optional().describe("Filter by project name"), tagId: nonEmptyString.optional().describe("Filter by tag ID"), tagName: nonEmptyString.optional().describe("Filter by tag name"), includeDone: z.boolean().optional().describe("Include completed tasks"), source: z.enum(["active", "archived", "all"]).optional().describe("Which task source to query"), }, async ({ query, projectId, projectName, tagId, tagName, includeDone, source }) => { const resolved = await resolveTaskFilterIds({ projectId, projectName, tagId, tagName }); const tasks = await SpClient.getTasks({ query, projectId: resolved.projectId, tagId: resolved.tagId, includeDone, source, }); return ok(tasks); } - src/tools/tasks.ts:7-7 (helper)Helper constant nonEmptyString used in the schema (z.string().trim().min(1)).
const nonEmptyString = z.string().trim().min(1); - src/tools/tasks.ts:9-31 (helper)Helper function resolveTaskFilterIds used by search_tasks to resolve optional projectName/tagName to IDs.
async function resolveTaskFilterIds(params: { projectId?: string; projectName?: string; tagId?: string; tagName?: string; }) { if (!params.projectName && !params.tagName) { return { projectId: params.projectId, tagId: params.tagId, }; } const [projects, tags] = await Promise.all([ params.projectName ? SpClient.getProjects() : Promise.resolve([]), params.tagName ? SpClient.getTags() : Promise.resolve([]), ]); return { projectId: resolveProjectId(projects, params.projectId, params.projectName), tagId: resolveTagId(tags, params.tagId, params.tagName), }; }