Skip to main content
Glama
modelcontextprotocol

Knowledge Graph Memory Server

add_observations

Enhance entities in the Knowledge Graph Memory Server by appending new observations. Input entity names and associated observations to update and expand stored information efficiently.

Instructions

Add new observations to existing entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observationsYes

Implementation Reference

  • Core handler implementing the logic to add unique new observations to existing entities in the knowledge graph.
    async addObservations(observations: { entityName: string; contents: string[] }[]): Promise<{ entityName: string; addedObservations: string[] }[]> { const graph = await this.loadGraph(); const results = observations.map(o => { const entity = graph.entities.find(e => e.name === o.entityName); if (!entity) { throw new Error(`Entity with name ${o.entityName} not found`); } const newObservations = o.contents.filter(content => !entity.observations.includes(content)); entity.observations.push(...newObservations); return { entityName: o.entityName, addedObservations: newObservations }; }); await this.saveGraph(graph); return results; }
  • Registers the add_observations tool with the MCP server, providing title, description, input/output schemas, and a handler that delegates to KnowledgeGraphManager.addObservations.
    server.registerTool( "add_observations", { title: "Add Observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { observations: z.array(z.object({ entityName: z.string().describe("The name of the entity to add the observations to"), contents: z.array(z.string()).describe("An array of observation contents to add") })) }, outputSchema: { results: z.array(z.object({ entityName: z.string(), addedObservations: z.array(z.string()) })) } }, async ({ observations }) => { const result = await knowledgeGraphManager.addObservations(observations); return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], structuredContent: { results: result } }; } );
  • Tool metadata including title, description, and Zod-based input/output schemas for validation.
    { title: "Add Observations", description: "Add new observations to existing entities in the knowledge graph", inputSchema: { observations: z.array(z.object({ entityName: z.string().describe("The name of the entity to add the observations to"), contents: z.array(z.string()).describe("An array of observation contents to add") })) }, outputSchema: { results: z.array(z.object({ entityName: z.string(), addedObservations: z.array(z.string()) })) } },

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/modelcontextprotocol/knowledge-graph-memory-server'

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