Skip to main content
Glama

zk_find_similar_notes

Identifies and retrieves notes similar to a specified reference note based on similarity threshold and result limit, aiding in Zettelkasten knowledge management.

Instructions

Find notes similar to a given note. Args: note_id: ID of the reference note threshold: Similarity threshold (0.0-1.0) limit: Maximum number of results to return

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
note_idYes
thresholdNo

Implementation Reference

  • MCP tool handler implementation for zk_find_similar_notes, including decorator registration, input parameters (note_id, threshold, limit), logic to fetch similar notes from zettel_service, apply limit, and format output string.
        name="zk_find_similar_notes",
        description="Discover notes with similar content using semantic similarity analysis.",
        annotations={
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
        },
    )
    def zk_find_similar_notes(
        note_id: str, threshold: float = 0.3, limit: int = 5
    ) -> str:
        """Discover notes with similar content using semantic similarity analysis.
    
        Args:
            note_id: The unique ID of the reference note to compare against
            threshold: Minimum similarity score from 0.0 (unrelated) to 1.0 (identical) (default: 0.3)
            limit: Maximum number of similar notes to return (default: 5)
        """
        try:
            # Get similar notes
            similar_notes = self.zettel_service.find_similar_notes(
                str(note_id), threshold
            )
            # Limit results
            similar_notes = similar_notes[:limit]
            if not similar_notes:
                return f"No similar notes found for {note_id} with threshold {threshold}."
    
            # Format results
            output = f"Found {len(similar_notes)} similar notes for {note_id}:\n\n"
            for i, (note, similarity) in enumerate(similar_notes, 1):
                output += f"{i}. {note.title} (ID: {note.id})\n"
                output += f"   Similarity: {similarity:.2f}\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)
  • Core helper method implementing similarity calculation based on tag overlap (40%), shared outgoing links (20%), incoming links to the reference note (20%), and direct outgoing links (20%). Compares against all notes, filters by threshold, sorts by score.
    def find_similar_notes(self, note_id: str, threshold: float = 0.5) -> List[Tuple[Note, float]]:
        """Find notes similar to the given note based on shared tags and links."""
        note = self.repository.get(note_id)
        if not note:
            raise ValueError(f"Note with ID {note_id} not found")
        
        # Get all notes
        all_notes = self.repository.get_all()
        results = []
        
        # Set of this note's tags and links
        note_tags = {tag.name for tag in note.tags}
        note_links = {link.target_id for link in note.links}
        
        # Add notes linked to this note
        incoming_notes = self.repository.find_linked_notes(note_id, "incoming")
        note_incoming = {n.id for n in incoming_notes}
        
        # For each note, calculate similarity
        for other_note in all_notes:
            if other_note.id == note_id:
                continue
            
            # Calculate tag overlap
            other_tags = {tag.name for tag in other_note.tags}
            tag_overlap = len(note_tags.intersection(other_tags))
            
            # Calculate link overlap (outgoing)
            other_links = {link.target_id for link in other_note.links}
            link_overlap = len(note_links.intersection(other_links))
            
            # Check if other note links to this note
            incoming_overlap = 1 if other_note.id in note_incoming else 0
            
            # Check if this note links to other note
            outgoing_overlap = 1 if other_note.id in note_links else 0
            
            # Calculate similarity score
            # Weight: 40% tags, 20% outgoing links, 20% incoming links, 20% direct connections
            total_possible = (
                max(len(note_tags), len(other_tags)) * 0.4 +
                max(len(note_links), len(other_links)) * 0.2 +
                1 * 0.2 +  # Possible incoming link
                1 * 0.2    # Possible outgoing link
            )
            
            # Avoid division by zero
            if total_possible == 0:
                similarity = 0.0
            else:
                similarity = (
                    (tag_overlap * 0.4) +
                    (link_overlap * 0.2) +
                    (incoming_overlap * 0.2) +
                    (outgoing_overlap * 0.2)
                ) / total_possible
            
            if similarity >= threshold:
                results.append((other_note, similarity))
        
        # Sort by similarity (descending)
        results.sort(key=lambda x: x[1], reverse=True)
        return results
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool finds similar notes but doesn't explain what 'similar' means (e.g., content-based, tags, metadata), how similarity is computed, or any behavioral traits like performance considerations, rate limits, or error handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and well-structured: a clear purpose statement followed by bullet-point parameter explanations. Every sentence earns its place, with no wasted words, and it's front-loaded with the core functionality. The formatting with 'Args:' enhances readability without verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and parameters well but lacks details on behavior, output format, and usage context. Without annotations or output schema, more information on what the tool returns and how it operates would improve completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful semantics beyond the input schema, which has 0% schema description coverage. It explains that 'note_id' is the 'ID of the reference note', 'threshold' is the 'Similarity threshold (0.0-1.0)', and 'limit' is the 'Maximum number of results to return'. This clarifies the purpose and constraints of each parameter, compensating well for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Find notes similar to a given note.' This specifies the verb ('find') and resource ('notes'), but doesn't explicitly differentiate it from sibling tools like 'zk_search_notes' or 'zk_get_linked_notes', which might also retrieve notes based on different criteria. It's clear but lacks sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'zk_search_notes' (for keyword-based searches) or 'zk_get_linked_notes' (for explicitly linked notes), leaving the agent to infer usage context. There's no explicit when/when-not or alternative recommendations.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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