Add tags filter to task_list (MCP + REST + domain)#3
Open
memphyssk wants to merge 1 commit into
Open
Conversation
Enables cross-project tag rollups (e.g., OKR or iteration progress) without
client-side filtering. Currently only the write side (task_create / task_update)
accepted tags — task_list dropped them on the floor.
Implements AND-mode: list({ tags: ["okr:H1-3", "iter:H1"] }) returns tasks
that have BOTH listed tags. Empty array or omitted = no tag filter.
- types.ts: TaskListFilter gains optional tags?: string[]
- domain/tasks.ts: list() adds one EXISTS (json_each(t.tags)) clause per tag
- transport/mcp.ts: task_list inputSchema declares tags array
- transport/mcp-handlers.ts: handleList passes tags through
- transport/rest.ts: GET /api/tasks parses ?tags=a,b or repeated ?tags=
- tests/tasks.test.ts: 5 new domain-level tests (single, AND, empty, cross-project, combined)
- tests/mcp.test.ts: 4 new MCP-handler tests (parity with REST/domain)
All 440 tests pass; npm run check (typecheck + lint + format:check + test) green.
memphyssk
pushed a commit
to memphyssk/agent-tasks
that referenced
this pull request
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
tagsfilter totask_listacross all three transports (MCP, REST, domain). Currently only the write side (task_create/task_update) accepts tags —task_listdrops them on the floor. This enables cross-project tag rollups (e.g., OKR or iteration progress) without forcing every caller to do per-project list + client-side filter + union.Why
We're using
agent-tasksas the queue engine for a multi-project framework where tasks are tagged withokr:OKR-H1-3anditer:H1to support cross-project rollups (a single OKR's progress spans both engineering and business projects, each with its own pipeline). The natural query istask_list({ tags: ["okr:OKR-H1-3"] }). Today this requires:…which is fine until task counts grow. With the filter, the same query is one call and runs in SQL.
The infrastructure was already 90% there —
tasks.tagsis a JSON-serializedTEXTcolumn,optStringArrayhelper is used bytask_update, andvalidateTagsexists. This PR just wires the read path.How
AND-mode:
list({ tags: ["a", "b"] })returns tasks that have BOTHaandb. One clause per tag usingEXISTS (SELECT 1 FROM json_each(t.tags) WHERE value = ?). SQLite'sjson_eachis in core json1 (compiled into better-sqlite3 by default), so no schema migration or new dependency.Empty array or omitted = no tag filter (consistent with existing filter conventions).
Changes
src/types.tsTaskListFiltergainstags?: string[]src/domain/tasks.tslist()addsAND t.tags IS NOT NULL AND EXISTS (SELECT 1 FROM json_each(t.tags) WHERE value = ?)per tagsrc/transport/mcp.tstask_listinput schema declarestags: array<string>src/transport/mcp-handlers.tshandleListpassestagsthrough viaoptStringArray(args, 'tags')src/transport/rest.tsGET /api/tasksparses?tags=a,b(comma-split) and repeated?tags=a&tags=bTests
9 new tests, all passing:
tests/tasks.test.ts(5): single tag, AND across multiple tags, empty/no-match, cross-project rollup, tag + project combo.tests/mcp.test.ts(4): single tag via MCP handler, AND-mode via MCP, cross-project rollup via MCP, tag + project combo via MCP.Open design choices (happy to adjust)
tags_any?: string[]for OR-mode would be straightforward.?tags=okr:H1,iter:H1) and repeated (?tags=okr:H1&tags=iter:H1) for ergonomic flexibility.Follow-ups (not in this PR)
tags_any?: string[]for OR-mode rollups.tags_exclude?: string[]for "everything not tagged X".task_tags_summaryreturning per-tag counts) for dashboard-side rollup widgets.🤖 Generated with Claude Code