create_relations
Define and link entities within a knowledge graph by creating multiple relationships, specifying the origin, destination, and type of each connection.
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, deduplicates relations, adds new ones, saves changes, and returns 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:31-35 (schema)TypeScript interface defining the structure of a Relation used by create_relations.interface Relation { from: string; to: string; relationType: string; }
- index.ts:955-972 (schema)JSON schema defining the input parameters for the create_relations tool: array of relations with from, to, relationType.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:953-973 (registration)Tool registration in the MCP server's listTools response, defining name, description, and 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:1225-1226 (handler)Dispatcher case in the MCP CallToolRequest handler that invokes the createRelations method and formats the response.case "create_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2) }] };