create_relations
Generate and establish multiple new relationships between entities in a knowledge graph using active voice, enabling structured data connections for enhanced information storage and retrieval in the MCP Memory Server.
Instructions
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes |
Input Schema (JSON Schema)
{
"properties": {
"relations": {
"items": {
"properties": {
"from": {
"description": "The name of the entity where the relation starts",
"type": "string"
},
"relationType": {
"description": "The type of the relation",
"type": "string"
},
"to": {
"description": "The name of the entity where the relation ends",
"type": "string"
}
},
"required": [
"from",
"to",
"relationType"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"relations"
],
"type": "object"
}
Implementation Reference
- src/index.ts:77-87 (handler)Core implementation of create_relations tool: loads the knowledge graph from file, filters out duplicate relations, appends new relations, saves back to file, 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; }
- src/index.ts:228-249 (registration)Registers the 'create_relations' tool with the MCP server by including it in the tools list returned by ListToolsRequestHandler, specifying 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"], }, },
- src/index.ts:386-387 (handler)Dispatches tool calls to the createRelations handler in the CallToolRequestHandler switch statement.case "create_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2) }] };
- src/index.ts:30-34 (schema)TypeScript interface defining the structure of a Relation object used by the create_relations tool.interface Relation { from: string; to: string; relationType: string; }