Skip to main content
Glama
branch-handlers.ts2.61 kB
import { Entity, MemoryBranchInfo } from "../../memory-types.js"; /** * Branch Management Handlers * Handles all memory branch operations */ export class BranchHandlers { private memoryManager: any; constructor(memoryManager: any) { this.memoryManager = memoryManager; } async handleListMemoryBranches(): Promise<any> { const branches = await this.memoryManager.listBranches(); return { content: [ { type: "text", text: JSON.stringify( { branches, summary: `Found ${ branches.length } memory branches. Main branch has ${ branches.find((b: any) => b.name === "main")?.entityCount || 0 } entities.`, }, null, 2 ), }, ], }; } async handleCreateMemoryBranch(args: any): Promise<any> { if (!args.branch_name) { throw new Error("branch_name is required"); } const newBranch = await this.memoryManager.createBranch( args.branch_name as string, args.purpose as string ); return { content: [ { type: "text", text: JSON.stringify( { message: `Created branch "${args.branch_name}"`, branch: newBranch, }, null, 2 ), }, ], }; } async handleDeleteMemoryBranch(args: any): Promise<any> { if (!args.branch_name) { throw new Error("branch_name is required"); } await this.memoryManager.deleteBranch(args.branch_name as string); return { content: [ { type: "text", text: JSON.stringify( { message: `Deleted branch "${args.branch_name}"`, }, null, 2 ), }, ], }; } async handleReadMemoryBranch(args: any): Promise<any> { const branchGraph = await this.memoryManager.readGraph( args.branch_name as string, args.include_statuses, args.include_auto_context !== false ); return { content: [ { type: "text", text: JSON.stringify( { graph: branchGraph, branch: args.branch_name || "main", summary: `Branch "${args.branch_name || "main"}" contains ${ branchGraph.entities.length } entities and ${branchGraph.relations.length} relations`, }, null, 2 ), }, ], }; } }

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/PrismAero/agentic-memory-server'

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