Skip to main content
Glama

create_relations

Establish directed connections between entities in Memento's memory system, avoiding duplicates to maintain clean relationship mapping.

Instructions

Create directed relations between entities. Skips existing relations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYesArray of relations to create.

Implementation Reference

  • Core handler function that implements the logic for creating relations: resolves entity IDs, inserts relations via repository, and returns successfully created ones.
    async createRelations(relations) { const created = []; for (const relation of relations) { const fromId = await this.#repository.getOrCreateEntityId(relation.from, 'Unknown'); const toId = await this.#repository.getOrCreateEntityId(relation.to, 'Unknown'); const inserted = await this.#repository.createRelation(fromId, toId, relation.relationType); if (inserted) { created.push(relation); } } return created; }
  • src/server.js:67-88 (registration)
    Registers the MCP tool 'create_relations' with name, description, input schema using Zod, and a thin handler that delegates to KnowledgeGraphManager.createRelations and formats response.
    // Tool: create_relations this.tool( 'create_relations', 'Create directed relations between entities. Skips existing relations.', { relations: z.array(z.object({ from: z.string().describe('Source entity name.'), to: z.string().describe('Target entity name.'), relationType: z.string().describe('Label or type of the relation.') })).describe('Array of relations to create.') }, async ({ relations }) => ({ content: [{ type: 'text', text: JSON.stringify( await this.#knowledgeGraphManager.createRelations(relations), null, 2 ) }] }) );
  • Zod schema defining the input parameters for the 'create_relations' tool: array of relations with from, to, and relationType fields.
    { relations: z.array(z.object({ from: z.string().describe('Source entity name.'), to: z.string().describe('Target entity name.'), relationType: z.string().describe('Label or type of the relation.') })).describe('Array of relations to create.') },

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/iAchilles/memento'

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