Skip to main content
Glama

delete_entities

Remove multiple entities and their associated relations from the Memento MCP knowledge graph memory, ensuring clean and efficient data management.

Instructions

Delete multiple entities and their associated relations from your Memento MCP knowledge graph memory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entityNamesYesAn array of entity names to delete

Implementation Reference

  • The primary handler function that executes the delete_entities MCP tool. It extracts entityNames from args and calls knowledgeGraphManager.deleteEntities, returning a success message.
    export async function handleDeleteEntities( args: Record<string, unknown>, // eslint-disable-next-line @typescript-eslint/no-explicit-any knowledgeGraphManager: any ): Promise<{ content: Array<{ type: string; text: string }> }> { await knowledgeGraphManager.deleteEntities(args.entityNames); return { content: [ { type: 'text', text: 'Entities deleted successfully', }, ], }; }
  • Defines the schema and metadata for the delete_entities tool, including input validation for entityNames array.
    name: 'delete_entities', description: 'Delete multiple entities and their associated relations from your Memento MCP knowledge graph memory', inputSchema: { type: 'object', properties: { entityNames: { type: 'array', items: { type: 'string' }, description: 'An array of entity names to delete', }, }, required: ['entityNames'], }, },
  • Registers the dispatching of delete_entities tool calls to the specific handleDeleteEntities function.
    case 'delete_entities': return await toolHandlers.handleDeleteEntities(args, knowledgeGraphManager);
  • Re-exports the handleDeleteEntities handler for use in callToolHandler.
    export { handleDeleteEntities } from './deleteEntities.js';
  • Supporting method in KnowledgeGraphManager that handles entity deletion, including relations cleanup and vector store removal, delegating to storageProvider when available.
    async deleteEntities(entityNames: string[]): Promise<void> { if (!entityNames || entityNames.length === 0) { return; } if (this.storageProvider) { // Use storage provider for deleting entities await this.storageProvider.deleteEntities(entityNames); } else { // Fallback to file-based implementation const graph = await this.loadGraph(); // Remove the entities const entitiesToKeep = graph.entities.filter((e) => !entityNames.includes(e.name)); // Remove relations involving the deleted entities const relationsToKeep = graph.relations.filter( (r) => !entityNames.includes(r.from) && !entityNames.includes(r.to) ); // Update the graph graph.entities = entitiesToKeep; graph.relations = relationsToKeep; await this.saveGraph(graph); } // Remove entities from vector store if available try { // Ensure vector store is available const vectorStore = await this.ensureVectorStore().catch(() => undefined); if (vectorStore) { for (const entityName of entityNames) { try { await vectorStore.removeVector(entityName); logger.debug(`Removed vector for entity ${entityName} from vector store`); } catch (error) { logger.error(`Failed to remove vector for entity ${entityName}`, error); // Don't throw here, continue with the next entity } } } } catch (error) { logger.error('Failed to remove vectors from vector store', error); // Continue even if vector store operations fail } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gannonh/memento-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server