search_notes
Find specific text within your Markdown notes using full-text search to locate relevant information quickly.
Instructions
Search for text within notes
Args: query: Search query
Returns: List of notes containing the query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- notes_server.py:108-143 (handler)The handler function for the 'search_notes' tool. It searches all .md note files for the given query (case-insensitive), extracts titles, finds matching lines with context, and returns formatted results. Registered via @mcp.tool() decorator.@mcp.tool() def search_notes(query: str) -> str: """ Search for text within notes Args: query: Search query Returns: List of notes containing the query """ ensure_notes_dir() results = [] query_lower = query.lower() for filename in os.listdir(NOTES_DIR): if filename.endswith('.md'): filepath = os.path.join(NOTES_DIR, filename) with open(filepath, "r", encoding="utf-8") as f: content = f.read() if query_lower in content.lower(): title_match = re.search(r'^# (.+)$', content, re.MULTILINE) title = title_match.group(1) if title_match else filename lines = content.split('\n') for i, line in enumerate(lines): if query_lower in line.lower(): context = line[:100] + "..." if len(line) > 100 else line results.append(f"- [{filename}] {title}\n → {context}") break if not results: return f"No matches found for '{query}'" return "\n\n".join(results)
- notes_server.py:108-108 (registration)The @mcp.tool() decorator registers the search_notes function as an MCP tool.@mcp.tool()
- notes_server.py:110-118 (schema)The docstring defines the input schema (query: str) and output description for the tool.""" Search for text within notes Args: query: Search query Returns: List of notes containing the query """