Skip to main content
Glama

zk_find_orphaned_notes

Identify unlinked notes in your Zettelkasten system to ensure all information is connected and accessible for effective knowledge management.

Instructions

Find notes with no connections to other notes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler function that finds orphaned notes via the search service and formats the results as a string list with previews.
    def zk_find_orphaned_notes() -> str: """Find isolated notes that have no links to or from other notes. Orphaned notes may indicate fleeting ideas that need integration or cleanup. """ try: # Get orphaned notes orphans = self.search_service.find_orphaned_notes() if not orphans: return "No orphaned notes found." # Format results output = f"Found {len(orphans)} orphaned notes:\n\n" for i, note in enumerate(orphans, 1): output += f"{i}. {note.title} (ID: {note.id})\n" if note.tags: output += ( f" Tags: {', '.join(tag.name for tag in note.tags)}\n" ) # Add a snippet of content (first 100 chars) content_preview = note.content[:100].replace("\n", " ") if len(note.content) > 100: content_preview += "..." output += f" Preview: {content_preview}\n\n" return output except Exception as e: return self.format_error_response(e)
  • Registration of the zk_find_orphaned_notes MCP tool with metadata and hints.
    @self.mcp.tool( name="zk_find_orphaned_notes", description="Find isolated notes that have no links to or from other notes.", annotations={ "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, }, )
  • Helper method in SearchService that performs the database query to identify notes without any links (orphaned notes).
    def find_orphaned_notes(self) -> List[Note]: """Find notes with no incoming or outgoing links.""" orphans = [] with self.zettel_service.repository.session_factory() as session: # Subquery for notes with links notes_with_links = ( select(DBNote.id) .outerjoin(DBLink, or_( DBNote.id == DBLink.source_id, DBNote.id == DBLink.target_id )) .where(or_( DBLink.source_id != None, DBLink.target_id != None )) .subquery() ) # Query for notes without links query = ( select(DBNote) .options( joinedload(DBNote.tags), joinedload(DBNote.outgoing_links), joinedload(DBNote.incoming_links) ) .where(DBNote.id.not_in(select(notes_with_links))) ) result = session.execute(query) orphaned_db_notes = result.unique().scalars().all() # Convert DB notes to model Notes for db_note in orphaned_db_notes: note = self.zettel_service.get_note(db_note.id) if note: orphans.append(note) return orphans

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Liam-Deacon/zettelkasten-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server