@@ -32,7 +32,7 @@ async def handle_list_tools() -> list[types.Tool]:
32
32
"type" : "object" ,
33
33
"properties" : {
34
34
"query" : {"type" : "string" },
35
- "namespace" : {"type" : "string" , "enum" : ["article" , "issue" , "ticket" ]},
35
+ "namespace" : {"type" : "string" , "enum" : ["article" , "issue" , "ticket" , "part" , "dev_user" ]},
36
36
},
37
37
"required" : ["query" , "namespace" ],
38
38
},
@@ -47,6 +47,21 @@ async def handle_list_tools() -> list[types.Tool]:
47
47
},
48
48
"required" : ["id" ],
49
49
},
50
+ ),
51
+ types .Tool (
52
+ name = "create_object" ,
53
+ description = "Create a new isssue or ticket in DevRev" ,
54
+ inputSchema = {
55
+ "type" : "object" ,
56
+ "properties" : {
57
+ "type" : {"type" : "string" , "enum" : ["issue" , "ticket" ]},
58
+ "title" : {"type" : "string" },
59
+ "body" : {"type" : "string" },
60
+ "applies_to_part" : {"type" : "string" },
61
+ "owned_by" : {"type" : "array" , "items" : {"type" : "string" }}
62
+ },
63
+ "required" : ["type" , "title" , "applies_to_part" ],
64
+ },
50
65
)
51
66
]
52
67
@@ -118,6 +133,52 @@ async def handle_call_tool(
118
133
text = f"Object information for '{ id } ':\n { object_info } "
119
134
)
120
135
]
136
+ elif name == "create_object" :
137
+ if not arguments :
138
+ raise ValueError ("Missing arguments" )
139
+
140
+ # Mandatory fields
141
+ object_type = arguments .get ("type" )
142
+ if not object_type :
143
+ raise ValueError ("Missing type parameter" )
144
+
145
+ title = arguments .get ("title" )
146
+ if not title :
147
+ raise ValueError ("Missing title parameter" )
148
+
149
+ applies_to_part = arguments .get ("applies_to_part" )
150
+ if not applies_to_part :
151
+ raise ValueError ("Missing applies_to_part parameter" )
152
+
153
+ # Optional fields
154
+ body = arguments .get ("body" , "" )
155
+ owned_by = arguments .get ("owned_by" , [])
156
+
157
+ response = make_devrev_request (
158
+ "works.create" ,
159
+ {
160
+ "type" : object_type ,
161
+ "title" : title ,
162
+ "body" : body ,
163
+ "applies_to_part" : applies_to_part ,
164
+ "owned_by" : owned_by
165
+ }
166
+ )
167
+ if response .status_code != 201 :
168
+ error_text = response .text
169
+ return [
170
+ types .TextContent (
171
+ type = "text" ,
172
+ text = f"Create object failed with status { response .status_code } : { error_text } "
173
+ )
174
+ ]
175
+
176
+ return [
177
+ types .TextContent (
178
+ type = "text" ,
179
+ text = f"Object created successfully: { response .json ()} "
180
+ )
181
+ ]
121
182
else :
122
183
raise ValueError (f"Unknown tool: { name } " )
123
184
0 commit comments