Agents & the cachly Brain
Autonomous AI agents (LangChain, CrewAI, AutoGen, custom REST loops) can use the cachly Brain MCP server to persist memory across runs — so every agent instance learns from past attempts and never repeats the same mistakes.
Why do agents need persistent memory?
No re-research
Agent recalls past solutions in <10 ms — skips re-running searches, API calls, or reasoning chains.
Cross-run learning
Lessons from run #1 are available in run #2, across machines and instances.
Fewer failures
Known pitfalls are stored. Agent avoids repeating failed approaches automatically.
Setup — one command
# Detects your editor and writes all configs automatically npx @cachly-dev/mcp-server@latest autopilot
Or add manually to your agent's MCP config:
{
"mcpServers": {
"cachly": {
"command": "npx",
"args": ["-y", "@cachly-dev/mcp-server@latest"],
"env": {
"CACHLY_JWT": "your-api-key",
"CACHLY_BRAIN_INSTANCE_ID": "your-instance-uuid"
}
}
}
}Python agent with Brain memory
import anthropic, os
client = anthropic.Anthropic()
# Brain MCP server — memory persists across every run
server_params = {
"command": "npx",
"args": ["-y", "@cachly-dev/mcp-server@latest"],
"env": {
"CACHLY_JWT": os.environ["CACHLY_JWT"],
"CACHLY_BRAIN_INSTANCE_ID": os.environ["CACHLY_BRAIN_INSTANCE_ID"],
},
}
with client.beta.messages.stream(
model="claude-opus-4-5",
max_tokens=4096,
tools=[{"type": "mcp", "server": server_params}],
messages=[{
"role": "user",
"content": "Fix the flaky Stripe webhook test. Check what worked before first.",
}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
# The agent automatically:
# 1. Calls recall_best_solution("fix:stripe-webhook") before writing code
# 2. Calls learn_from_attempts(...) after the fix — stored foreverCore Brain tools for agents
recall_best_solution(topic)Most impactfulBefore attempting a task, retrieve the best known solution. Returns what worked, what failed, exact commands, and severity.
learn_from_attempts(...)After every runStore what the agent learned — outcome, approach, commands, file paths. Retrieved by all future agent runs automatically.
smart_recall(query)Semantic searchNatural language search over all stored lessons. E.g. 'docker healthcheck IPv6 error' returns the relevant fix instantly.
remember_context(key, value)StatePersist arbitrary agent state between runs. E.g. last processed record ID, config values, intermediate results.
recall_context(key)StateRetrieve stored context by key. Supports glob patterns (e.g. file:*) for namespace retrieval.
Framework compatibility
Free tier included · No credit card