Skip to main content
Glama
cwente25

Knowledge Base MCP Server

by cwente25

list_notes

Retrieve notes from your knowledge base, with optional filtering by category or tag to organize information.

Instructions

List all notes, optionally filtered by category path or tag

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
category_pathNoOptional category path filter (e.g., 'work/clients')
tagNoOptional tag filter
recursiveNoIf true, list notes in subcategories too (default: true)

Implementation Reference

  • MCP tool handler function for list_notes. Processes input arguments, retrieves notes from storage, groups them by category, and returns a formatted text list.
    async def handle_list_notes(arguments: dict) -> list[TextContent]:
        """Handle list_notes tool call."""
        category_path = arguments.get("category_path")
        tag = arguments.get("tag")
        recursive = arguments.get("recursive", True)
    
        # Get notes
        notes = storage.list_notes(
            category_path=category_path,
            tag=tag,
            recursive=recursive
        )
    
        if not notes:
            return [TextContent(type="text", text="No notes found.")]
    
        # Group by category
        by_category = {}
        for note in notes:
            cat = note.category or 'root'
            if cat not in by_category:
                by_category[cat] = []
            by_category[cat].append(note)
    
        # Format output
        output_lines = []
    
        if category_path:
            recursive_str = " (including subcategories)" if recursive else " (non-recursive)"
            output_lines.append(f"Notes in {category_path}/{recursive_str} ({len(notes)} total):\n")
        else:
            output_lines.append(f"All notes ({len(notes)} total):\n")
    
        for cat in sorted(by_category.keys()):
            cat_notes = by_category[cat]
            output_lines.append(f"\n{cat}/ ({len(cat_notes)} notes):")
    
            for note in sorted(cat_notes, key=lambda n: n.title):
                tags_str = ', '.join(note.frontmatter.tags) if note.frontmatter.tags else 'no tags'
                output_lines.append(f"  - {note.title} [{tags_str}]")
    
        return [TextContent(type="text", text="\n".join(output_lines))]
  • Registration of the list_notes tool in the MCP server's list_tools() method, defining its name, description, and input schema.
        name="list_notes",
        description="List all notes, optionally filtered by category path or tag",
        inputSchema={
            "type": "object",
            "properties": {
                "category_path": {
                    "type": "string",
                    "description": "Optional category path filter (e.g., 'work/clients')",
                },
                "tag": {
                    "type": "string",
                    "description": "Optional tag filter",
                },
                "recursive": {
                    "type": "boolean",
                    "description": "If true, list notes in subcategories too (default: true)",
                    "default": True,
                },
            },
        },
    ),
  • Input schema/JSON Schema for the list_notes tool defining parameters: category_path, tag, recursive.
    inputSchema={
        "type": "object",
        "properties": {
            "category_path": {
                "type": "string",
                "description": "Optional category path filter (e.g., 'work/clients')",
            },
            "tag": {
                "type": "string",
                "description": "Optional tag filter",
            },
            "recursive": {
                "type": "boolean",
                "description": "If true, list notes in subcategories too (default: true)",
                "default": True,
            },
        },
    },
  • Helper method in KnowledgeBaseStorage that implements the core listing logic: scans directories for .md files recursively or not, parses each into Note objects, filters by tag, skips invalid files.
    def list_notes(
        self,
        category_path: Optional[str] = None,
        tag: Optional[str] = None,
        recursive: bool = True
    ) -> list[Note]:
        """
        List all notes, optionally filtered by category path or tag.
    
        Args:
            category_path: Optional category path filter (e.g., "work/clients")
            tag: Optional tag filter
            recursive: If True, include notes from subcategories (default: True)
    
        Returns:
            List of Note objects
        """
        notes = []
    
        # Determine which path to search
        if category_path:
            normalized = normalize_path(category_path)
            search_path = self._get_category_path(normalized)
            if not search_path.exists():
                return []
        else:
            search_path = self.base_path
    
        # Find all markdown files
        if recursive:
            pattern = "**/*.md"
        else:
            pattern = "*.md"
    
        for file_path in search_path.glob(pattern):
            # Skip backup and temp files
            if file_path.suffix in ('.backup', '.tmp', '.deleted'):
                continue
    
            try:
                note = self._parse_note_file(file_path)
    
                # Apply tag filter if specified
                if tag and tag.lower() not in [t.lower() for t in note.frontmatter.tags]:
                    continue
    
                notes.append(note)
    
            except StorageError:
                # Skip files that can't be parsed
                continue
    
        return notes
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions filtering and recursive behavior, but lacks details on permissions, rate limits, pagination, return format, or whether it's read-only. For a list operation with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves beyond basic functionality.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('List all notes') and includes key optional features. There is zero waste, and every word earns its place by conveying essential information without redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and filtering options, but lacks details on behavioral aspects like permissions, output format, or error handling. Without annotations or output schema, more context would be helpful for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents all three parameters thoroughly. The description adds minimal value by mentioning 'optionally filtered by category path or tag,' which aligns with schema details but doesn't provide additional semantics beyond what's in the schema. With high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('notes') with optional filtering capabilities. It distinguishes from 'get_note' (singular retrieval) and 'search_notes' (likely broader search), but doesn't explicitly differentiate from 'list_categories' which handles different resources. The purpose is specific but sibling differentiation could be more explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through 'optionally filtered by category path or tag,' suggesting when to use filtering parameters. However, it doesn't provide explicit guidance on when to choose this tool versus alternatives like 'search_notes' or 'list_categories,' nor does it mention prerequisites or exclusions. Usage is implied rather than clearly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/cwente25/KnowledgeBaseMCP'

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