get_categories
Retrieve a complete mapping of forum categories to organize topics by subject area, enabling filtering and navigation within the USCardForum community.
Instructions
Get a mapping of all forum categories.
Returns a CategoryMap object with category_id to category name mapping.
Categories organize topics by subject area.
Common USCardForum categories include sections for:
- Credit card applications and approvals
- Bank account bonuses
- Travel and redemptions
- Data points and experiences
Use category IDs to:
- Filter search results by category
- Understand which section a topic belongs to
- Navigate to specific areas of interest
The mapping includes both main categories and subcategories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The MCP tool handler function for 'get_categories'. Decorated with @mcp.tool(), it retrieves the category mapping using get_client().get_category_map() and returns a CategoryMap.@mcp.tool() def get_categories() -> CategoryMap: """ Get a mapping of all forum categories. Returns a CategoryMap object with category_id to category name mapping. Categories organize topics by subject area. Common USCardForum categories include sections for: - Credit card applications and approvals - Bank account bonuses - Travel and redemptions - Data points and experiences Use category IDs to: - Filter search results by category - Understand which section a topic belongs to - Navigate to specific areas of interest The mapping includes both main categories and subcategories. """ return get_client().get_category_map()
- Pydantic BaseModel defining the CategoryMap return type for the get_categories tool, providing a dictionary mapping category IDs to names with utility methods.class CategoryMap(BaseModel): """Mapping of category IDs to names.""" categories: dict[int, str] = Field( default_factory=dict, description="ID to name mapping" ) def get_name(self, category_id: int) -> str | None: """Get category name by ID.""" return self.categories.get(category_id) def __getitem__(self, category_id: int) -> str: """Get category name by ID.""" return self.categories[category_id] def __contains__(self, category_id: int) -> bool: """Check if category ID exists.""" return category_id in self.categories def items(self) -> list[tuple[int, str]]: """Iterate over category mappings.""" return list(self.categories.items())
- src/uscardforum/server_tools/__init__.py:41-41 (registration)Import statement registering the get_categories tool in the server_tools package __init__, making it available for import in the MCP server.from .categories import get_categories
- src/uscardforum/server.py:61-61 (registration)Explicit inclusion of get_categories in the __all__ export list of the main server entrypoint, ensuring it's registered and exposed as an MCP tool."get_categories",