list_notes
Retrieve and display all stored notes with optional filtering by tags to organize and access your documented information quickly.
Instructions
Get a list of all notes
Args: tag: Optional tag filter
Returns: List of notes with titles and dates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No |
Implementation Reference
- notes_server.py:51-86 (handler)The handler function for the 'list_notes' tool. It lists all notes or filters by tag, parsing titles, tags, and creation dates from Markdown files in the notes directory. The @mcp.tool() decorator registers it as an MCP tool, with type hints and docstring providing the schema.@mcp.tool() def list_notes(tag: str = "") -> str: """ Get a list of all notes Args: tag: Optional tag filter Returns: List of notes with titles and dates """ ensure_notes_dir() notes = [] for filename in sorted(os.listdir(NOTES_DIR), reverse=True): if filename.endswith('.md'): filepath = os.path.join(NOTES_DIR, filename) with open(filepath, "r", encoding="utf-8") as f: content = f.read() title_match = re.search(r'^# (.+)$', content, re.MULTILINE) title = title_match.group(1) if title_match else filename if tag: tags_match = re.search(r'\*\*Tags:\*\* (.+)$', content, re.MULTILINE) if not tags_match or tag.lower() not in tags_match.group(1).lower(): continue date_match = re.search(r'\*\*Created:\*\* (.+)$', content, re.MULTILINE) date = date_match.group(1) if date_match else "Unknown" notes.append(f"- [{filename}] {title} (Created: {date})") if not notes: return "No notes found" + (f" with tag '{tag}'" if tag else "") return "\n".join(notes)