create_relations
Establish connections between entities in a knowledge graph by defining relationships with active voice descriptions, enabling structured data organization and relationship mapping.
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 | ||
| memoryFilePath | Yes | The path to the memory file |
Implementation Reference
- index.ts:135-153 (handler)The core handler function in KnowledgeGraphManager that executes the create_relations tool logic: loads the graph, filters out existing relations to avoid duplicates, appends new relations, saves the graph to the memory file, and returns the newly added relations.async createRelations( relations: Relation[], filepath: string ): Promise<Relation[]> { await this.setMemoryFilePath(filepath); 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:362-398 (registration)Registers the create_relations tool in the list of available tools, including name, description, and input schema.{ 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"], }, }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["relations", "memoryFilePath"], },
- index.ts:618-633 (handler)The dispatch handler in the CallToolRequestSchema that invokes the KnowledgeGraphManager.createRelations method with parsed arguments and formats the response as MCP content.case "create_relations": return { content: [ { type: "text", text: JSON.stringify( await knowledgeGraphManager.createRelations( args.relations as Relation[], args.memoryFilePath as string ), null, 2 ), }, ], };
- index.ts:366-397 (schema)Input schema definition for validating the arguments to the create_relations tool: expects an array of relations (from, to, relationType) and memoryFilePath.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"], }, }, memoryFilePath: { type: "string", description: "The path to the memory file", }, }, required: ["relations", "memoryFilePath"],