create_relations
Adds multiple new connections between entities in a knowledge graph to establish relationships using active voice descriptions.
Instructions
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"relations": "<relations>"
},
"name": "create_relations"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes |
Implementation Reference
- index.ts:93-107 (handler)The core handler function in KnowledgeGraphManager that implements the logic for creating new relations: loads the graph, filters out duplicates based on from/to/relationType, adds timestamps and versions, appends to graph, saves, and returns the new 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 )).map(r => ({ ...r, createdAt: new Date().toISOString(), version: r.version || 1 })); graph.relations.push(...newRelations); await this.saveGraph(graph); return newRelations; } - index.ts:313-330 (schema)The JSON schema defining the input structure for the 'create_relations' tool, specifying an array of relations each with 'from', 'to', and '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:310-331 (registration)Registration of the 'create_relations' tool in the list of tools returned by ListToolsRequestSchema handler.
{ 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:516-517 (registration)Dispatch case in the CallToolRequestSchema handler that invokes the createRelations method with parsed arguments and formats the response.
case "create_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2) }] }; - index.ts:39-45 (schema)TypeScript interface defining the structure of a Relation object used by the createRelations handler.
interface Relation { from: string; to: string; relationType: string; createdAt: string; version: number; }