get_bug
Retrieve a bug by ID from a specified provider. Optionally fetch only metadata to skip comments and tasks.
Instructions
Fetch a bug by ID from the given provider.
Set metadata_only to True to skip fetching comments and tasks.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bug_id | Yes | ||
| provider_name | Yes | ||
| metadata_only | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/ubuntu_mcp/bugs/server.py:45-69 (handler)The get_bug tool handler function. It fetches a bug by ID from the given provider using the singleton QueryService, and converts the result to a dictionary via _bug_record_to_dict. Registered as an MCP tool via @mcp.tool() decorator.
@mcp.tool() def get_bug( bug_id: str, provider_name: str, metadata_only: bool = False, ) -> dict | None: """Fetch a bug by ID from the given provider. Set metadata_only to True to skip fetching comments and tasks. """ svc = get_service() try: record = svc.get_bug( bug_id=bug_id, provider_name=provider_name, metadata_only=metadata_only, ) except ValueError as exc: return {"error": str(exc)} if record is None: return None return _bug_record_to_dict(record) - Helper that converts a BugRecord into a plain dict for JSON serialization. Defines the output schema (shape) of the get_bug tool result.
def _bug_record_to_dict(record) -> dict: return { "provider_name": record.provider_name, "id": record.id, "title": record.title, "description": record.description, "tags": record.tags, "created_at": _fmt_dt(record.created_at), "updated_at": _fmt_dt(record.updated_at), "last_message_at": _fmt_dt(record.last_message_at), "owner": _user_to_dict(record.owner), "assignee": _user_to_dict(record.assignee), "bug_tasks": [_task_to_dict(t) for t in record.bug_tasks], "comments": [_comment_to_dict(c) for c in record.comments], } def _task_to_dict(task) -> dict: return { "title": task.title, "target": task.target, "importance": task.importance, "status": task.status, "milestone": task.milestone, "owner": _user_to_dict(task.owner), "assignee": _user_to_dict(task.assignee), } def _comment_to_dict(comment) -> dict: return { "author": _user_to_dict(comment.author), "content": comment.content, "created_at": _fmt_dt(comment.created_at), "edited_at": _fmt_dt(comment.edited_at), } def _user_to_dict(user) -> dict | None: if user is None: return None return { "username": user.username, "display_name": user.display_name, "profile_url": user.profile_url, } def _fmt_dt(dt: datetime | None) -> str | None: return dt.isoformat() if dt else None def _parse_datetime(value: str | None) -> datetime | None: if value is None: return None return datetime.fromisoformat(value) - src/ubuntu_mcp/bugs/server.py:45-46 (registration)The get_bug function is registered as an MCP tool via the @mcp.tool() decorator on the FastMCP instance 'mcp' (line 16).
@mcp.tool() def get_bug( - Helper used by _bug_record_to_dict to serialize UserRecord objects.
def _user_to_dict(user) -> dict | None: if user is None: return None return { "username": user.username, "display_name": user.display_name, "profile_url": user.profile_url, }