Skip to main content
Glama
itseasy21

Knowledge Graph Memory Server

create_relations

Establish connections between entities in the knowledge graph by defining relation types, enabling structured data storage and retrieval for AI memory systems.

Instructions

Create multiple new relations between entities in the knowledge graph. Relations should be in active voice

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
relationsYes

Implementation Reference

  • index.ts:93-107 (handler)
    The core handler function in KnowledgeGraphManager that executes the create_relations tool logic: loads the graph from memory file, deduplicates incoming relations, adds creation timestamp and version, appends to graph, saves back to file, and returns newly created relations.
    async createRelations(relations: Relation[]): Promise<Relation[]> { const graph = await this.loadGraph(); const newRelations = relations.filter(r => !graph.relations.some(existingRelation => existingRelation.from === r.from && existingRelation.to === r.to && existingRelation.relationType === r.relationType )).map(r => ({ ...r, createdAt: new Date().toISOString(), version: r.version || 1 })); graph.relations.push(...newRelations); await this.saveGraph(graph); return newRelations; }
  • Input schema definition for the create_relations tool, specifying the expected structure: an object with a 'relations' array, each item having 'from', 'to', and 'relationType' strings.
    inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, }, }, required: ["relations"], },
  • index.ts:310-331 (registration)
    Tool registration in the listTools response, defining the name, description, and inputSchema for create_relations.
    { name: "create_relations", description: "Create multiple new relations between entities in the knowledge graph. Relations should be in active voice", inputSchema: { type: "object", properties: { relations: { type: "array", items: { type: "object", properties: { from: { type: "string", description: "The name of the entity where the relation starts" }, to: { type: "string", description: "The name of the entity where the relation ends" }, relationType: { type: "string", description: "The type of the relation" }, }, required: ["from", "to", "relationType"], }, }, }, required: ["relations"], }, },
  • index.ts:516-517 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes create_relations calls to the knowledgeGraphManager.createRelations method and formats the response.
    case "create_relations": return { content: [{ type: "text", text: JSON.stringify(await knowledgeGraphManager.createRelations(args.relations as Relation[]), null, 2) }] };
  • TypeScript interface defining the structure of a Relation, used for input validation and storage in create_relations and related tools.
    interface Relation { from: string; to: string; relationType: string; createdAt: string; version: number; }

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/itseasy21/mcp-knowledge-graph'

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