cf-memory
CF Memory Plugin
适用于每个 AI 编码代理和 LLM 框架的 Cloudflare Agent Memory。
基于 Cloudflare Agent Memory 为你的代理提供持久化、跨会话的记忆——这是一项托管服务,负责处理召回、事实提取和画像摘要。无需自行运行向量数据库,无需管理嵌入,也无需部署 Worker。
适用对象
AI 编码代理(Claude Code、Codex、Cursor、Hermes、OpenClaw、TRAE、OpenCode、pi)需要跨会话记住上下文
LLM 框架(LangChain、LangGraph)构建带持久记忆的代理
MCP 客户端(任何支持 Model Context Protocol 的工具)
代理到代理系统,使用 A2A 协议
任何人,只要想为自己的 AI 代理获得一个简单、托管的记忆后端
功能
能力 | 描述 |
记忆 | 存储事实、指令、事件——CF 会自动分类 |
召回 | 语义检索并生成综合答案(不仅仅是原始匹配) |
摄取 | 输入对话回合——CF 会提取事实/事件/指令/任务 |
摘要 | 自动生成所有已存储内容的 Markdown 画像 |
命名空间 | 按应用、用户或环境隔离记忆 |
快速上手(任意代理)
pip install git+https://github.com/hansakoch/cf-memory-plugin.git
# Set credentials
export MCP_CLOUDFLARE_API_KEY="your-cf-api-token"
export CF_ACCOUNT_ID="your-account-id"
# Test it works
cf-memory test集成
MCP 客户端(通用)
适用于任何支持 MCP 的客户端:Claude Desktop、Cursor、Windsurf、Continue、Zed 等。
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}公开的工具: remember、recall、list_memories、get_memory、delete_memory、ingest、summary、list_namespaces、create_namespace、delete_namespace
Hermes
通过 pip 入口点自动发现。无需复制任何文件。
# Install
pip install git+https://github.com/hansakoch/cf-memory-plugin.git
# Activate
hermes config set memory.provider cloudflare-memory
# Verify
hermes memory status
# Management
hermes cloudflare-memory status
hermes cloudflare-memory test
hermes cloudflare-memory namespaces
hermes cloudflare-memory cardHermes 获得的能力:
prefetch()— 0ms(缓存 + 后台召回)sync_turn()— 0ms(守护线程摄取)6 个代理工具:
cf_remember、cf_recall、cf_list、cf_get、cf_summary、cf_deleteon_session_end— 自动摄取整个会话以进行事实提取系统提示词注入,附带提供方状态
Claude Code
在项目中的 .claude/mcp.json 中添加:
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}或全局添加:claude mcp add cf-memory -- cf-memory serve
Codex(OpenAI)
添加到 ~/.codex/config.toml:
[mcp_servers.cf-memory]
command = "cf-memory"
args = ["serve"]
env = { MCP_CLOUDFLARE_API_KEY = "your-token", CF_ACCOUNT_ID = "your-account-id" }Cursor
在项目中的 .cursor/mcp.json 中添加:
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}OpenClaw
添加到你的 OpenClaw 配置中:
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}TRAE / TRAE CN / TraeCode CLI 2.0
在 TRAE 设置中或 .trae/mcp.json 中添加 MCP 服务器:
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}OpenCode
添加到 ~/.opencode/config.json:
{
"mcp": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID": "your-account-id"
}
}
}
}pi
将 MCP 服务器添加到 pi 配置中:
{
"mcpServers": {
"cf-memory": {
"command": "cf-memory",
"args": ["serve"],
"env": {
"MCP_CLOUDFLARE_API_KEY": "your-token",
"CF_ACCOUNT_ID = "your-account-id"
}
}
}
}Agent Plugins 1.0
以插件方式安装:
pip install git+https://github.com/hansakoch/cf-memory-plugin.git该包通过 hermes_agent.memory_providers 入口点注册。任何兼容 Agent Plugins 1.0 的主机都会自动发现它。
LangChain / LangGraph
import asyncio
from cloudflare_memory import CloudflareMemoryClient
# Use as a memory backend in your LangChain/LangGraph agent
client = CloudflareMemoryClient(
account_id="your-account-id",
api_token="your-token",
namespace="my-agent",
profile="user-123",
)
# Store a fact
entry = asyncio.run(client.remember("User prefers Python over JavaScript."))
# Recall
result = asyncio.run(client.recall("What programming language does the user prefer?"))
print(result.answer) # "Python"
# Ingest a conversation
asyncio.run(client.ingest([
{"role": "user", "content": "I'm building a RAG pipeline."},
{"role": "assistant", "content": "Great! Let me help with that."},
]))
# Get summary
summary = asyncio.run(client.get_summary())A2A(代理到代理)
启动 A2A 服务器,供对等代理发现并调用:
cf-memory a2a --port 9120Agent 卡片位于 http://localhost:9120/.well-known/agent.json
技能:remember、recall、ingest、list、get、summary
Python(独立使用)
import asyncio
from cloudflare_memory import CloudflareMemoryClient
async def main():
async with CloudflareMemoryClient(
account_id="your-account-id",
api_token="your-token",
namespace="my-app",
profile="default",
) as client:
# Remember
entry = await client.remember("User is based in London.")
print(f"[{entry.type}] {entry.summary}")
# Recall
result = await client.recall("Where is the user based?")
print(result.answer)
# Ingest conversation (async — memories appear 3-8s later)
await client.ingest([
{"role": "user", "content": "I prefer dark mode."},
{"role": "assistant", "content": "Noted!"},
])
# Summary
print(await client.get_summary())
asyncio.run(main())配置
环境变量
变量 | 必需 | 说明 |
| 是 | 具有 Agent Memory 权限的 Cloudflare API 令牌 |
| 否 | Cloudflare 账户 ID(默认为 Iceberg Media) |
| 否 | 命名空间名称(默认: |
| 否 | 画像名称(默认: |
获取 Cloudflare API 令牌
创建一个具有 Agent Memory 权限的令牌
你需要拥有 付费的 Workers 订阅以及 Agent Memory 的 beta 访问权限
限制(官方)
功能 | 限制 |
单次 ingest() 的消息数 | 500 |
消息内容 | 32 KB UTF-8 |
召回查询 | 1 KB UTF-8 |
会话 ID | 64 个字符 |
画像名称 | 100 个字符 |
命名空间名称 | 32 个字符 |
性能
设计上不会为你的代理的回合增加任何延迟:
操作 | 延迟 | 阻塞? |
| 0ms | 否 —— 缓存 + 后台 |
| 0ms | 否 —— 守护线程 |
| 1.3–3.8s | 用户发起 |
| ~5s | 用户发起 |
| ~0.4s | 用户发起 |
| ~0.8s | 用户发起 |
CLI 参考
# Standalone
cf-memory test # Connectivity check
cf-memory serve [--transport stdio|sse] # MCP server
cf-memory a2a [--port 9120] # A2A agent server
cf-memory card # Print agent card JSON
# Hermes plugin
hermes cloudflare-memory status # Provider status
hermes cloudflare-memory test # Full connectivity test
hermes cloudflare-memory namespaces # List namespaces
hermes cloudflare-memory create-ns NAME # Create namespace
hermes cloudflare-memory delete-ns NAME # Delete namespace
hermes cloudflare-memory card # Print agent card开发
git clone https://github.com/hansakoch/cf-memory-plugin.git
cd cloudflare-memory
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest tests/ -v许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Shared long-term memory vault for AI agents with 20 MCP tools.
Your memory, everywhere AI goes. Build knowledge once, access it via MCP anywhere.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/hansakoch/cf-memory-plugin'
If you have feedback or need assistance with the MCP directory API, please join our Discord server