8
8
import asyncio
9
9
import os
10
10
import requests
11
+ import json
12
+ import httpx
11
13
12
14
from mcp .server .models import InitializationOptions
13
15
import mcp .types as types
@@ -30,6 +32,20 @@ async def handle_list_tools() -> list[types.Tool]:
30
32
description = "Fetch the current DevRev user details. When the user specifies 'me' in the query, this tool should be called to get the user details." ,
31
33
inputSchema = {"type" : "object" , "properties" : {}},
32
34
),
35
+ types .Tool (
36
+ name = "get_vistas" ,
37
+ description = "Retrieve all available vistas (filtered views) from DevRev" ,
38
+ inputSchema = {
39
+ "type" : "object" ,
40
+ "properties" : {
41
+ "id" : {
42
+ "type" : "string" ,
43
+ "description" : "The DevRev ID of the vista"
44
+ }
45
+ },
46
+ "required" : ["id" ]
47
+ },
48
+ ),
33
49
types .Tool (
34
50
name = "search" ,
35
51
description = "Search DevRev using the provided query" ,
@@ -39,7 +55,7 @@ async def handle_list_tools() -> list[types.Tool]:
39
55
"query" : {"type" : "string" },
40
56
"namespace" : {
41
57
"type" : "string" ,
42
- "enum" : ["article" , "issue" , "ticket" , "part" , "dev_user" , "account" , "rev_org" ],
58
+ "enum" : ["article" , "issue" , "ticket" , "part" , "dev_user" , "account" , "rev_org" , "vista" ],
43
59
"description" : "The namespace to search in. Use this to specify the type of object to search for."
44
60
},
45
61
},
@@ -439,6 +455,39 @@ async def handle_call_tool(
439
455
text = f"Current DevRev user details: { response .json ()} "
440
456
)
441
457
]
458
+
459
+ elif name == "get_vistas" :
460
+ if not arguments :
461
+ raise ValueError ("Missing arguments" )
462
+
463
+ id = arguments .get ("id" )
464
+ if not id :
465
+ raise ValueError ("Missing id " )
466
+
467
+ response = make_devrev_request (
468
+ "vistas.get" ,
469
+ {
470
+ "id" : id
471
+ }
472
+ )
473
+
474
+ if response .status_code != 200 :
475
+ error_text = response .text
476
+ return [
477
+ types .TextContent (
478
+ type = "text" ,
479
+ text = f"get_vistas failed with status { response .status_code } : { error_text } "
480
+ )
481
+ ]
482
+
483
+ return [
484
+ types .TextContent (
485
+ type = "text" ,
486
+ text = f"Vista details for '{ id } ':\n { response .json ()} "
487
+ )
488
+ ]
489
+
490
+
442
491
elif name == "search" :
443
492
if not arguments :
444
493
raise ValueError ("Missing arguments" )
@@ -547,6 +596,9 @@ async def handle_call_tool(
547
596
text = f"Object created successfully: { response .json ()} "
548
597
)
549
598
]
599
+ # elif name == "get_vistas":
600
+ # return await _get_vistas(arguments)
601
+
550
602
elif name == "update_work" :
551
603
if not arguments :
552
604
raise ValueError ("Missing arguments" )
0 commit comments