delete_relations
Remove specified relationships between entities stored in the MCP Memory Server's knowledge graph to maintain accurate and relevant data connections for improved reasoning and retrieval.
Instructions
Delete multiple relations from the knowledge graph
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| relations | Yes | An array of relations to delete |
Input Schema (JSON Schema)
{
"properties": {
"relations": {
"description": "An array of relations to delete",
"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:122-130 (handler)Core handler function in KnowledgeGraphManager that loads the graph, filters out the specified relations, and saves the updated graph to persist the deletions.async deleteRelations(relations: Relation[]): Promise<void> { const graph = await this.loadGraph(); graph.relations = graph.relations.filter(r => !relations.some(delRelation => r.from === delRelation.from && r.to === delRelation.to && r.relationType === delRelation.relationType )); await this.saveGraph(graph); }
- src/index.ts:315-337 (registration)Tool registration in the ListToolsRequestHandler, defining the name, description, and input schema for the delete_relations tool.{ name: "delete_relations", description: "Delete multiple relations from the knowledge graph", 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"], }, description: "An array of relations to delete" }, }, required: ["relations"], }, },
- src/index.ts:396-398 (handler)Dispatch logic in the CallToolRequestHandler that calls the KnowledgeGraphManager.deleteRelations method with the provided arguments and returns a success message.case "delete_relations": await knowledgeGraphManager.deleteRelations(args.relations as Relation[]); return { content: [{ type: "text", text: "Relations deleted successfully" }] };
- src/index.ts:30-34 (schema)TypeScript interface defining the structure of a Relation object used by the delete_relations tool.interface Relation { from: string; to: string; relationType: string; }