obsidian_notes_search
Search your Obsidian vault for notes matching a query and retrieve their absolute file paths for further access.
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. It searches Obsidian notes using a local HTTP endpoint at localhost:51361, sorts results by score, and formats them with title, excerpt, score, and absolute filepath. Registered via @mcp.tool() decorator.@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 []
- src/mcp_server_obsidian_omnisearch/server.py:10-10 (registration)Registers the obsidian_notes_search tool using FastMCP's @mcp.tool() decorator.@mcp.tool()
- Input schema defined by function signature (query: str) and docstring description.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. """