Skip to content

Commit 3360187

Browse files
Anoushka KumarAnoushka Kumar
authored andcommitted
feat: Add list_vistas tool for listing DevRev vistas
- Add list_vistas tool definition with comprehensive input schema - Implement handler with support for all API parameters - Support filtering by type, flavor, state, created_by, members - Include pagination support with cursor and mode parameters - Add limit and sorting capabilities - Enable default vista filtering and item skipping options
1 parent d62f2c5 commit 3360187

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

src/devrev_mcp/server.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,26 @@ async def handle_list_tools() -> list[types.Tool]:
4646
"required": ["id"]
4747
},
4848
),
49+
types.Tool(
50+
name="list_vistas",
51+
description="List all available vistas (filtered views) from DevRev with optional filtering",
52+
inputSchema={
53+
"type": "object",
54+
"properties": {
55+
"type": {"type": "array", "items": {"type": "string", "enum": ["curated", "dynamic", "grouped"]}, "description": "Filters for vistas of the specific type"},
56+
"cursor": {"type": "string", "description": "The cursor to resume iteration from. If not provided, iteration begins from the first page"},
57+
"created_by": {"type": "array", "items": {"type": "string"}, "description": "Filters for vistas created by any of these users"},
58+
"flavor": {"type": "array", "items": {"type": "string", "enum": ["nnl", "sprint_board", "support_inbox"]}, "description": "Filters for vistas of specific flavor"},
59+
"is_default": {"type": "boolean", "description": "Whether the default vistas should be fetched or not"},
60+
"limit": {"type": "integer", "description": "The maximum number of vistas to return. The default is 50, the maximum is 100"},
61+
"members": {"type": "array", "items": {"type": "string"}, "description": "Filters for vistas accessible to the input members"},
62+
"mode": {"type": "string", "enum": ["after", "before"], "description": "The iteration mode to use. If 'after', then entries after the provided cursor will be returned. If 'before', then entries before the provided cursor will be returned"},
63+
"sort_by": {"type": "array", "items": {"type": "string"}, "description": "Fields to sort the vistas by and the direction to sort them"},
64+
"state": {"type": "array", "items": {"type": "string", "enum": ["active", "completed", "planned"]}, "description": "Denotes the state of the vista group item"},
65+
"skip_items": {"type": "boolean", "description": "Denotes whether to skip items of vista_group_item in response"}
66+
}
67+
},
68+
),
4969
types.Tool(
5070
name="search",
5171
description="Search DevRev using the provided query",
@@ -487,6 +507,77 @@ async def handle_call_tool(
487507
)
488508
]
489509

510+
elif name == "list_vistas":
511+
if not arguments:
512+
arguments = {}
513+
514+
payload = {}
515+
516+
# Optional parameters from the API
517+
vista_type = arguments.get("type")
518+
if vista_type:
519+
payload["type"] = vista_type
520+
521+
cursor = arguments.get("cursor")
522+
if cursor:
523+
payload["cursor"] = cursor
524+
525+
created_by = arguments.get("created_by")
526+
if created_by:
527+
payload["created_by"] = created_by
528+
529+
flavor = arguments.get("flavor")
530+
if flavor:
531+
payload["flavor"] = flavor
532+
533+
is_default = arguments.get("is_default")
534+
if is_default is not None:
535+
payload["is_default"] = is_default
536+
537+
limit = arguments.get("limit")
538+
if limit:
539+
payload["limit"] = limit
540+
541+
members = arguments.get("members")
542+
if members:
543+
payload["members"] = members
544+
545+
mode = arguments.get("mode")
546+
if mode:
547+
payload["mode"] = mode
548+
549+
sort_by = arguments.get("sort_by")
550+
if sort_by:
551+
payload["sort_by"] = sort_by
552+
553+
state = arguments.get("state")
554+
if state:
555+
payload["state"] = state
556+
557+
skip_items = arguments.get("skip_items")
558+
if skip_items is not None:
559+
payload["skip_items"] = skip_items
560+
561+
response = make_devrev_request(
562+
"vistas.list",
563+
payload
564+
)
565+
566+
if response.status_code != 200:
567+
error_text = response.text
568+
return [
569+
types.TextContent(
570+
type="text",
571+
text=f"List vistas failed with status {response.status_code}: {error_text}"
572+
)
573+
]
574+
575+
return [
576+
types.TextContent(
577+
type="text",
578+
text=f"Vistas listed successfully:\n{response.json()}"
579+
)
580+
]
490581

491582
elif name == "search":
492583
if not arguments:

0 commit comments

Comments
 (0)