Skip to content

feat: add advanced_search_work_items tool#88

Open
lifeiscontent wants to merge 1 commit intomakeplane:mainfrom
lifeiscontent:feat/work-item-query-filters
Open

feat: add advanced_search_work_items tool#88
lifeiscontent wants to merge 1 commit intomakeplane:mainfrom
lifeiscontent:feat/work-item-query-filters

Conversation

@lifeiscontent
Copy link
Collaborator

@lifeiscontent lifeiscontent commented Mar 23, 2026

Summary

Adds a new advanced_search_work_items MCP tool that exposes the advanced search endpoint, enabling structured filtering of work items by assignee, state, priority, labels, dates, and more using AND/OR logic.

New Tool: advanced_search_work_items

Parameters:

  • query — optional free-text search
  • filters — structured AND/OR filter dict (e.g. {"and": [{"state_group__in": ["unstarted", "started"]}, {"priority__in": ["urgent", "high"]}]})
  • project_id — scope to a specific project
  • workspace_search — search across all projects
  • limit — max results

Supported filter keys: assignee_id, state_id, state_group, priority, label_id, created_by_id, is_draft, is_archived, start_date, target_date, cycle_id, module_id, subscriber_id, and their __in variants.

Context

This complements the existing search_work_items tool (text search only) with full filter support via the existing advanced-search API endpoint.

Dependency

  • Requires plane-python-sdk#24 for project_id and workspace_search support in AdvancedSearchWorkItem

Verified

  • All 13 non-integration tests pass
  • Advanced search filtering tested end-to-end against UAT

Summary by CodeRabbit

  • New Features
    • Added an advanced work-item search: free-text query plus structured AND/OR filters, optional project scoping or workspace-wide search, and result limiting for more precise, targeted searches.

Copilot AI review requested due to automatic review settings March 23, 2026 00:17
@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Warning

Rate limit exceeded

@lifeiscontent has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff811971-b9af-4746-a820-bcab59bcc506

📥 Commits

Reviewing files that changed from the base of the PR and between 6ee0ea4 and 5908c9a.

📒 Files selected for processing (1)
  • plane_mcp/tools/work_items.py
📝 Walkthrough

Walkthrough

Adds a new MCP tool function advanced_search_work_items(...) and associated imports to perform structured advanced searches for work items via client.work_items.advanced_search, returning a list of AdvancedSearchResult objects.

Changes

