@@ -38,41 +38,84 @@ async def handle_list_tools() -> list[types.Tool]:
38
38
},
39
39
),
40
40
types .Tool (
41
- name = "get_object " ,
42
- description = "Get all information about a DevRev issue and ticket using its ID" ,
41
+ name = "get_work " ,
42
+ description = "Get all information about a DevRev work item (issue, ticket) using its ID" ,
43
43
inputSchema = {
44
44
"type" : "object" ,
45
45
"properties" : {
46
- "id" : {"type" : "string" },
46
+ "id" : {"type" : "string" , "description" : "The DevRev ID of the work item" },
47
47
},
48
48
"required" : ["id" ],
49
49
},
50
50
),
51
51
types .Tool (
52
- name = "create_object " ,
53
- description = "Create a new isssue or ticket in DevRev" ,
52
+ name = "create_work " ,
53
+ description = "Create a new work item (issue, ticket) in DevRev" ,
54
54
inputSchema = {
55
55
"type" : "object" ,
56
56
"properties" : {
57
57
"type" : {"type" : "string" , "enum" : ["issue" , "ticket" ]},
58
58
"title" : {"type" : "string" },
59
59
"body" : {"type" : "string" },
60
- "applies_to_part" : {"type" : "string" },
61
- "owned_by" : {"type" : "array" , "items" : {"type" : "string" }}
60
+ "applies_to_part" : {"type" : "string" , "description" : "The DevRev ID of the part to which the work item applies" },
61
+ "owned_by" : {"type" : "array" , "items" : {"type" : "string" }, "description" : "The DevRev IDs of the users who are assigned to the work item" }
62
62
},
63
63
"required" : ["type" , "title" , "applies_to_part" ],
64
64
},
65
65
),
66
66
types .Tool (
67
- name = "update_object " ,
68
- description = "Update an existing issue or ticket in DevRev" ,
67
+ name = "update_work " ,
68
+ description = "Update an existing work item (issue, ticket) in DevRev" ,
69
69
inputSchema = {
70
70
"type" : "object" ,
71
71
"properties" : {
72
72
"type" : {"type" : "string" , "enum" : ["issue" , "ticket" ]},
73
73
"id" : {"type" : "string" },
74
74
"title" : {"type" : "string" },
75
75
"body" : {"type" : "string" },
76
+ "applies_to_part" : {"type" : "string" , "description" : "The DevRev ID of the part to which the work item applies" },
77
+ "owned_by" : {"type" : "array" , "items" : {"type" : "string" }, "description" : "The DevRev IDs of the users who are assigned to the work item" },
78
+ },
79
+ "required" : ["id" , "type" ],
80
+ },
81
+ ),
82
+ types .Tool (
83
+ name = "get_part" ,
84
+ description = "Get information about a part (enhancement) in DevRev using its ID" ,
85
+ inputSchema = {
86
+ "type" : "object" ,
87
+ "properties" : {"id" : {"type" : "string" , "description" : "The DevRev ID of the part" }},
88
+ "required" : ["id" ],
89
+ },
90
+ ),
91
+ types .Tool (
92
+ name = "create_part" ,
93
+ description = "Create a new part (enhancement) in DevRev" ,
94
+ inputSchema = {
95
+ "type" : "object" ,
96
+ "properties" : {
97
+ "type" : {"type" : "string" , "enum" : ["enhancement" ]},
98
+ "name" : {"type" : "string" },
99
+ "owned_by" : {"type" : "array" , "items" : {"type" : "string" }, "description" : "The DevRev IDs of the users assigned to the part" },
100
+ "parent_part" : {"type" : "array" , "items" : {"type" : "string" }, "description" : "The DevRev IDs of the parent parts" },
101
+ "description" : {"type" : "string" , "description" : "The description of the part" },
102
+ },
103
+ "required" : ["type" , "name" , "owned_by" , "parent_part" ],
104
+ },
105
+ ),
106
+ types .Tool (
107
+ name = "update_part" ,
108
+ description = "Update an existing part (enhancement) in DevRev" ,
109
+ inputSchema = {
110
+ "type" : "object" ,
111
+ "properties" : {
112
+ "type" : {"type" : "string" , "enum" : ["enhancement" ]},
113
+ "id" : {"type" : "string" , "description" : "The DevRev ID of the part" },
114
+ "name" : {"type" : "string" , "description" : "The name of the part" },
115
+ "owned_by" : {"type" : "array" , "items" : {"type" : "string" }, "description" : "The DevRev IDs of the users assigned to the part" },
116
+ "description" : {"type" : "string" , "description" : "The description of the part" },
117
+ "target_close_date" : {"type" : "string" , "description" : "The target closed date of the part, for example: 2025-06-03T00:00:00Z" },
118
+ "target_start_date" : {"type" : "string" , "description" : "The target start date of the part, for example: 2025-06-03T00:00:00Z" },
76
119
},
77
120
"required" : ["id" , "type" ],
78
121
},
@@ -101,7 +144,10 @@ async def handle_call_tool(
101
144
102
145
response = make_devrev_request (
103
146
"search.hybrid" ,
104
- {"query" : query , "namespace" : namespace }
147
+ {
148
+ "query" : query ,
149
+ "namespace" : namespace
150
+ }
105
151
)
106
152
if response .status_code != 200 :
107
153
error_text = response .text
@@ -119,7 +165,7 @@ async def handle_call_tool(
119
165
text = f"Search results for '{ query } ':\n { search_results } "
120
166
)
121
167
]
122
- elif name == "get_object " :
168
+ elif name == "get_work " :
123
169
if not arguments :
124
170
raise ValueError ("Missing arguments" )
125
171
@@ -129,7 +175,9 @@ async def handle_call_tool(
129
175
130
176
response = make_devrev_request (
131
177
"works.get" ,
132
- {"id" : id }
178
+ {
179
+ "id" : id
180
+ }
133
181
)
134
182
if response .status_code != 200 :
135
183
error_text = response .text
@@ -140,20 +188,18 @@ async def handle_call_tool(
140
188
)
141
189
]
142
190
143
- object_info = response .json ()
144
191
return [
145
192
types .TextContent (
146
193
type = "text" ,
147
- text = f"Object information for '{ id } ':\n { object_info } "
194
+ text = f"Object information for '{ id } ':\n { response . json () } "
148
195
)
149
196
]
150
- elif name == "create_object " :
197
+ elif name == "create_work " :
151
198
if not arguments :
152
199
raise ValueError ("Missing arguments" )
153
200
154
- # Mandatory fields
155
- object_type = arguments .get ("type" )
156
- if not object_type :
201
+ type = arguments .get ("type" )
202
+ if not type :
157
203
raise ValueError ("Missing type parameter" )
158
204
159
205
title = arguments .get ("title" )
@@ -164,14 +210,13 @@ async def handle_call_tool(
164
210
if not applies_to_part :
165
211
raise ValueError ("Missing applies_to_part parameter" )
166
212
167
- # Optional fields
168
213
body = arguments .get ("body" , "" )
169
214
owned_by = arguments .get ("owned_by" , [])
170
215
171
216
response = make_devrev_request (
172
217
"works.create" ,
173
218
{
174
- "type" : object_type ,
219
+ "type" : type ,
175
220
"title" : title ,
176
221
"body" : body ,
177
222
"applies_to_part" : applies_to_part ,
@@ -193,37 +238,35 @@ async def handle_call_tool(
193
238
text = f"Object created successfully: { response .json ()} "
194
239
)
195
240
]
196
- elif name == "update_object" :
197
- # Update mandatory fields
241
+ elif name == "update_work" :
198
242
if not arguments :
199
243
raise ValueError ("Missing arguments" )
200
244
201
245
id = arguments .get ("id" )
202
246
if not id :
203
247
raise ValueError ("Missing id parameter" )
204
248
205
- object_type = arguments .get ("type" )
206
- if not object_type :
249
+ type = arguments .get ("type" )
250
+ if not type :
207
251
raise ValueError ("Missing type parameter" )
208
252
209
- # Update title and body
210
253
title = arguments .get ("title" )
211
254
body = arguments .get ("body" )
212
-
213
- # Build request payload with only the fields that have values
214
- update_payload = {"id" : id , "type" : object_type }
255
+ sprint = arguments . get ( "sprint" )
256
+
257
+ payload = {"id" : id , "type" : type }
215
258
if title :
216
- update_payload ["title" ] = title
259
+ payload ["title" ] = title
217
260
if body :
218
- update_payload ["body" ] = body
261
+ payload ["body" ] = body
262
+ if sprint :
263
+ payload ["sprint" ] = sprint
219
264
220
- # Make devrev request to update the object
221
265
response = make_devrev_request (
222
266
"works.update" ,
223
- update_payload
267
+ payload
224
268
)
225
269
226
- # Check if the request was successful
227
270
if response .status_code != 200 :
228
271
error_text = response .text
229
272
return [
@@ -239,6 +282,142 @@ async def handle_call_tool(
239
282
text = f"Object updated successfully: { id } "
240
283
)
241
284
]
285
+ elif name == "get_part" :
286
+ if not arguments :
287
+ raise ValueError ("Missing arguments" )
288
+
289
+ id = arguments .get ("id" )
290
+ if not id :
291
+ raise ValueError ("Missing id parameter" )
292
+
293
+ response = make_devrev_request (
294
+ "parts.get" ,
295
+ {
296
+ "id" : id
297
+ }
298
+ )
299
+
300
+ if response .status_code != 200 :
301
+ error_text = response .text
302
+ return [
303
+ types .TextContent (
304
+ type = "text" ,
305
+ text = f"Get part failed with status { response .status_code } : { error_text } "
306
+ )
307
+ ]
308
+
309
+ return [
310
+ types .TextContent (
311
+ type = "text" ,
312
+ text = f"Part information for '{ id } ':\n { response .json ()} "
313
+ )
314
+ ]
315
+ elif name == "create_part" :
316
+ if not arguments :
317
+ raise ValueError ("Missing arguments" )
318
+
319
+ payload = {}
320
+
321
+ type = arguments .get ("type" )
322
+ if not type :
323
+ raise ValueError ("Missing type parameter" )
324
+ payload ["type" ] = type
325
+
326
+ part_name = arguments .get ("name" )
327
+ if not part_name :
328
+ raise ValueError ("Missing name parameter" )
329
+ payload ["name" ] = part_name
330
+
331
+ owned_by = arguments .get ("owned_by" )
332
+ if not owned_by :
333
+ raise ValueError ("Missing owned_by parameter" )
334
+ payload ["owned_by" ] = owned_by
335
+
336
+ parent_part = arguments .get ("parent_part" )
337
+ if not parent_part :
338
+ raise ValueError ("Missing parent_part parameter" )
339
+ payload ["parent_part" ] = parent_part
340
+
341
+ description = arguments .get ("description" )
342
+ if description :
343
+ payload ["description" ] = description
344
+
345
+ response = make_devrev_request (
346
+ "parts.create" ,
347
+ payload
348
+ )
349
+
350
+ if response .status_code != 201 :
351
+ error_text = response .text
352
+ return [
353
+ types .TextContent (
354
+ type = "text" ,
355
+ text = f"Create part failed with status { response .status_code } : { error_text } "
356
+ )
357
+ ]
358
+
359
+ return [
360
+ types .TextContent (
361
+ type = "text" ,
362
+ text = f"Part created successfully: { response .json ()} "
363
+ )
364
+ ]
365
+ elif name == "update_part" :
366
+ if not arguments :
367
+ raise ValueError ("Missing arguments" )
368
+
369
+ payload = {}
370
+
371
+ id = arguments .get ("id" )
372
+ if not id :
373
+ raise ValueError ("Missing id parameter" )
374
+ payload ["id" ] = id
375
+
376
+ type = arguments .get ("type" )
377
+ if not type :
378
+ raise ValueError ("Missing type parameter" )
379
+ payload ["type" ] = type
380
+
381
+ part_name = arguments .get ("name" )
382
+ if part_name :
383
+ payload ["name" ] = part_name
384
+
385
+ owned_by = arguments .get ("owned_by" )
386
+ if owned_by :
387
+ payload ["owned_by" ] = owned_by
388
+
389
+ description = arguments .get ("description" )
390
+ if description :
391
+ payload ["description" ] = description
392
+
393
+ target_close_date = arguments .get ("target_close_date" )
394
+ if target_close_date :
395
+ payload ["target_close_date" ] = target_close_date
396
+
397
+ target_start_date = arguments .get ("target_start_date" )
398
+ if target_start_date :
399
+ payload ["target_start_date" ] = target_start_date
400
+
401
+ response = make_devrev_request (
402
+ "parts.update" ,
403
+ payload
404
+ )
405
+
406
+ if response .status_code != 200 :
407
+ error_text = response .text
408
+ return [
409
+ types .TextContent (
410
+ type = "text" ,
411
+ text = f"Update part failed with status { response .status_code } : { error_text } "
412
+ )
413
+ ]
414
+
415
+ return [
416
+ types .TextContent (
417
+ type = "text" ,
418
+ text = f"Part updated successfully: { id } "
419
+ )
420
+ ]
242
421
else :
243
422
raise ValueError (f"Unknown tool: { name } " )
244
423
0 commit comments