Skip to main content
Glama
j3k0

Elasticsearch Knowledge Graph for MCP

by j3k0

mark_important

Boost or reduce an entity's relevance score in the Elasticsearch Knowledge Graph, enhancing its importance in searches or memory-based queries. Specify memory zone and optionally create new entities if needed.

Instructions

Mark entity as important in knowledge graph (memory) by boosting its relevance score

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
auto_createNoWhether to automatically create the entity if it doesn't exist (default: false)
importantYesSet as important (true - multiply relevance by 10) or not (false - divide relevance by 10)
memory_zoneYesOptional memory zone specifier. If provided, entity will be marked in this zone.
nameYesEntity name

Implementation Reference

  • Core handler logic for the mark_important tool: adjusts entity relevance score by factor of 10 or 0.1, auto-creates entity if specified and missing.
    async markImportant(
      name: string, 
      important: boolean, 
      zone?: string,
      options?: {
        autoCreateMissingEntities?: boolean;
      }
    ): Promise<ESEntity> {
      return this.updateEntityRelevanceScore(name, important ? 10 : 0.1, zone, options);
    }
    
    /**
     * Mark an entity as important or not important
     * @param name Entity name
     * @param important Whether the entity is important
     * @param zone Optional memory zone name, uses defaultZone if not specified
     * @param options Optional configuration options
     * @param options.autoCreateMissingEntities Whether to automatically create missing entities (default: false)
     * @returns The updated entity
     */
    async updateEntityRelevanceScore(
      name: string, 
      ratio: number, 
      zone?: string,
      options?: {
        autoCreateMissingEntities?: boolean;
      }
    ): Promise<ESEntity> {
      const actualZone = zone || this.defaultZone;
      
      // Default to false for auto-creation (different from saveRelation)
      const autoCreateMissingEntities = options?.autoCreateMissingEntities ?? false;
    
      // Get existing entity
    
      // Get existing entity
      let entity = await this.getEntity(name, actualZone);
      
      // If entity doesn't exist
      if (!entity) {
        if (autoCreateMissingEntities) {
          // Auto-create the entity with unknown type
          entity = await this.saveEntity({
            name: name,
            entityType: 'unknown',
            observations: [],
            relevanceScore: 1.0
          }, actualZone);
        } else {
          throw new Error(`Entity "${name}" not found in zone "${actualZone}"`);
        }
      }
      
      // Calculate the new relevance score
      // If marking as important, multiply by 10
      // If removing importance, divide by 10
      const baseRelevanceScore = entity.relevanceScore || 1.0;
      const newRelevanceScore = ratio > 1.0
        ? Math.min(25, baseRelevanceScore * ratio)
        : Math.max(0.01, baseRelevanceScore * ratio);
      
      // Update entity with new relevance score
      const updatedEntity = await this.saveEntity({
        name: entity.name,
        entityType: entity.entityType,
        observations: entity.observations,
        relevanceScore: newRelevanceScore
      }, actualZone);
      
      return updatedEntity;
    }
  • JSON schema defining input parameters for mark_important tool: name (string, required), important (boolean, required), memory_zone (string, required), auto_create (boolean, optional).
      name: "mark_important",
      description: "Mark entity as important in knowledge graph (memory) by boosting its relevance score",
      inputSchema: {
        type: "object",
        properties: {
          name: {
            type: "string",
            description: "Entity name"
          },
          important: {
            type: "boolean",
            description: "Set as important (true - multiply relevance by 10) or not (false - divide relevance by 10)"
          },
          memory_zone: {
            type: "string",
            description: "Optional memory zone specifier. If provided, entity will be marked in this zone."
          },
          auto_create: {
            type: "boolean",
            description: "Whether to automatically create the entity if it doesn't exist (default: false)",
            default: false
          }
        },
        required: ["memory_zone", "name", "important"],
        additionalProperties: false,
        "$schema": "http://json-schema.org/draft-07/schema#"
      }
    },
  • src/index.ts:1056-1080 (registration)
    Tool dispatch handler in CallToolRequestSchema that extracts parameters, calls kgClient.markImportant, handles errors and formats response.
    else if (toolName === "mark_important") {
      const name = params.name;
      const important = params.important;
      const zone = params.memory_zone;
      const autoCreate = params.auto_create === true;
      
      try {
        // Mark the entity as important, with auto-creation if specified
        const updatedEntity = await kgClient.markImportant(name, important, zone, {
          autoCreateMissingEntities: autoCreate
        });
        
        return formatResponse({
          success: true,
          entity: updatedEntity,
          auto_created: autoCreate && !(await kgClient.getEntity(name, zone))
        });
      } catch (error) {
        const zoneMsg = zone ? ` in zone "${zone}"` : "";
        return formatResponse({
          success: false,
          error: `Entity "${name}" not found${zoneMsg}`,
          message: "Please create the entity before marking it as important, or set auto_create to true."
        });
      }
  • src/index.ts:89-649 (registration)
    Registration of mark_important tool in the ListToolsRequestSchema response, including name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: "inspect_files",
            description: "Agent driven file inspection that uses AI to retrieve relevant content from multiple files.",
            inputSchema: {
              type: "object",
              properties: {
                file_paths: {
                  type: "array",
                  items: { type: "string" },
                  description: "Paths to the files (or directories) to inspect"
                },
                information_needed: {
                  type: "string",
                  description: "Full description of what information is needed from the files, including the context of the information needed. Do not be vague, be specific. The AI agent does not have access to your context, only this \"information needed\" and \"reason\" fields. That's all it will use to decide that a line is relevant to the information needed. So provide a detailed specific description, listing all the details about what you are looking for."
                },
                reason: {
                  type: "string",
                  description: "Explain why this information is needed to help the AI agent give better results. The more context you provide, the better the results will be."
                },
                include_lines: {
                  type: "boolean",
                  description: "Whether to include the actual line content in the response, which uses more of your limited token quota, but gives more informatiom (default: false)"
                },
                keywords: {
                  type: "array",
                  items: { type: "string" },
                  description: "Array of specific keywords related to the information needed. AI will target files that contain one of these keywords. REQUIRED and cannot be null or empty - the more keywords you provide, the better the results. Include variations, synonyms, and related terms."
                }
              },
              required: ["file_paths", "information_needed", "include_lines", "keywords"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "inspect_knowledge_graph",
            description: "Agent driven knowledge graph inspection that uses AI to retrieve relevant entities and relations based on a query.",
            inputSchema: {
              type: "object",
              properties: {
                information_needed: {
                  type: "string",
                  description: "Full description of what information is needed from the knowledge graph, including the context of the information needed. Do not be vague, be specific. The AI agent does not have access to your context, only this \"information needed\" and \"reason\" fields. That's all it will use to decide that an entity is relevant to the information needed."
                },
                reason: {
                  type: "string",
                  description: "Explain why this information is needed to help the AI agent give better results. The more context you provide, the better the results will be."
                },
                include_entities: {
                  type: "boolean",
                  description: "Whether to include the full entity details in the response, which uses more of your limited token quota, but gives more information (default: false)"
                },
                include_relations: {
                  type: "boolean",
                  description: "Whether to include the entity relations in the response (default: false)"
                },
                keywords: {
                  type: "array",
                  items: { type: "string" },
                  description: "Array of specific keywords related to the information needed. AI will target entities that match one of these keywords. REQUIRED and cannot be null or empty - the more keywords you provide, the better the results. Include variations, synonyms, and related terms."
                },
                memory_zone: {
                  type: "string",
                  description: "Memory zone to search in. If not provided, uses the default zone."
                },
                entity_types: {
                  type: "array",
                  items: { type: "string" },
                  description: "Optional filter to specific entity types"
                }
              },
              required: ["information_needed", "keywords"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "create_entities",
            description: "Create entities in knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                entities: {
                  type: "array",
                  items: {
                    type: "object",
                    properties: {
                      name: {type: "string", description: "Entity name"},
                      entityType: {type: "string", description: "Entity type"},
                      observations: {
                        type: "array", 
                        items: {type: "string"},
                        description: "Observations about this entity"
                      }
                    },
                    required: ["name", "entityType"]
                  },
                  description: "List of entities to create"
                },
                memory_zone: {
                  type: "string",
                  description: "Memory zone to create entities in."
                }
              },
              required: ["entities", "memory_zone"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "update_entities",
            description: "Update entities in knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                entities: {
                  type: "array",
                  description: "List of entities to update",
                  items: {
                    type: "object",
                    properties: {
                      name: {type: "string"},
                      entityType: {type: "string"},
                      observations: {
                        type: "array",
                        items: {type: "string"}
                      },
                      isImportant: {type: "boolean"}
                    },
                    required: ["name"]
                  }
                },
                memory_zone: {
                  type: "string",
                  description: "Memory zone specifier. Entities will be updated in this zone."
                }
              },
              required: ["entities", "memory_zone"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "delete_entities",
            description: "Delete entities from knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                names: {
                  type: "array",
                  items: {type: "string"},
                  description: "Names of entities to delete"
                },
                memory_zone: {
                  type: "string",
                  description: "Memory zone specifier. Entities will be deleted from this zone."
                },
                cascade_relations: {
                  type: "boolean",
                  description: "Whether to delete relations involving these entities (default: true)",
                  default: true
                }
              },
              required: ["names", "memory_zone"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "create_relations",
            description: "Create relationships between entities in knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                relations: {
                  type: "array",
                  description: "List of relations to create",
                  items: {
                    type: "object",
                    properties: {
                      from: {type: "string", description: "Source entity name"},
                      fromZone: {type: "string", description: "Optional zone for source entity, defaults to memory_zone or default zone. Must be one of the existing zones."},
                      to: {type: "string", description: "Target entity name"},
                      toZone: {type: "string", description: "Optional zone for target entity, defaults to memory_zone or default zone. Must be one of the existing zones."},
                      type: {type: "string", description: "Relationship type"}
                    },
                    required: ["from", "to", "type"]
                  }
                },
                memory_zone: {
                  type: "string",
                  description: "Optional default memory zone specifier. Used if a relation doesn't specify fromZone or toZone."
                },
                auto_create_missing_entities: {
                  type: "boolean",
                  description: "Whether to automatically create missing entities in the relations (default: true)",
                  default: true
                }
              },
              required: ["relations"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "delete_relations",
            description: "Delete relationships from knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                relations: {
                  type: "array",
                  description: "List of relations to delete",
                  items: {
                    type: "object",
                    properties: {
                      from: {type: "string", description: "Source entity name"},
                      to: {type: "string", description: "Target entity name"},
                      type: {type: "string", description: "Relationship type"}
                    },
                    required: ["from", "to", "type"]
                  }
                },
                memory_zone: {
                  type: "string",
                  description: "Optional memory zone specifier. If provided, relations will be deleted from this zone."
                }
              },
              required: ["relations"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "search_nodes",
            description: "Search entities using ElasticSearch query syntax. Supports boolean operators (AND, OR, NOT), fuzzy matching (~), phrases (\"term\"), proximity (\"terms\"~N), wildcards (*, ?), and boosting (^N). Examples: 'meeting AND notes', 'Jon~', '\"project plan\"~2'. All searches respect zone isolation.",
            inputSchema: {
              type: "object",
              properties: {
                query: {
                  type: "string",
                  description: "ElasticSearch query string."
                },
                informationNeeded: {
                  type: "string",
                  description: "Important. Describe what information you are looking for, to give a precise context to the search engine AI agent. What questions are you trying to answer? Helps get more useful results."
                },
                reason: {
                  type: "string",
                  description: "Explain why this information is needed to help the AI agent give better results. The more context you provide, the better the results will be."
                },
                entityTypes: {
                  type: "array",
                  items: {type: "string"},
                  description: "Filter to specific entity types (OR condition if multiple)."
                },
                limit: {
                  type: "integer",
                  description: "Max results (default: 20, or 5 with observations)."
                },
                sortBy: {
                  type: "string",
                  enum: ["relevance", "recency", "importance"],
                  description: "Sort by match quality, access time, or importance."
                },
                includeObservations: {
                  type: "boolean",
                  description: "Include full entity observations (default: false).",
                  default: false
                },
                memory_zone: {
                  type: "string",
                  description: "Limit search to specific zone. Omit for default zone."
                },
              },
              required: ["query", "memory_zone", "informationNeeded", "reason"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "open_nodes",
            description: "Get details about specific entities in knowledge graph (memory) and their relations",
            inputSchema: {
              type: "object",
              properties: {
                names: {
                  type: "array",
                  items: {type: "string"},
                  description: "Names of entities to retrieve"
                },
                memory_zone: {
                  type: "string",
                  description: "Optional memory zone to retrieve entities from. If not specified, uses the default zone."
                }
              },
              required: ["names", "memory_zone"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "add_observations",
            description: "Add observations to an existing entity in knowledge graph (memory)",
            inputSchema: {
              type: "object",
              properties: {
                name: {
                  type: "string",
                  description: "Name of entity to add observations to"
                },
                observations: {
                  type: "array",
                  items: {type: "string"},
                  description: "Observations to add to the entity"
                },
                memory_zone: {
                  type: "string",
                  description: "Optional memory zone where the entity is stored. If not specified, uses the default zone."
                }
              },
              required: ["memory_zone", "name", "observations"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "mark_important",
            description: "Mark entity as important in knowledge graph (memory) by boosting its relevance score",
            inputSchema: {
              type: "object",
              properties: {
                name: {
                  type: "string",
                  description: "Entity name"
                },
                important: {
                  type: "boolean",
                  description: "Set as important (true - multiply relevance by 10) or not (false - divide relevance by 10)"
                },
                memory_zone: {
                  type: "string",
                  description: "Optional memory zone specifier. If provided, entity will be marked in this zone."
                },
                auto_create: {
                  type: "boolean",
                  description: "Whether to automatically create the entity if it doesn't exist (default: false)",
                  default: false
                }
              },
              required: ["memory_zone", "name", "important"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "get_recent",
            description: "Get recently accessed entities from knowledge graph (memory) and their relations",
            inputSchema: {
              type: "object",
              properties: {
                limit: {
                  type: "integer",
                  description: "Max results (default: 20 if includeObservations is false, 5 if true)"
                },
                includeObservations: {
                  type: "boolean",
                  description: "Whether to include full entity observations in results (default: false)",
                  default: false
                },
                memory_zone: {
                  type: "string",
                  description: "Optional memory zone to get recent entities from. If not specified, uses the default zone."
                }
              },
              required: ["memory_zone"],
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "list_zones",
            description: "List all available memory zones with metadata. When a reason is provided, zones will be filtered and prioritized based on relevance to your needs.",
            inputSchema: {
              type: "object",
              properties: {
                reason: {
                  type: "string",
                  description: "Reason for listing zones. What zones are you looking for? Why are you looking for them? The AI will use this to prioritize and filter relevant zones."
                }
              },
              additionalProperties: false,
              "$schema": "http://json-schema.org/draft-07/schema#"
            }
          },
          {
            name: "create_zone",
            description: "Create a new memory zone with optional description.",
            inputSchema: {
              type: "object",
              properties: {
                name: {
                  type: "string",
                  description: "Zone name (cannot be 'default')"
                },
                shortDescription: {
                  type: "string",
                  description: "Short description of the zone."
                },
                description: {
                  type: "string",
                  description: "Full zone description. Make it very descriptive and detailed."
                }
              },
              required: ["name"]
            }
          },
          {
            name: "delete_zone",
            description: "Delete a memory zone and all its entities/relations.",
            inputSchema: {
              type: "object",
              properties: {
                name: {
                  type: "string",
                  description: "Zone name to delete (cannot be 'default')"
                },
                confirm: {
                  type: "boolean",
                  description: "Confirmation flag, must be true",
                  default: false
                }
              },
              required: ["name", "confirm"]
            }
          },
          {
            name: "copy_entities",
            description: "Copy entities between zones with optional relation handling.",
            inputSchema: {
              type: "object",
              properties: {
                names: {
                  type: "array",
                  items: { type: "string" },
                  description: "Entity names to copy"
                },
                source_zone: {
                  type: "string",
                  description: "Source zone"
                },
                target_zone: {
                  type: "string",
                  description: "Target zone"
                },
                copy_relations: {
                  type: "boolean",
                  description: "Copy related relationships (default: true)",
                  default: true
                },
                overwrite: {
                  type: "boolean",
                  description: "Overwrite if entity exists (default: false)",
                  default: false
                }
              },
              required: ["names", "source_zone", "target_zone"]
            }
          },
          {
            name: "move_entities",
            description: "Move entities between zones (copy + delete from source).",
            inputSchema: {
              type: "object",
              properties: {
                names: {
                  type: "array",
                  items: { type: "string" },
                  description: "Entity names to move"
                },
                source_zone: {
                  type: "string",
                  description: "Source zone"
                },
                target_zone: {
                  type: "string",
                  description: "Target zone"
                },
                move_relations: {
                  type: "boolean",
                  description: "Move related relationships (default: true)",
                  default: true
                },
                overwrite: {
                  type: "boolean",
                  description: "Overwrite if entity exists (default: false)",
                  default: false
                }
              },
              required: ["names", "source_zone", "target_zone"]
            }
          },
          {
            name: "merge_zones",
            description: "Merge multiple zones with conflict resolution options.",
            inputSchema: {
              type: "object",
              properties: {
                source_zones: {
                  type: "array",
                  items: { type: "string" },
                  description: "Source zones to merge from"
                },
                target_zone: {
                  type: "string",
                  description: "Target zone to merge into"
                },
                delete_source_zones: {
                  type: "boolean",
                  description: "Delete source zones after merging",
                  default: false
                },
                overwrite_conflicts: {
                  type: "string",
                  enum: ["skip", "overwrite", "rename"],
                  description: "How to handle name conflicts",
                  default: "skip"
                }
              },
              required: ["source_zones", "target_zone"]
            }
          },
          {
            name: "zone_stats",
            description: "Get statistics for entities and relationships in a zone.",
            inputSchema: {
              type: "object",
              properties: {
                zone: {
                  type: "string",
                  description: "Zone name (omit for default zone)"
                }
              },
              required: ["zone"]
            }
          },
          {
            name: "get_time_utc",
            description: "Get the current UTC time in YYYY-MM-DD hh:mm:ss format",
            inputSchema: {
              type: "object",
              properties: {},
              additionalProperties: false
            }
          }
        ]
      };
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the effect on relevance scores (multiply/divide by 10) and implies mutation ('mark'), but doesn't cover permissions, rate limits, side effects (e.g., impact on other entities), or response format. For a mutation tool with zero annotation coverage, this leaves significant gaps in understanding how it behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('mark entity as important') and includes key behavioral detail ('boosting its relevance score'). There is zero waste or redundancy, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and a mutation tool with 4 parameters, the description is minimally adequate. It covers the purpose and basic effect but lacks details on usage context, behavioral traits, and return values. The high schema coverage helps, but for a tool that modifies data, more guidance would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't explain 'memory_zone' or 'auto_create' further). Baseline 3 is appropriate when the schema does the heavy lifting, though no extra value is added.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('mark') and resource ('entity in knowledge graph') with the specific action of 'boosting its relevance score'. It distinguishes from siblings like 'create_entities' or 'update_entities' by focusing on importance marking rather than creation or general updates. However, it doesn't explicitly differentiate from all siblings like 'merge_zones' or 'move_entities' in terms of scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'update_entities' (which might handle importance) or 'create_entities' (with auto_create parameter). It mentions the effect on relevance scores but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/j3k0/mcp-brain-tools'

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