Skip to main content
Glama
bazylhorsey
by bazylhorsey

analyze_graph

Analyze the structure of your knowledge graph to understand connections and relationships within your Obsidian vault.

Instructions

Analyze the knowledge graph structure

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultYesVault name

Implementation Reference

  • src/index.ts:190-200 (registration)
    Registration of the 'analyze_graph' tool in the ListToolsRequestHandler, defining its name, description, and input schema requiring a 'vault' parameter.
    {
      name: 'analyze_graph',
      description: 'Analyze the knowledge graph structure',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
        },
        required: ['vault'],
      },
    },
  • Dispatch handler for 'analyze_graph' tool: retrieves notes from the specified vault, updates the KnowledgeGraphService, calls analyzeGraph(), and returns the JSON-serialized analysis.
    case 'analyze_graph': {
      const connector = this.connectors.get(args?.vault as string);
      if (!connector) {
        throw new Error(`Vault "${args?.vault}" not found`);
      }
      const notesResult = await connector.getAllNotes();
      if (notesResult.success && notesResult.data) {
        this.knowledgeGraph.updateNotes(notesResult.data);
        const analysis = this.knowledgeGraph.analyzeGraph();
        return {
          content: [{ type: 'text', text: JSON.stringify(analysis, null, 2) }],
        };
      }
      throw new Error('Failed to analyze graph');
    }
  • Core implementation of graph analysis in KnowledgeGraphService: calculates connection counts, identifies orphans, finds most connected nodes, builds the graph, and returns GraphAnalysis.
    /**
     * Analyze the knowledge graph
     */
    analyzeGraph(): GraphAnalysis {
      const connectionCounts = new Map<string, number>();
      const orphans: string[] = [];
    
      for (const note of this.notes.values()) {
        const linkCount = (note.links?.length || 0) + (note.backlinks?.length || 0);
        connectionCounts.set(note.path, linkCount);
    
        if (linkCount === 0) {
          orphans.push(note.path);
        }
      }
    
      // Sort by connection count
      const mostConnected = Array.from(connectionCounts.entries())
        .sort((a, b) => b[1] - a[1])
        .slice(0, 10)
        .map(([id, connections]) => ({ id, connections }));
    
      const graph = this.buildGraph();
    
      return {
        totalNodes: graph.nodes.filter(n => n.type === 'note').length,
        totalEdges: graph.edges.length,
        mostConnectedNodes: mostConnected,
        orphanNotes: orphans
      };
    }
  • TypeScript interface defining the output structure of the analyzeGraph method.
    export interface GraphAnalysis {
      totalNodes: number;
      totalEdges: number;
      mostConnectedNodes: Array<{ id: string; connections: number }>;
      orphanNotes: string[];
      clusters?: Array<string[]>;
    }
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. 'Analyze' suggests a read-only operation, but the description doesn't specify if it's safe, what the output looks like (e.g., statistics, errors), or any side effects like performance impact. For a tool with no annotation coverage, this is a significant gap 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.

Conciseness5/5

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

The description is a single, efficient sentence with no wasted words. It's front-loaded and directly states the tool's function, making it highly concise and well-structured for quick understanding.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what 'analyze' means in practice, what results to expect, or how it differs from similar tools. For a tool with no structured behavioral or output information, this leaves critical gaps for an agent.

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

Parameters3/5

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

The input schema has 100% description coverage, with the single parameter 'vault' documented as 'Vault name'. The description doesn't add any meaning beyond this, such as explaining what a vault represents or how it affects the analysis. Given the high schema coverage, a baseline score of 3 is appropriate.

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

Purpose3/5

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

The description 'Analyze the knowledge graph structure' states a general purpose but lacks specificity. It mentions the resource ('knowledge graph structure') and a verb ('analyze'), but doesn't clarify what analysis entails (e.g., metrics, visualization, validation) or how it differs from sibling tools like 'get_knowledge_graph' or 'get_vault_stats'. This makes the purpose somewhat vague.

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. With siblings like 'get_knowledge_graph' and 'get_vault_stats' that might overlap in functionality, there's no indication of context, prerequisites, or exclusions. This leaves the agent without clear usage direction.

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

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/bazylhorsey/obsidian-mcp-server'

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