🚀 MindCache 3.7 — React Components & Local-First AI Chat!

AI Agent Memory
Made Simple

MindCache is a TypeScript library for managing short-term memory in AI agents. Drop-in React components for local-first AI chat, cloud persistence, real-time sync, and GitHub storage.

☁️ Try MindCache Cloud

Local-First with GitStore

100% client-side apps with GitHub as your database

💻

No Server Required

Run AI entirely in the browser. API keys stay in localStorage, never touch a server.

📂

GitHub as Database

Sync MindCache to any GitHub repo. Version history, branching, and collaboration built-in.

📱

Cross-Platform

Web, Mac, Android — all apps sync through GitHub. Works offline, syncs when online.

⚛️

React Components

Drop-in <MindCacheChat> component. Full AI chat in ~15 lines of code.

// Local-first AI chat in 15 lines
import { MindCacheProvider, MindCacheChat } from 'mindcache';

function App() {
  return (
    <MindCacheProvider
      ai={{ provider: 'openai', model: 'gpt-4o', keyStorage: 'localStorage' }}
    >
      <MindCacheChat welcomeMessage="Hello! I run in your browser." />
    </MindCacheProvider>
  );
}

MindCache Cloud

A hosted, collaborative key-value store for AI agents

☁️

Cloud Persistence

All key-value data stored securely in the cloud with automatic sync between clients.

Real-Time Sync

WebSocket-based live updates. Subscribe to specific keys or entire instances.

👥

Collaboration

Share projects and instances with teams. Granular permissions for read/write/admin access.

🤖

Built-in AI APIs

Chat API, image generation, web search, and transform APIs — all reading from MindCache.

☁️ Start Using MindCache Cloud

Free tier available • No credit card required

Why MindCache?

Built specifically for AI agents and LLM integration

🤖

Auto Tool Generation

Automatically generate LLM tool schemas for AI agents to read and write memory with zero configuration

🧠

Auto Context Management

Intelligent context tracking and memory organization that adapts to your AI agent's needs

📋

Auto System Prompt Generation

Dynamically generate system prompts with all memory context and tool instructions included

Template Injection

Dynamic {placeholder} replacement with recursive resolution for context-aware prompts

🔄

Reactive Updates

Subscribe to specific keys or all changes with event-driven listeners

🏷️

Tags & Search

Organize memory with tags and search by category for efficient retrieval

💾

Local Persistence

IndexedDB support for browser-based persistence across page reloads

⚛️

React Components

Drop-in <MindCacheChat> component and hooks for building AI apps in minutes

Examples

Real-world use cases for AI agents

// Full AI Chat App in ~15 Lines
import { MindCacheProvider, MindCacheChat } from 'mindcache';

function App() {
  return (
    <MindCacheProvider
      ai={{
        provider: 'openai',       // or 'anthropic'
        model: 'gpt-4o',
        keyStorage: 'localStorage' // API key stored locally
      }}
      mindcache={{
        indexedDB: { dbName: 'my-app' } // Local persistence
      }}
    >
      <MindCacheChat 
        welcomeMessage="Hello! I'm your AI assistant."
        placeholder="Type a message..."
      />
    </MindCacheProvider>
  );
}

// That's it! No server, no API routes, no backend.

Local-First React Components

Drop-in AI chat with streaming responses, tool integration, and MindCache memory. API keys stay in the browser. Works offline with IndexedDB persistence.

Hooks available:
  • useMindCacheContext() - Access MindCache instance & AI config
  • useClientChat() - Build custom chat UIs
  • useLocalFirstSync() - Sync to GitHub
// Auto Tool Generation for AI Agents
import { mindcache } from 'mindcache';
import { generateText } from 'ai';

// Store user preferences and context
mindcache.set_value('userName', 'Alice', { tags: ['user'] });
mindcache.set_value('favoriteColor', 'blue', { tags: ['preferences'] });
mindcache.set_value('lastTask', 'planning vacation', { tags: ['context'] });

// Automatically generate tool schemas for Vercel AI SDK
const tools = mindcache.get_aisdk_tools();
// Returns: {
//   write_userName: { description: "...", parameters: {...} },
//   write_favoriteColor: { description: "...", parameters: {...} },
//   write_lastTask: { description: "...", parameters: {...} }
// }

// Generate system prompt with memory context
const systemPrompt = mindcache.get_system_prompt();
// "userName: Alice. You can rewrite \"userName\" by using..."
// "favoriteColor: blue. You can rewrite \"favoriteColor\" by..."
// "$date: 2025-01-15"

// Use with AI SDK - tools are automatically available
const { text, toolCalls } = await generateText({
  model: openai('gpt-4'),
  tools: tools, // AI can now call write_userName(), etc.
  system: systemPrompt,
  prompt: 'Remember that I love green now, not blue.'
});

// AI will automatically call write_favoriteColor('green')
// and the memory is updated automatically

Auto Tool Generation

Automatically generate LLM tool schemas so AI agents can read and write memory using function calls. No manual tool definitions needed - tools are created for every writable key in your memory.

// Context Management with Tags & System Prompts
import { mindcache } from 'mindcache';

// Set items with or without tags
mindcache.set_value('tempNote', 'Meeting at 3pm');
mindcache.set_value('userName', 'Alice', { tags: ['context'] });
mindcache.set_value('userRole', 'developer', { tags: ['context'] });
mindcache.set_value('projectName', 'MindCache', { tags: ['context'] });


// Extract only tagged context for focused prompts
const contextData = mindcache.getTagged('context');
// "userName: Alice, userRole: developer, projectName: MindCache"

// Generate system prompt with all visible keys
const fullSystemPrompt = mindcache.get_system_prompt();
// Includes all keys: userName, userRole, projectName, tempNote

// Or create focused context from tagged items only
const focusedContext = `Context: ${contextData}
Instructions: You are helping ${mindcache.get_value('userName')} 
with their ${mindcache.get_value('projectName')} project.`;

// Use focused context for specific workflows
// Or use full system prompt for comprehensive memory access

// Filter keys by tag programmatically
const allKeys = Object.keys(mindcache.getAll());
const contextKeys = allKeys.filter(key => 
  mindcache.hasTag(key, 'context')
);
// ['userName', 'userRole', 'projectName']

Context Management & System Prompts

Use tags to mark important context items, extract only tagged content when needed, and automatically generate system prompts with all memory context. Perfect for building focused AI workflows while maintaining full memory access.

// MindCache Cloud Sync
import { MindCache } from 'mindcache';

// Connect to MindCache Cloud with built-in sync
const mc = new MindCache({
  cloud: {
    instanceId: 'my-instance-id',
    tokenEndpoint: '/api/ws-token', // Your API endpoint
  }
});

// Same API as local — now with cloud persistence!
mc.set_value('userName', 'Alice');
mc.set_value('notes', 'Meeting at 3pm', { tags: ['important'] });

// Real-time sync across all connected clients
mc.subscribeToAll(() => {
  console.log('Data synced from cloud!');
});

// Check connection state
console.log(mc.connectionState); // 'connected'
console.log(mc.isLoaded);        // true when initial sync done
console.log(mc.isCloud);         // true

// AI tools work the same way
const tools = mc.get_aisdk_tools();
const prompt = mc.get_system_prompt();

// Clean up when done
mc.disconnect();

Cloud Sync & Real-Time Collaboration

Seamless cloud persistence with the same simple API — data automatically syncs across all clients in real-time. Share instances with your team, connect AI agents, and build collaborative workflows.

Try MindCache Cloud →

Documentation

Complete API reference and guides

Copied to clipboard!