Skip to content

Commit d26f5cc

Browse files
Anoushka KumarAnoushka Kumar
authored andcommitted
Add vista namespace to search tool
1 parent 9c8313b commit d26f5cc

File tree

2 files changed

+184
-131
lines changed

2 files changed

+184
-131
lines changed

src/devrev_mcp/server.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import asyncio
99
import os
1010
import requests
11+
import json
12+
import httpx
1113

1214
from mcp.server.models import InitializationOptions
1315
import mcp.types as types
@@ -30,6 +32,20 @@ async def handle_list_tools() -> list[types.Tool]:
3032
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.",
3133
inputSchema={"type": "object", "properties": {}},
3234
),
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+
),
3349
types.Tool(
3450
name="search",
3551
description="Search DevRev using the provided query",
@@ -39,7 +55,7 @@ async def handle_list_tools() -> list[types.Tool]:
3955
"query": {"type": "string"},
4056
"namespace": {
4157
"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"],
4359
"description": "The namespace to search in. Use this to specify the type of object to search for."
4460
},
4561
},
@@ -439,6 +455,39 @@ async def handle_call_tool(
439455
text=f"Current DevRev user details: {response.json()}"
440456
)
441457
]
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+
442491
elif name == "search":
443492
if not arguments:
444493
raise ValueError("Missing arguments")
@@ -547,6 +596,9 @@ async def handle_call_tool(
547596
text=f"Object created successfully: {response.json()}"
548597
)
549598
]
599+
# elif name == "get_vistas":
600+
# return await _get_vistas(arguments)
601+
550602
elif name == "update_work":
551603
if not arguments:
552604
raise ValueError("Missing arguments")

0 commit comments

Comments
 (0)