Skip to main content
Glama

delete_observations

Remove specific observations from entities in a knowledge graph to maintain accurate semantic code indexing and search capabilities.

Instructions

Delete specific observations from entities in the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deletionsYes

Implementation Reference

  • The primary handler for the 'delete_observations' tool. Validates the input arguments and delegates the deletion to the knowledge graph manager.
    export const deleteObservationsHandler: ToolHandler = async (args) => {
      if (!args.deletions || !Array.isArray(args.deletions)) {
        throw new Error("The 'deletions' parameter is required and must be an array");
      }
    
      // Valider chaque suppression
      for (const deletion of args.deletions) {
        if (!deletion.entityName || typeof deletion.entityName !== 'string') {
          throw new Error("Each deletion must have an 'entityName' string property");
        }
        if (!deletion.observations || !Array.isArray(deletion.observations)) {
          throw new Error("Each deletion must have an 'observations' array property");
        }
      }
    
      try {
        await knowledgeGraphManager.deleteObservations(args.deletions);
        return { 
          content: [{ 
            type: "text", 
            text: "Observations deleted successfully" 
          }] 
        };
      } catch (error) {
        console.error("Error in delete_observations tool:", error);
        throw error;
      }
    };
  • The tool definition including name, description, and input schema for 'delete_observations'.
    export const deleteObservationsTool: ToolDefinition = {
      name: "delete_observations",
      description: "Delete specific observations from entities in the knowledge graph",
      inputSchema: {
        type: "object",
        properties: {
          deletions: {
            type: "array",
            items: {
              type: "object",
              properties: {
                entityName: { 
                  type: "string", 
                  description: "The name of the entity containing the observations" 
                },
                observations: {
                  type: "array",
                  items: { type: "string" },
                  description: "An array of observations to delete"
                },
              },
              required: ["entityName", "observations"],
            },
          },
        },
        required: ["deletions"],
      },
    };
  • Core helper function in KnowledgeGraphManager that performs the actual deletion of observations by filtering the entity's observations array and saving the graph.
    async deleteObservations(deletions: DeletionInput[]): Promise<void> {
      const graph = await this.loadGraph();
      deletions.forEach(d => {
        const entity = graph.entities.find(e => e.name === d.entityName);
        if (entity) {
          entity.observations = entity.observations.filter(o => !d.observations.includes(o));
        }
      });
      await this.saveGraph(graph);
    }
  • The auto-registration system that discovers and registers tools from build/tools/graph including delete_observations via its Tool and Handler exports.
    export const autoRegistry = new AutoRegistry();
    
    /**
     * Fonction utilitaire pour initialiser le registre automatique
  • Alternative schema definition for delete_observations in the graph tools array (possibly for manual use or dispatcher).
        name: "delete_observations",
        description: "Delete specific observations from entities in the knowledge graph",
        inputSchema: {
            type: "object",
            properties: {
                deletions: {
                    type: "array",
                    items: {
                        type: "object",
                        properties: {
                            entityName: { type: "string", description: "The name of the entity containing the observations" },
                            observations: {
                                type: "array",
                                items: { type: "string" },
                                description: "An array of observations to delete"
                            },
                        },
                        required: ["entityName", "observations"],
                    },
                },
            },
            required: ["deletions"],
        },
    },
  • Dispatcher handler case for delete_observations in executeGraphTool function.
    case "delete_observations":
        await knowledgeGraphManager.deleteObservations(args.deletions);
        return { content: [{ type: "text", text: "Observations deleted successfully" }] };

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/ali-48/rag-mcp-server'

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