Skip to main content
Glama

zk_find_central_notes

Identify key notes in your Zettelkasten system by ranking them based on total incoming and outgoing links, highlighting central nodes in the knowledge network.

Instructions

Find notes with the most connections (incoming + outgoing links). Notes are ranked by their total number of connections, determining their centrality in the knowledge network. Due to database constraints, only one link of each type is counted between any pair of notes.

        Args:
            limit: Maximum number of results to return (default: 10)
        

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo

Implementation Reference

  • The MCP tool handler function 'zk_find_central_notes' that retrieves central notes from the search service and formats the output as a ranked list with previews.
    def zk_find_central_notes(limit: int = 10) -> str:
        """Identify the most connected notes that serve as knowledge hubs.
    
        Notes are ranked by their total number of connections (incoming + outgoing links),
        determining their centrality in the knowledge network. These central notes often
        represent key concepts or structure notes.
    
        Args:
            limit: Maximum number of central notes to return (default: 10)
        """
        try:
            # Get central notes
            central_notes = self.search_service.find_central_notes(limit)
            if not central_notes:
                return "No notes found with connections."
    
            # Format results
            output = "Central notes in the Zettelkasten (most connected):\n\n"
            for i, (note, connection_count) in enumerate(central_notes, 1):
                output += f"{i}. {note.title} (ID: {note.id})\n"
                output += f"   Connections: {connection_count}\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)
  • The @mcp.tool decorator that registers the 'zk_find_central_notes' tool with its metadata and annotations.
    @self.mcp.tool(
        name="zk_find_central_notes",
        description="Identify the most connected notes that serve as knowledge hubs.",
        annotations={
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
        },
    )
  • The SearchService.find_central_notes method containing the core database query logic to compute note centrality based on link counts and return the top connected notes.
    def find_central_notes(self, limit: int = 10) -> List[Tuple[Note, int]]:
        """Find notes with the most connections (incoming + outgoing links)."""
        note_connections = []
        # Direct database query to count connections for all notes at once
        with self.zettel_service.repository.session_factory() as session:
            # Use a CTE for better readability and performance
            query = text("""
            WITH outgoing AS (
                SELECT source_id as note_id, COUNT(*) as outgoing_count 
                FROM links 
                GROUP BY source_id
            ),
            incoming AS (
                SELECT target_id as note_id, COUNT(*) as incoming_count 
                FROM links 
                GROUP BY target_id
            )
            SELECT n.id,
                COALESCE(o.outgoing_count, 0) as outgoing,
                COALESCE(i.incoming_count, 0) as incoming,
                (COALESCE(o.outgoing_count, 0) + COALESCE(i.incoming_count, 0)) as total
            FROM notes n
            LEFT JOIN outgoing o ON n.id = o.note_id
            LEFT JOIN incoming i ON n.id = i.note_id
            WHERE (COALESCE(o.outgoing_count, 0) + COALESCE(i.incoming_count, 0)) > 0
            ORDER BY total DESC
            LIMIT :limit
            """)
            
            results = session.execute(query, {"limit": limit}).all()
            
            # Process results
            for note_id, outgoing_count, incoming_count, total_connections in results:
                total_connections = outgoing_count + incoming_count
                if total_connections > 0:  # Only include notes with connections
                    note = self.zettel_service.get_note(note_id)
                    if note:
                        note_connections.append((note, total_connections))
        
        # Sort by total connections (descending)
        note_connections.sort(key=lambda x: x[1], reverse=True)
        
        # Return top N notes
        return note_connections[:limit]
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it's a read operation (implied by 'Find'), discloses a constraint ('only one link of each type is counted between any pair of notes'), and explains the ranking logic. However, it does not cover aspects like performance, error handling, or output format, leaving some gaps in transparency.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded, starting with the core purpose. The explanation of ranking and constraints is necessary, and the parameter documentation is concise. However, the formatting with indentation and blank lines slightly reduces efficiency, but overall, most sentences earn their place without waste.

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 (ranking based on connections), no annotations, and no output schema, the description is partially complete. It covers the purpose, constraint, and parameter semantics well, but lacks details on the output format, error conditions, or performance considerations, which would enhance completeness for an agent's 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 input schema has 0% description coverage, so the description must compensate. It adds meaningful semantics for the single parameter 'limit' by explaining its purpose ('Maximum number of results to return') and default value. This fully compensates for the schema gap, though it does not provide additional details like range constraints or examples.

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

Purpose5/5

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

The description clearly states the specific action ('Find notes with the most connections'), identifies the resource ('notes'), and distinguishes from siblings by focusing on centrality ranking rather than other criteria like similarity, orphan status, or date. It explains the ranking methodology ('ranked by their total number of connections') and the scope ('incoming + outgoing links'), making the purpose explicit and differentiated.

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

Usage Guidelines3/5

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

The description implies usage for identifying central notes in a knowledge network, but does not explicitly state when to use this tool versus alternatives like 'zk_find_similar_notes' or 'zk_get_linked_notes'. It mentions 'database constraints' which provides some context, but lacks clear guidance on scenarios where this tool is preferred over siblings or any exclusions.

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