Skip to content

Commit b8ff2b5

Browse files
Added create_object tool
This tool enables creating DevRev's issues & tickets to start with.
1 parent 2c8dda1 commit b8ff2b5

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

src/devrev_mcp/server.py

+62-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def handle_list_tools() -> list[types.Tool]:
3232
"type": "object",
3333
"properties": {
3434
"query": {"type": "string"},
35-
"namespace": {"type": "string", "enum": ["article", "issue", "ticket"]},
35+
"namespace": {"type": "string", "enum": ["article", "issue", "ticket", "part", "dev_user"]},
3636
},
3737
"required": ["query", "namespace"],
3838
},
@@ -47,6 +47,21 @@ async def handle_list_tools() -> list[types.Tool]:
4747
},
4848
"required": ["id"],
4949
},
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+
},
5065
)
5166
]
5267

@@ -118,6 +133,52 @@ async def handle_call_tool(
118133
text=f"Object information for '{id}':\n{object_info}"
119134
)
120135
]
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+
]
121182
else:
122183
raise ValueError(f"Unknown tool: {name}")
123184

0 commit comments

Comments
 (0)