search_nodes
Search for entities, types, and observation content in a knowledge graph stored in Obsidian Memory MCP. Use a query to retrieve relevant nodes for enhanced knowledge graph navigation and analysis.
Instructions
Search for nodes in the knowledge graph based on a query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query to match against entity names, types, and observation content |
Implementation Reference
- Core implementation of the search_nodes tool logic: loads the full graph, filters entities matching the query in name, entityType, or observations (case-insensitive), then filters relations to only those connecting matching entities, returning a KnowledgeGraph subset.async searchNodes(query: string): Promise<KnowledgeGraph> { const graph = await this.loadGraph(); const queryLower = query.toLowerCase(); // Filter entities const filteredEntities = graph.entities.filter(e => e.name.toLowerCase().includes(queryLower) || e.entityType.toLowerCase().includes(queryLower) || e.observations.some(o => o.toLowerCase().includes(queryLower)) ); // Get filtered entity names const filteredEntityNames = new Set(filteredEntities.map(e => e.name)); // Filter relations to only include those between filtered entities const filteredRelations = graph.relations.filter(r => filteredEntityNames.has(r.from) && filteredEntityNames.has(r.to) ); return { entities: filteredEntities, relations: filteredRelations }; }
- index.ts:228-229 (handler)MCP tool dispatch handler for search_nodes: extracts query from args, calls storageManager.searchNodes, stringifies the KnowledgeGraph result as JSON, and returns it in the expected MCP content format.case "search_nodes": return { content: [{ type: "text", text: JSON.stringify(await storageManager.searchNodes(args.query as string), null, 2) }] };
- index.ts:173-183 (registration)Tool registration in ListToolsRequestSchema handler: defines name 'search_nodes', description, and inputSchema requiring a 'query' string.{ name: "search_nodes", description: "Search for nodes in the knowledge graph based on a query", inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query to match against entity names, types, and observation content" }, }, required: ["query"], }, },
- index.ts:176-182 (schema)Input schema for search_nodes tool: object with required 'query' string property.inputSchema: { type: "object", properties: { query: { type: "string", description: "The search query to match against entity names, types, and observation content" }, }, required: ["query"], },