create_relations
Adds multiple new connections between entities in a knowledge graph to build relationships and structure data.
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:611-621 (handler)The main handler function in KnowledgeGraphManager that executes the create_relations tool logic: loads the graph, filters out duplicate relations, adds new ones, saves the graph, and returns the 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:955-972 (schema)Input schema definition for the create_relations tool, specifying the expected structure of the relations array.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:1225-1226 (registration)Registration and dispatch handler in the CallToolRequestSchema switch statement that invokes the createRelations method.case "create_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2) }] };
- index.ts:952-973 (registration)Tool registration in the ListToolsRequestSchema response, defining 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"], }, }, }, required: ["relations"], }, },
- index.ts:31-35 (schema)TypeScript interface defining the structure of a Relation object used by the tool.interface Relation { from: string; to: string; relationType: string; }