Skip to main content
Glama

add_location

Add a new location to MemoryMesh's knowledge graph, including details like name, type, description, status, notable features, and associated characters, quests, or artifacts for enhanced world-building.

Instructions

Add a new location to the knowledge graph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationYes

Implementation Reference

  • Core handler logic for the 'add_location' tool (and similar add_<schema> tools). Checks if node exists, creates nodes and relationships using createSchemaNode, adds them to the graph in a transaction, and returns formatted response.
    switch (operation) {
        case 'add': {
            const nodeData = args[schemaName];
            const existingNodes = await knowledgeGraphManager.openNodes([nodeData.name]);
    
            if (existingNodes.nodes.length > 0) {
                throw new Error(`Node already exists: ${nodeData.name}`);
            }
    
            const {nodes, edges} = await createSchemaNode(nodeData, schema, schemaName);
    
            await knowledgeGraphManager.beginTransaction();
            try {
                await knowledgeGraphManager.addNodes(nodes);
                if (edges.length > 0) {
                    await knowledgeGraphManager.addEdges(edges);
                }
                await knowledgeGraphManager.commit();
    
                return formatToolResponse({
                    data: {nodes, edges},
                    actionTaken: `Created ${schemaName}: ${nodeData.name}`
                });
            } catch (error) {
                await knowledgeGraphManager.rollback();
                throw error;
            }
        }
  • SchemaBuilder.build() method generates the Tool inputSchema for 'add_location' from the schema configuration, used as the tool schema in dynamic tool generation.
    build(): SchemaConfig {
        return {
            ...this.schema as SchemaConfig,
            relationships: Object.fromEntries(this.relationships),
            metadataConfig: this.metadataConfig
        };
    }
  • ToolsRegistry.initialize() registers all dynamic tools (including 'add_location' if location schema exists) into the central tools Map by calling dynamicToolManager.getTools().
    async initialize(knowledgeGraphManager: ApplicationManager): Promise<void> {
        if (this.initialized) {
            return;
        }
    
        try {
            this.knowledgeGraphManager = knowledgeGraphManager;
    
            // Register static tools
            allStaticTools.forEach(tool => {
                this.tools.set(tool.name, tool);
            });
    
            // Initialize and register dynamic tools
            await dynamicToolManager.initialize();
            dynamicToolManager.getTools().forEach(tool => {
                this.tools.set(tool.name, tool);
            });
    
            this.initialized = true;
            console.error(`[ToolsRegistry] Initialized with ${this.tools.size} tools`);
        } catch (error) {
            console.error('[ToolsRegistry] Initialization error:', error);
            throw error;
        }
    }
  • DynamicSchemaToolRegistry.initialize() loads schema files, creates SchemaBuilder instances, generates add/update/delete tools (e.g. 'add_location'), and caches them.
    public async initialize(): Promise<void> {
        try {
            const SCHEMAS_DIR = CONFIG.PATHS.SCHEMAS_DIR;
            const schemaFiles = await fs.readdir(SCHEMAS_DIR);
    
            // Process schema files
            for (const file of schemaFiles) {
                if (file.endsWith('.schema.json')) {
                    const schemaName = path.basename(file, '.schema.json');
                    const schema = await SchemaLoader.loadSchema(schemaName);
                    this.schemas.set(schemaName, schema);
                }
            }
    
            // Generate tools for each schema
            for (const [schemaName, schema] of this.schemas.entries()) {
                const tools = await this.generateToolsForSchema(schemaName, schema);
                tools.forEach(tool => this.toolsCache.set(tool.name, tool));
            }
    
            console.error(`[DynamicSchemaTools] Initialized ${this.schemas.size} schemas and ${this.toolsCache.size} tools`);
        } catch (error) {
            console.error('[DynamicSchemaTools] Initialization error:', error);
            throw error;
        }
    }
  • SchemaBuilder constructor initializes the inputSchema structure specifically for 'add_*' named schemas (like 'add_location'), setting up the object wrapper and properties.
    constructor(name: string, description: string) {
        this.schema = {
            name,
            description,
            inputSchema: {
                type: "object",
                properties: {
                    [name.replace('add_', '')]: {
                        type: "object",
                        properties: {},
                        required: [],
                        additionalProperties: {
                            type: "string",
                            description: "Any additional properties"
                        }
                    }
                },
                required: [name.replace('add_', '')]
            }
        };
    
        this.relationships = new Map();
        this.metadataConfig = {
            requiredFields: [],
            optionalFields: [],
            excludeFields: []
        };
    }
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. 'Add a new location' implies a write/mutation operation, but the description doesn't address permissions needed, whether duplicates are allowed, how the location integrates with the graph, what happens on success/failure, or any side effects. This leaves significant behavioral gaps for a mutation tool.

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 maximally concise - a single sentence that states the core purpose without any fluff. Every word earns its place, and the structure is front-loaded with the essential information. There's no wasted verbiage or unnecessary elaboration.

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

Completeness2/5

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

For a mutation tool with no annotations, 0% schema description coverage, no output schema, and complex nested parameters, the description is severely inadequate. It doesn't compensate for the missing structured information about behavior, parameters, or results. The agent lacks critical context about how this tool operates within the knowledge graph ecosystem.

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

Parameters1/5

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

The schema description coverage is 0% (no parameter descriptions in the schema), and the tool description provides absolutely no information about the single 'location' parameter or its nested properties. The agent must infer everything from property names alone, with no guidance on what constitutes a valid location object, required fields beyond schema requirements, or how properties interrelate.

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 action ('Add') and resource ('location to the knowledge graph'), making the purpose understandable. It distinguishes itself from siblings like 'add_artifact' or 'add_quest' by specifying the resource type, but doesn't explicitly differentiate from other location-related tools like 'update_location' or 'delete_location' in terms of when to use each.

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. With siblings like 'update_location' and 'delete_location' available, there's no indication of prerequisites, when this tool is appropriate versus updates, or any context about the knowledge graph system that would inform usage decisions.

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/CheMiguel23/MemoryMesh'

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