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.
100% client-side apps with GitHub as your database
Run AI entirely in the browser. API keys stay in localStorage, never touch a server.
Sync MindCache to any GitHub repo. Version history, branching, and collaboration built-in.
Web, Mac, Android — all apps sync through GitHub. Works offline, syncs when online.
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>
);
}
A hosted, collaborative key-value store for AI agents
All key-value data stored securely in the cloud with automatic sync between clients.
WebSocket-based live updates. Subscribe to specific keys or entire instances.
Share projects and instances with teams. Granular permissions for read/write/admin access.
Chat API, image generation, web search, and transform APIs — all reading from MindCache.
Free tier available • No credit card required
Built specifically for AI agents and LLM integration
Automatically generate LLM tool schemas for AI agents to read and write memory with zero configuration
Intelligent context tracking and memory organization that adapts to your AI agent's needs
Dynamically generate system prompts with all memory context and tool instructions included
Dynamic {placeholder} replacement with recursive resolution for context-aware prompts
Subscribe to specific keys or all changes with event-driven listeners
Organize memory with tags and search by category for efficient retrieval
IndexedDB support for browser-based persistence across page reloads
Drop-in <MindCacheChat> component and hooks for building AI apps in minutes
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.
Drop-in AI chat with streaming responses, tool integration, and MindCache memory. API keys stay in the browser. Works offline with IndexedDB persistence.
useMindCacheContext() - Access MindCache instance & AI configuseClientChat() - Build custom chat UIsuseLocalFirstSync() - 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
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']
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();
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 →Complete API reference and guides
Comprehensive llms-full.txt for LLMs, AI agents, and vibe coding — copy the entire file into your context
MindCacheProvider, MindCacheChat, and hooks for local-first AI apps
Complete documentation of all methods and types
Real-world examples and integration patterns