Skip to main content
Glama

Knowledge Graph Memory Server

update_relations

Modifies existing relationships within the knowledge graph by updating 'from', 'to', and 'relationType' attributes for multiple connections, ensuring accurate data representation in the Knowledge Graph Memory Server.

Instructions

Update multiple existing relations in the knowledge graph

Input Schema

NameRequiredDescriptionDefault
relationsYes

Input Schema (JSON Schema)

{ "properties": { "relations": { "items": { "properties": { "from": { "description": "The name of the entity where the relation starts", "type": "string" }, "relationType": { "description": "The type of the relation", "type": "string" }, "to": { "description": "The name of the entity where the relation ends", "type": "string" } }, "required": [ "from", "to", "relationType" ], "type": "object" }, "type": "array" } }, "required": [ "relations" ], "type": "object" }

Implementation Reference

  • Core handler function in KnowledgeGraphManager that updates existing relations by matching on from/to/relationType, merging updates, incrementing version, saving the graph, and returning updated relations.
    async updateRelations(relations: Relation[]): Promise<Relation[]> { const graph = await this.loadGraph(); const updatedRelations = relations.map(updateRelation => { const existingRelation = graph.relations.find(r => r.from === updateRelation.from && r.to === updateRelation.to && r.relationType === updateRelation.relationType ); if (!existingRelation) { throw new Error(`Relation not found`); } return { ...existingRelation, ...updateRelation, version: existingRelation.version + 1, createdAt: new Date().toISOString() }; }); // Update relations in the graph updatedRelations.forEach(updatedRelation => { const index = graph.relations.findIndex(r => r.from === updatedRelation.from && r.to === updatedRelation.to && r.relationType === updatedRelation.relationType ); if (index !== -1) { graph.relations[index] = updatedRelation; } }); await this.saveGraph(graph); return updatedRelations; }
  • index.ts:480-501 (registration)
    Tool registration in the listTools response, including name, description, and input schema.
    { name: "update_relations", description: "Update multiple existing relations in 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"], }, }, }, required: ["relations"], }, },
  • JSON Schema for the input parameters of the update_relations tool.
    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"], },
  • Dispatcher case in the CallToolRequestHandler that calls the updateRelations method with parsed arguments and formats the response.
    case "update_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.updateRelations(args.relations as Relation[]), null, 2) }] };
  • TypeScript interface defining the structure of a Relation object used by the tool.
    interface Relation { from: string; to: string; relationType: string; createdAt: string; version: number; }

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/itseasy21/mcp-knowledge-graph'

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