Skip to content

Added create_object tool #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devrev/repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deployable: true
63 changes: 62 additions & 1 deletion src/devrev_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def handle_list_tools() -> list[types.Tool]:
"type": "object",
"properties": {
"query": {"type": "string"},
"namespace": {"type": "string", "enum": ["article", "issue", "ticket"]},
"namespace": {"type": "string", "enum": ["article", "issue", "ticket", "part", "dev_user"]},
},
"required": ["query", "namespace"],
},
Expand All @@ -47,6 +47,21 @@ async def handle_list_tools() -> list[types.Tool]:
},
"required": ["id"],
},
),
types.Tool(
name="create_object",
description="Create a new isssue or ticket in DevRev",
inputSchema={
"type": "object",
"properties": {
"type": {"type": "string", "enum": ["issue", "ticket"]},
"title": {"type": "string"},
"body": {"type": "string"},
"applies_to_part": {"type": "string"},
"owned_by": {"type": "array", "items": {"type": "string"}}
},
"required": ["type", "title", "applies_to_part"],
},
)
]

Expand Down Expand Up @@ -118,6 +133,52 @@ async def handle_call_tool(
text=f"Object information for '{id}':\n{object_info}"
)
]
elif name == "create_object":
if not arguments:
raise ValueError("Missing arguments")

# Mandatory fields
object_type = arguments.get("type")
if not object_type:
raise ValueError("Missing type parameter")

title = arguments.get("title")
if not title:
raise ValueError("Missing title parameter")

applies_to_part = arguments.get("applies_to_part")
if not applies_to_part:
raise ValueError("Missing applies_to_part parameter")

# Optional fields
body = arguments.get("body", "")
owned_by = arguments.get("owned_by", [])

response = make_devrev_request(
"works.create",
{
"type": object_type,
"title": title,
"body": body,
"applies_to_part": applies_to_part,
"owned_by": owned_by
}
)
if response.status_code != 201:
error_text = response.text
return [
types.TextContent(
type="text",
text=f"Create object failed with status {response.status_code}: {error_text}"
)
]

return [
types.TextContent(
type="text",
text=f"Object created successfully: {response.json()}"
)
]
else:
raise ValueError(f"Unknown tool: {name}")

Expand Down