Cohort / File(s) Summary
Advanced Work Item Search
plane_mcp/tools/work_items.py
Added imports AdvancedSearchResult, AdvancedSearchWorkItem and implemented `advanced_search_work_items(query: str

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Tool as advanced_search_work_items
    participant Client as MCP Client
    participant API as Work Items API
    participant Model as AdvancedSearchResult

    Caller->>Tool: call advanced_search_work_items(query, filters, project_id, workspace_search, limit)
    Tool->>Client: client.work_items.advanced_search(workspace_slug, data=AdvancedSearchWorkItem(...))
    Client->>API: HTTP request with payload
    API-->>Client: HTTP response (results)
    Client-->>Tool: list[AdvancedSearchResult]
    Tool-->>Caller: return results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I hopped through code to find the art,
A search that splits and joins each part,
Filters stitched and queries bright,
Results returned — a joyful sight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title states 'feat: add advanced_search_work_items tool', but the PR objectives describe adding filter parameters to the existing 'list_work_items' tool, not a new advanced search tool. This is a significant mismatch. Update the PR title to accurately reflect the main change: 'feat: expose work item filter params in list_work_items tool' (as stated in the PR summary objectives), or clarify if the PR actually implements a new advanced_search_work_items tool.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
plane_mcp/tools/work_items.py (1)

35-36: Consider using Literal types for stricter input validation.

The docstring documents specific valid values for state_groups and priorities. For consistency with how create_work_item validates priority against PriorityEnum, you could use Literal types to provide better IDE hints and MCP schema generation.

💡 Optional: Add type constraints
+from typing import Literal, get_args
+
+StateGroup = Literal["backlog", "unstarted", "started", "completed", "cancelled"]
+
 def list_work_items(
     ...
-    state_groups: list[str] | None = None,
-    priorities: list[str] | None = None,
+    state_groups: list[StateGroup] | None = None,
+    priorities: list[PriorityEnum] | None = None,

This is optional since the backend will handle invalid values gracefully, but it would improve the developer experience with better autocomplete and schema documentation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plane_mcp/tools/work_items.py` around lines 35 - 36, Change the parameter
types for state_groups and priorities to use typing.Literal (e.g.,
list[Literal["backlog","in_progress","done"]] | None and
list[Literal["low","medium","high"]] | None) to match the documented valid
values and improve IDE/schema hints; add the appropriate import (from typing
import Literal) at the top and update any related type hints where these
parameters are declared (state_groups, priorities in the function signature in
plane_mcp/tools/work_items.py) so they align with the documented values and
PriorityEnum validation used in create_work_item.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@plane_mcp/tools/work_items.py`:
- Around line 35-36: Change the parameter types for state_groups and priorities
to use typing.Literal (e.g., list[Literal["backlog","in_progress","done"]] |
None and list[Literal["low","medium","high"]] | None) to match the documented
valid values and improve IDE/schema hints; add the appropriate import (from
typing import Literal) at the top and update any related type hints where these
parameters are declared (state_groups, priorities in the function signature in
plane_mcp/tools/work_items.py) so they align with the documented values and
PriorityEnum validation used in create_work_item.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ae933bc3-fe3c-44f0-9de1-cb7f35f27291

📥 Commits

Reviewing files that changed from the base of the PR and between a219916 and 43c200b.

📒 Files selected for processing (1)
  • plane_mcp/tools/work_items.py

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the list_work_items MCP tool to expose additional server-side filtering options that map to Plane SDK WorkItemQueryParams __in filter fields, enabling callers to narrow results by assignees, states, priorities, labels, creators, and draft/archived status.

Changes:

  • Added 8 new optional filter parameters to list_work_items (assignees, states/groups, priorities, labels, creators, draft, archived).
  • Wired the new parameters into the WorkItemQueryParams passed to client.work_items.list(...).
  • Updated the tool docstring to describe the new filters and expected values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +79 to +82
state_group__in=state_groups,
priority__in=priorities,
label_id__in=label_ids,
created_by_id__in=created_by_ids,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state_groups and priorities are currently accepted as list[str] and passed straight into state_group__in / priority__in. Elsewhere in this repo, enum-like inputs are validated against the SDK Literal enums (e.g., GroupEnum in state tools and PriorityEnum in create/update work item tools). Consider typing these as list[GroupEnum] / list[PriorityEnum] (or validating each element against get_args(...)) so invalid values don’t get silently forwarded (or cause a downstream API validation error).

Copilot uses AI. Check for mistakes.
Comment on lines +55 to +60
assignee_ids: Filter by assignee user UUIDs
state_ids: Filter by state UUIDs
state_groups: Filter by state groups (backlog, unstarted, started, completed, cancelled)
priorities: Filter by priority levels (urgent, high, medium, low, none)
label_ids: Filter by label UUIDs
created_by_ids: Filter by creator user UUIDs
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring documents allowed values for state_groups and priorities, but the function signature doesn’t reflect those constraints (both are list[str]). Using the existing SDK enum types (e.g., GroupEnum / PriorityEnum) here would improve the generated tool schema and keep the API self-documenting/consistent with other tools.

Copilot uses AI. Check for mistakes.
@Saurabhkmr98
Copy link
Member

@lifeiscontent we've fixed this issue in #89 using our advanced work items search API.

@sriramveeraghanta sriramveeraghanta changed the base branch from canary to main March 23, 2026 12:19
@lifeiscontent lifeiscontent force-pushed the feat/work-item-query-filters branch from 43c200b to 6ee0ea4 Compare March 24, 2026 07:58
@lifeiscontent lifeiscontent changed the title feat: expose work item filter params in list_work_items tool feat: add advanced_search_work_items tool Mar 24, 2026
Add a new MCP tool that exposes the advanced search endpoint,
enabling structured filtering of work items by assignee, state,
priority, labels, dates, and more using AND/OR logic.

This complements the existing search_work_items tool (text search
only) with full filter support via the advanced-search API endpoint.
@lifeiscontent lifeiscontent force-pushed the feat/work-item-query-filters branch from 6ee0ea4 to 5908c9a Compare March 24, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants