Skip to main content
Glama

neuroverse_store

Store memory records in a tiered system for AI agents, organizing short-term, episodic, and semantic data with importance-based persistence.

Instructions

Store a memory record in NeuroVerse's tiered memory system.

Tiers:

  • short_term: In-process, capped at 50 per user. Lost on restart.

  • episodic: Persisted to JSON file. Recent actions.

  • semantic: Persisted to JSON file. Long-term facts.

Only episodic/semantic memories with importance_score ≥ 0.4 are persisted.

Args:

  • user_id (string): Agent / user identifier

  • intent (string): Canonical intent name

  • tier (string): short_term | episodic | semantic

  • language (string): Language code (default: "en")

  • data (object): Structured payload

  • importance_score (number): 0.0–1.0

Returns: JSON of the stored MemoryRecord

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idYesAgent / user identifier
intentYesCanonical intent this memory relates to
tierNoMemory tiershort_term
languageNoPrimary language codeen
dataNoStructured memory payload
importance_scoreNoImportance score — only above 0.4 are persisted for episodic/semantic

Implementation Reference

  • The MCP tool registration and handler function for "neuroverse_store" in `npm/src/index.ts`. It invokes `storeMemory` from `core/memory.ts`.
    server.registerTool(
      "neuroverse_store",
      {
        title: "Store Memory",
        description: `Store a memory record in NeuroVerse's tiered memory system.
    
    Tiers:
      - short_term: In-process, capped at 50 per user. Lost on restart.
      - episodic: Persisted to JSON file. Recent actions.
      - semantic: Persisted to JSON file. Long-term facts.
    
    Only episodic/semantic memories with importance_score ≥ 0.4 are persisted.
    
    Args:
      - user_id (string): Agent / user identifier
      - intent (string): Canonical intent name
      - tier (string): short_term | episodic | semantic
      - language (string): Language code (default: "en")
      - data (object): Structured payload
      - importance_score (number): 0.0–1.0
    
    Returns:
      JSON of the stored MemoryRecord`,
        inputSchema: StoreMemorySchema,
        annotations: {
          readOnlyHint: false,
          destructiveHint: false,
          idempotentHint: false,
          openWorldHint: false,
        },
      },
      async (params) => {
        const record = await storeMemory({
          userId: params.user_id,
          intent: params.intent,
          tier: params.tier as MemoryTier,
          language: params.language,
          data: params.data as Record<string, unknown>,
          importanceScore: params.importance_score,
        });
    
        return {
          content: [{ type: "text" as const, text: JSON.stringify(record, null, 2) }],
        };
      }
    );
  • The actual implementation of `storeMemory`, which handles tiered memory storage (short-term in-memory vs persistent storage).
    /**
     * Store a memory record in the appropriate tier.
     */
    export async function storeMemory(record: Partial<MemoryRecord> & { userId: string; intent: string }): Promise<MemoryRecord> {
      const now = new Date().toISOString();
      
      let vector: number[] | undefined;
      if (record.tier && record.tier !== "short_term" && record.importanceScore !== undefined && record.importanceScore >= IMPORTANCE_THRESHOLD) {
         const textToEmbed = JSON.stringify(record.data);
         if (textToEmbed && textToEmbed !== "{}") {
           vector = await generateEmbedding(textToEmbed);
         }
      }
    
      const full: MemoryRecord = {
        id: record.id ?? randomUUID(),
        userId: record.userId,
        tier: (record.tier ?? "short_term") as MemoryTier,
        intent: record.intent,
        language: record.language ?? "en",
        data: record.data ?? {},
        importanceScore: record.importanceScore ?? 0.5,
        vector,
        createdAt: record.createdAt ?? now,
        updatedAt: now,
      };
    
      if (full.tier === "short_term") {
        const existing = shortTerm.get(full.userId) ?? [];
        existing.push(full);
        // Cap
        if (existing.length > MAX_SHORT_TERM) {
          existing.shift();
        }
        shortTerm.set(full.userId, existing);
      } else {
        // Episodic / Semantic — persist only above threshold
        if (full.importanceScore >= IMPORTANCE_THRESHOLD) {
          const records = loadPersistent();
          records.push(full);
          savePersistent(records);
        }
      }
    
      return full;
    }
  • The Zod schema used for input validation of the "neuroverse_store" tool.
    const StoreMemorySchema = z
      .object({
        user_id: z.string().min(1).describe("Agent / user identifier"),
        intent: z.string().min(1).describe("Canonical intent this memory relates to"),
        tier: z
          .enum(["short_term", "episodic", "semantic"])
          .default("short_term")
          .describe("Memory tier"),
        language: z.string().default("en").describe("Primary language code"),
        data: z
          .record(z.unknown())
          .default({})
          .describe("Structured memory payload"),
        importance_score: z
          .number()
          .min(0)
          .max(1)
          .default(0.5)
          .describe("Importance score — only above 0.4 are persisted for episodic/semantic"),
      })
      .strict();

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/joshua400/neuroverse'

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