get_category
Retrieve category details by ID from Document360, including name, description, articles, and metadata.
Instructions
Get category by ID from Document360
Args: category_id: Document360 category ID (UUID string) ctx: MCP context for logging and error handling
Returns: Category information including name, description, articles, and metadata
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category_id | Yes | Document360 category ID (UUID string) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:89-103 (registration)The `get_category` tool is registered as an MCP tool using the @mcp.tool decorator on the server. It accepts a category_id (UUID string via Pydantic Field) and ctx, and delegates to tools.get_category().
@mcp.tool async def get_category( category_id: Annotated[str, Field(description="Document360 category ID (UUID string)")], ctx: Context ) -> dict: """Get category by ID from Document360 Args: category_id: Document360 category ID (UUID string) ctx: MCP context for logging and error handling Returns: Category information including name, description, articles, and metadata """ return await tools.get_category(category_id, ctx) - inc/tools.py:92-119 (handler)The `get_category` handler function in `inc/tools.py` is the core logic. It logs the request via ctx.info, calls `client.get_category(category_id)` on the Document360 API client, and handles Document360APIError and generic exceptions with appropriate logging and error propagation.
async def get_category(category_id: str, ctx: Context) -> Dict[str, Any]: """Get category by ID from Document360 Args: category_id: Document360 category ID (UUID string) ctx: MCP context for logging and error handling Returns: Category data from Document360 API """ try: await ctx.info(f"Fetching category with ID: {category_id}") result = await client.get_category(category_id) await ctx.info("Successfully retrieved category") return result except Document360APIError as e: await ctx.error(f"Document360 API error: {e.message}") if e.status_code == 404: await ctx.warning(f"Category {category_id} not found") elif e.status_code == 401: await ctx.error("Invalid API key - check configuration") raise e except Exception as e: await ctx.error(f"Unexpected error fetching category: {str(e)}") raise e - inc/document360_client.py:54-56 (helper)The `get_category` method on the Document360Client class makes the actual HTTP GET request to `/v2/categories/{category_id}` via the internal `_request` method.
async def get_category(self, category_id: str) -> Dict[str, Any]: """Get category by ID""" return await self._request("GET", f"/categories/{category_id}")