Skip to main content
Glama

list_categories

Retrieve all document categories and their associated document counts to organize and navigate your knowledge base.

Instructions

List all document categories with their document counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'list_categories' tool definition and handler. It invokes 'orchestrator.list_categories()' and returns the categories and their document counts as a JSON string.
    def list_categories() -> str:
        """List all document categories with their document counts."""
        orchestrator = get_orchestrator()
        categories = orchestrator.list_categories()
        return json.dumps({"status": "success", "categories": categories, "total_documents": sum(categories.values())}, indent=2)
  • The 'KnowledgeOrchestrator.list_categories' method which iterates over indexed documents to compute document counts per category.
    def list_categories(self) -> Dict[str, int]:
        """List all categories with document counts"""
        categories = {}
        for doc_info in self._indexed_docs.values():
            cat = doc_info.get("category", "unknown")
            categories[cat] = categories.get(cat, 0) + 1
        return categories

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lyonzin/knowledge-rag'

If you have feedback or need assistance with the MCP directory API, please join our Discord server