search_bugs
Query bugs from a provider with filters by title, status, owner, assignee, milestone, and creation or modification dates.
Instructions
Search for bugs matching criteria on the given provider.
Date arguments should be ISO 8601 format (e.g. '2025-01-01').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| provider_name | Yes | ||
| title | No | ||
| tags | No | ||
| status | No | ||
| importance | No | ||
| owner | No | ||
| assignee | No | ||
| milestone | No | ||
| created_since | No | ||
| created_before | No | ||
| modified_since | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/ubuntu_mcp/bugs/server.py:71-113 (handler)The `search_bugs` tool handler function, registered via @mcp.tool() decorator. It accepts provider_name and optional search criteria (title, tags, status, importance, owner, assignee, milestone, date range), builds a BugSearchRecord query, calls `svc.search_bugs()`, and returns results as a list of dicts via `_bug_record_to_dict`.
@mcp.tool() def search_bugs( # noqa: PLR0913 provider_name: str, title: str | None = None, tags: list[str] | None = None, status: str | None = None, importance: str | None = None, owner: str | None = None, assignee: str | None = None, milestone: str | None = None, created_since: str | None = None, created_before: str | None = None, modified_since: str | None = None, ) -> list[dict]: """Search for bugs matching criteria on the given provider. Date arguments should be ISO 8601 format (e.g. '2025-01-01'). """ svc = get_service() owner_record = UserRecord(username=owner) if owner else None assignee_record = UserRecord(username=assignee) if assignee else None query = BugSearchRecord( provider_name=provider_name, title=title, tags=tags or [], status=status, importance=importance, owner=owner_record, assignee=assignee_record, milestone=milestone, created_since=_parse_datetime(created_since), created_before=_parse_datetime(created_before), modified_since=_parse_datetime(modified_since), ) try: results = svc.search_bugs(query=query, provider_name=provider_name) except ValueError as exc: return [{"error": str(exc)}] return [_bug_record_to_dict(r) for r in results] - src/ubuntu_mcp/bugs/server.py:19-19 (registration)The `@mcp.tool()` decorator on line 19 (and used for all tool functions) registers the `search_bugs` function as an MCP tool. The mcp instance is `FastMCP('ubuntu-mcp-bugs')`.
@mcp.tool() - src/ubuntu_mcp/bugs/server.py:94-106 (schema)Construction of the `BugSearchRecord` query object (imported from `ubq.models`), which defines the input shape for the search. The function parameters (lines 73-84) also serve as the schema definition via type annotations.
query = BugSearchRecord( provider_name=provider_name, title=title, tags=tags or [], status=status, importance=importance, owner=owner_record, assignee=assignee_record, milestone=milestone, created_since=_parse_datetime(created_since), created_before=_parse_datetime(created_before), modified_since=_parse_datetime(modified_since), ) - `_bug_record_to_dict` helper that converts a bug record to a dict (used to format the search results).
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], } - `_parse_datetime` helper that parses ISO 8601 date strings into datetime objects for the date-range search filters.
def _parse_datetime(value: str | None) -> datetime | None: if value is None: return None return datetime.fromisoformat(value)