list_notes
Retrieve all stored notes with optional filtering by tag to organize and access your Markdown documentation efficiently.
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 core handler function for the 'list_notes' MCP tool. It scans the notes directory, parses each Markdown note for title, tags, and creation date, filters by optional tag parameter, and returns a formatted list of notes. Registered via @mcp.tool() decorator.@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)