|
6 | 6 | from plane.models.enums import PriorityEnum |
7 | 7 | from plane.models.query_params import RetrieveQueryParams, WorkItemQueryParams |
8 | 8 | from plane.models.work_items import ( |
| 9 | + AdvancedSearchResult, |
| 10 | + AdvancedSearchWorkItem, |
9 | 11 | CreateWorkItem, |
10 | 12 | PaginatedWorkItemResponse, |
11 | 13 | UpdateWorkItem, |
@@ -374,3 +376,52 @@ def search_work_items( |
374 | 376 | ) |
375 | 377 |
|
376 | 378 | return client.work_items.search(workspace_slug=workspace_slug, query=query, params=params) |
| 379 | + |
| 380 | + @mcp.tool() |
| 381 | + def advanced_search_work_items( |
| 382 | + query: str | None = None, |
| 383 | + filters: dict | None = None, |
| 384 | + project_id: str | None = None, |
| 385 | + workspace_search: bool | None = None, |
| 386 | + limit: int | None = None, |
| 387 | + ) -> list[AdvancedSearchResult]: |
| 388 | + """ |
| 389 | + Search work items with advanced filters using AND/OR logic. |
| 390 | +
|
| 391 | + Supports filtering by assignee, state, priority, labels, dates, and more |
| 392 | + using structured filter groups. Use this when you need to find work items |
| 393 | + matching specific criteria (e.g. unassigned urgent items, items in a |
| 394 | + particular state group). |
| 395 | +
|
| 396 | + Filter keys include: assignee_id, assignee_id__in, state_id, state_id__in, |
| 397 | + state_group, state_group__in, priority, priority__in, label_id, label_id__in, |
| 398 | + created_by_id, created_by_id__in, is_draft, is_archived, start_date, target_date, |
| 399 | + target_date__range, cycle_id, module_id, subscriber_id, and more. |
| 400 | +
|
| 401 | + Args: |
| 402 | + query: Optional free-text search string to match against work item |
| 403 | + name and description |
| 404 | + filters: Optional structured filter dict using AND/OR groups. |
| 405 | + Example: {"and": [{"state_group__in": ["unstarted", "started"]}, |
| 406 | + {"priority__in": ["urgent", "high"]}]} |
| 407 | + project_id: Optional project UUID to scope the search to a single project |
| 408 | + workspace_search: If true, search across all projects in the workspace |
| 409 | + limit: Maximum number of results to return |
| 410 | +
|
| 411 | + Returns: |
| 412 | + List of AdvancedSearchResult objects |
| 413 | + """ |
| 414 | + client, workspace_slug = get_plane_client_context() |
| 415 | + |
| 416 | + data = AdvancedSearchWorkItem( |
| 417 | + query=query, |
| 418 | + filters=filters, |
| 419 | + limit=limit, |
| 420 | + project_id=project_id, |
| 421 | + workspace_search=workspace_search, |
| 422 | + ) |
| 423 | + |
| 424 | + return client.work_items.advanced_search( |
| 425 | + workspace_slug=workspace_slug, |
| 426 | + data=data, |
| 427 | + ) |
0 commit comments