Skip to main content
Glama
bazylhorsey
by bazylhorsey

get_knowledge_graph

Retrieve the complete knowledge graph for an Obsidian vault to analyze connections and relationships between notes, enabling comprehensive understanding of your knowledge base structure.

Instructions

Get the complete knowledge graph for a vault

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultYesVault name

Implementation Reference

  • Tool handler switch case: fetches all notes from vault connector, updates KnowledgeGraphService with notes, builds the graph using buildGraph(), and returns JSON serialized graph.
    case 'get_knowledge_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 graph = this.knowledgeGraph.buildGraph();
        return {
          content: [{ type: 'text', text: JSON.stringify(graph, null, 2) }],
        };
      }
      throw new Error('Failed to build knowledge graph');
    }
  • Input schema definition for the tool, requiring 'vault' parameter.
    {
      name: 'get_knowledge_graph',
      description: 'Get the complete knowledge graph for a vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
        },
        required: ['vault'],
      },
    },
  • src/index.ts:166-176 (registration)
    Tool registration in the ListToolsRequestSchema handler, including name, description, and schema.
    {
      name: 'get_knowledge_graph',
      description: 'Get the complete knowledge graph for a vault',
      inputSchema: {
        type: 'object',
        properties: {
          vault: { type: 'string', description: 'Vault name' },
        },
        required: ['vault'],
      },
    },
  • Core implementation: builds KnowledgeGraph with note nodes, link edges, tag nodes/edges, and folder nodes/edges from stored notes.
    buildGraph(): KnowledgeGraph {
      const nodes: GraphNode[] = [];
      const edges: GraphEdge[] = [];
      const tagNodes = new Map<string, GraphNode>();
      const folderNodes = new Map<string, GraphNode>();
    
      // Create note nodes
      for (const note of this.notes.values()) {
        nodes.push({
          id: note.path,
          title: note.title,
          type: 'note',
          metadata: {
            tags: note.tags,
            wordCount: note.content.length,
            linkCount: note.links?.length || 0
          }
        });
    
        // Create edges for note links
        if (note.links) {
          for (const link of note.links) {
            edges.push({
              source: note.path,
              target: this.resolveNotePath(link.target),
              type: link.type,
              weight: 1
            });
          }
        }
    
        // Create tag nodes and edges
        if (note.tags) {
          for (const tag of note.tags) {
            if (!tagNodes.has(tag)) {
              const tagNode: GraphNode = {
                id: `tag:${tag}`,
                title: tag,
                type: 'tag'
              };
              tagNodes.set(tag, tagNode);
              nodes.push(tagNode);
            }
    
            edges.push({
              source: note.path,
              target: `tag:${tag}`,
              type: 'tagged-with',
              weight: 1
            });
          }
        }
    
        // Create folder nodes and edges
        const folder = this.getFolder(note.path);
        if (folder && folder !== '.') {
          if (!folderNodes.has(folder)) {
            const folderNode: GraphNode = {
              id: `folder:${folder}`,
              title: folder,
              type: 'folder'
            };
            folderNodes.set(folder, folderNode);
            nodes.push(folderNode);
          }
    
          edges.push({
            source: note.path,
            target: `folder:${folder}`,
            type: 'in-folder',
            weight: 1
          });
        }
      }
    
      return { nodes, edges };
    }
  • Updates internal notes map with new list of notes, called before building graph.
    updateNotes(notes: Note[]): void {
      this.notes.clear();
      for (const note of notes) {
        this.notes.set(note.path, note);
      }
    }
Behavior2/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 states 'Get the complete knowledge graph' but doesn't explain what 'complete' entails (e.g., size limits, format, or performance implications), leaving gaps in understanding the tool's 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 a single, efficient sentence that directly states the tool's purpose without any wasted words. It's front-loaded and appropriately sized for its simple function.

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 has one parameter with full schema coverage and no output schema, the description is minimally adequate. However, it lacks details on what a 'knowledge graph' entails (e.g., structure, content) and behavioral traits, making it incomplete for full contextual understanding.

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 'vault' parameter clearly documented. The description adds no additional meaning beyond the schema, such as clarifying 'vault' semantics or usage examples, so it meets the baseline for high schema coverage.

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 action ('Get') and resource ('complete knowledge graph for a vault'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'analyze_graph' or 'get_related_notes', which might have overlapping functionality, so it misses full distinction.

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?

No guidance is provided on when to use this tool versus alternatives like 'analyze_graph' or 'get_ote_metadata'. The description implies usage for retrieving knowledge graphs but offers no context on prerequisites, exclusions, or specific scenarios.

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