obsidian_notes_search
Search Obsidian notes using a query and retrieve absolute paths to matching documents. Integrate with tools like read_note to access and analyze note contents programmatically.
Instructions
Search Obsidian(옵시디언) notes and return absolute paths to the matching notes. The returned paths can be used with the read_note tool to view the note contents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- The handler function for the 'obsidian_notes_search' tool, decorated with @mcp.tool() for registration. Searches Obsidian notes via a local search API, sorts results by score, and returns formatted XML-like snippets with title, excerpt, score, and absolute filepath using the vault path.@mcp.tool() def obsidian_notes_search(query: str): """Search Obsidian(옵시디언) notes and return absolute paths to the matching notes. The returned paths can be used with the read_note tool to view the note contents. """ try: search_url: str = "http://localhost:51361/search?q={query}" response = requests.get(search_url.format(query=quote(query))) response.raise_for_status() # Raise an exception for bad status codes json_response = response.json() sorted_results = sorted( json_response, key=lambda x: x["score"], reverse=True ) return [ f"<title>{item['basename']}</title>\n" f"<excerpt>{item['excerpt']}</excerpt>\n" f"<score>{item['score']}</score>\n" f"<filepath>{os.path.join(obsidian_vault_path, item['path'].lstrip('/'))}</filepath>" for item in sorted_results ] except Exception: return []