create_relations
Adds multiple connections between entities in a knowledge graph using active voice relations to build persistent memory for chat applications.
Instructions
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes |
Implementation Reference
- index.ts:158-168 (handler)Core handler function for creating relations. Loads the knowledge graph, filters out duplicate relations, appends new ones, saves to persistent storage, and returns the newly created relations.async createRelations(relations: Relation[]): Promise<Relation[]> { const graph = await this.loadGraph(); const newRelations = relations.filter(r => !graph.relations.some(existingRelation => existingRelation.from === r.from && existingRelation.to === r.to && existingRelation.relationType === r.relationType )); graph.relations.push(...newRelations); await this.saveGraph(graph); return newRelations; }
- index.ts:41-45 (schema)Type definition for Relation used in the create_relations tool input.interface Relation { from: string; to: string; relationType: string; }
- index.ts:390-411 (registration)Tool registration in ListToolsRequestHandler, including name, description, and input schema for create_relations.{ 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"], }, },
- index.ts:555-556 (registration)Dispatch handler in CallToolRequestHandler switch statement that invokes the createRelations function.case "create_relations": return createResponse(JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2));