search_notes
Search notes by content, title, or tags, optionally within a specific folder.
Instructions
Search notes by content, title, or tags.
Args: query: Search query string folder: Optional folder to search within
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| folder | No |
Implementation Reference
- server.py:200-201 (registration)The MCP tool registration decorator marking 'search_notes' as a callable tool on the FastMCP server.
@mcp.tool() def search_notes(query: str, folder: Optional[str] = None) -> list: - server.py:201-221 (handler)The handler function for the 'search_notes' tool. It obtains the vault client, delegates the search to client.search_notes(), and formats results with path, title, and a 200-char excerpt.
def search_notes(query: str, folder: Optional[str] = None) -> list: """Search notes by content, title, or tags. Args: query: Search query string folder: Optional folder to search within """ try: client = get_vault_client() results = client.search_notes(query, folder) return [ { "path": note['path'], "title": note['title'], "excerpt": note['content'][:200] + "..." if len(note['content']) > 200 else note['content'] } for note in results ] except Exception as e: return [{"error": str(e)}] - obsidian_client.py:189-201 (helper)The underlying helper method on ObsidianVaultClient that performs the actual search, filtering notes by title, content, and tags (case-insensitive).
def search_notes(self, query: str, folder: Optional[str] = None) -> List[Dict[str, Any]]: """Search notes by content or title.""" notes = self.list_notes(folder) results = [] query_lower = query.lower() for note in notes: if (query_lower in note['title'].lower() or query_lower in note['content'].lower() or query_lower in ' '.join(str(tag) for tag in note.get('tags', [])).lower()): results.append(note) return results - server.py:201-201 (schema)Type signature indicating the tool accepts 'query: str' (required) and 'folder: Optional[str]' (optional), returning a list.
def search_notes(query: str, folder: Optional[str] = None) -> list: