Skip to main content
Glama
YuNaga224
by YuNaga224

add_observations

Add observations to entities in a knowledge graph, enabling users to expand and organize AI memories stored as Markdown files for visualization in Obsidian's graph view.

Instructions

Add new observations to existing entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observationsYes

Implementation Reference

  • Core handler function that implements the add_observations tool logic: loads entity markdown, filters duplicates, appends new observations, reloads relations, and saves the updated file.
    async addObservations(observations: { entityName: string; contents: string[] }[]): Promise<{ entityName: string; addedObservations: string[] }[]> { const results: { entityName: string; addedObservations: string[] }[] = []; for (const obs of observations) { const entityPath = getEntityPath(obs.entityName); try { // Load current entity const entity = await this.loadEntity(entityPath); if (!entity) { throw new Error(`Entity ${obs.entityName} not found`); } // Filter out duplicate observations const newObservations = obs.contents.filter( content => !entity.observations.includes(content) ); if (newObservations.length > 0) { // Update entity entity.observations.push(...newObservations); // Get current relations for this entity const graph = await this.loadGraph(); const entityRelations = graph.relations.filter(r => r.from === entity.name); // Save updated entity await this.saveEntity(entity, entityRelations); results.push({ entityName: obs.entityName, addedObservations: newObservations }); } } catch (error) { throw new Error(`Failed to add observations to ${obs.entityName}: ${error}`); } } return results; }
  • Input schema definition and tool metadata (name, description) for the add_observations tool, used in MCP tool listing.
    { name: "add_observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { type: "object", properties: { observations: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity to add the observations to" }, contents: { type: "array", items: { type: "string" }, description: "An array of observation contents to add" }, }, required: ["entityName", "contents"], }, }, }, required: ["observations"], }, },
  • MCP server dispatch handler case for add_observations, invoking the storage manager's implementation and formatting response.
    case "add_observations": return { content: [{ type: "text", text: JSON.stringify(await storageManager.addObservations(args.observations as { entityName: string; contents: string[] }[]), null, 2) }] };
  • index.ts:26-201 (registration)
    Registration of all tools including add_observations via the ListToolsRequestHandler, exposing the tool to MCP clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ { name: "create_entities", description: "Create multiple new entities in the knowledge graph", inputSchema: { type: "object", properties: { entities: { type: "array", items: { type: "object", properties: { name: { type: "string", description: "The name of the entity" }, entityType: { type: "string", description: "The type of the entity" }, observations: { type: "array", items: { type: "string" }, description: "An array of observation contents associated with the entity" }, }, required: ["name", "entityType", "observations"], }, }, }, required: ["entities"], }, }, { name: "create_relations", description: "Create multiple new relations between entities in the knowledge graph. Relations should be in active voice", inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, }, }, required: ["relations"], }, }, { name: "add_observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { type: "object", properties: { observations: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity to add the observations to" }, contents: { type: "array", items: { type: "string" }, description: "An array of observation contents to add" }, }, required: ["entityName", "contents"], }, }, }, required: ["observations"], }, }, { name: "delete_entities", description: "Delete multiple entities and their associated relations from the knowledge graph", inputSchema: { type: "object", properties: { entityNames: { type: "array", items: { type: "string" }, description: "An array of entity names to delete" }, }, required: ["entityNames"], }, }, { name: "delete_observations", description: "Delete specific observations from entities in the knowledge graph", inputSchema: { type: "object", properties: { deletions: { type: "array", items: { type: "object", properties: { entityName: { type: "string", description: "The name of the entity containing the observations" }, observations: { type: "array", items: { type: "string" }, description: "An array of observations to delete" }, }, required: ["entityName", "observations"], }, }, }, required: ["deletions"], }, }, { name: "delete_relations", description: "Delete multiple relations from the knowledge graph", inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, description: "An array of relations to delete" }, }, required: ["relations"], }, }, { name: "read_graph", description: "Read the entire knowledge graph", inputSchema: { type: "object", properties: {}, }, }, { 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"], }, }, { name: "open_nodes", description: "Open specific nodes in the knowledge graph by their names", inputSchema: { type: "object", properties: { names: { type: "array", items: { type: "string" }, description: "An array of entity names to retrieve", }, }, required: ["names"], }, }, ], }; });

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/YuNaga224/obsidian-memory-mcp'

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