Skip to content

Commit f392a2f

Browse files
Merge branch 'main' into add-include-child-parts-to-list-works
2 parents e749685 + 5844706 commit f392a2f

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

src/devrev_mcp/server.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from mcp.server import NotificationOptions, Server
1515
from pydantic import AnyUrl
1616
import mcp.server.stdio
17-
from .utils import make_devrev_request
17+
from .utils import make_devrev_request, make_internal_devrev_request
1818

1919
server = Server("devrev_mcp")
2020

@@ -30,9 +30,9 @@ async def handle_list_tools() -> list[types.Tool]:
3030
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.",
3131
inputSchema={"type": "object", "properties": {}},
3232
),
33-
types.Tool(
33+
types.Tool(
3434
name="get_vista",
35-
description="Retrieve information about a vista in DevRev using its ID",
35+
description="Retrieve information about a vista in DevRev using its ID. In DevRev a vista is a sprint board which contains sprints (or vista group items). The reponse of this tool will contain the sprint (or vista group item) IDs that you can use to filter on sprints.",
3636
inputSchema={
3737
"type": "object",
3838
"properties": {
@@ -43,7 +43,7 @@ async def handle_list_tools() -> list[types.Tool]:
4343
},
4444
"required": ["id"]
4545
},
46-
),
46+
),
4747
types.Tool(
4848
name="search",
4949
description="Search DevRev using the provided query",
@@ -195,6 +195,14 @@ async def handle_list_tools() -> list[types.Tool]:
195195
},
196196
"required": ["after", "before"]
197197
},
198+
"sprint": {
199+
"type": "array",
200+
"items": {
201+
"type": "string",
202+
"description": "The DevRev ID of the sprint to filter on. In DevRev a sprint is a vista group item. You will get these IDs from the response of get vista tool."
203+
},
204+
"description": "Use this to filter on sprints."
205+
}
198206
},
199207
"required": ["type"],
200208
},
@@ -470,7 +478,7 @@ async def handle_call_tool(
470478
if not id:
471479
raise ValueError("Missing id ")
472480

473-
response = make_devrev_request(
481+
response = make_internal_devrev_request(
474482
"vistas.get",
475483
{
476484
"id": id
@@ -751,6 +759,10 @@ async def handle_call_tool(
751759
if modified_date:
752760
payload["modified_date"] = {"type": "range", "after": modified_date["after"], "before": modified_date["before"]}
753761

762+
sprint = arguments.get("sprint")
763+
if sprint:
764+
payload["issue"]["sprint"] = sprint
765+
754766
if payload["issue"] == {}:
755767
payload.pop("issue")
756768

src/devrev_mcp/utils.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,32 @@ def make_devrev_request(endpoint: str, payload: Dict[str, Any]) -> requests.Resp
3737
headers=headers,
3838
json=payload
3939
)
40+
41+
def make_internal_devrev_request(endpoint: str, payload: Dict[str, Any]) -> requests.Response:
42+
"""
43+
Make an authenticated request to the DevRev API.
44+
45+
Args:
46+
endpoint: The API endpoint path (e.g., "works.get" or "search.hybrid")
47+
payload: The JSON payload to send
48+
49+
Returns:
50+
requests.Response object
51+
52+
Raises:
53+
ValueError: If DEVREV_API_KEY environment variable is not set
54+
"""
55+
api_key = os.environ.get("DEVREV_API_KEY")
56+
if not api_key:
57+
raise ValueError("DEVREV_API_KEY environment variable is not set")
58+
59+
headers = {
60+
"Authorization": f"{api_key}",
61+
"Content-Type": "application/json",
62+
}
63+
64+
return requests.post(
65+
f"https://api.devrev.ai/internal/{endpoint}",
66+
headers=headers,
67+
json=payload
68+
)

0 commit comments

Comments
 (0)