spherical-memory-mcp
This server provides a spatially-organized, gravity-linked AI memory system that stores, retrieves, and manages memories in a 3D spherical coordinate space with human-like forgetting and associative recall.
Store Memories (
tool_store_memory): Save memory nodes with rich metadata including content, type (coding, creation, discussion, planning, emotion, life, learning), emotional intensity/type, personality relevance, semantic tags (3-8 required), and event associations.Gravity-Based Associative Recall (
tool_recall_by_gravity): Retrieve related memories by spreading activation through gravity links from a natural language query — the core differentiating feature for deep associative search.Coordinate-Based Precise Recall (
tool_recall_by_coordinate): Look up memories using exact filters like memory type, event ID, time range, or keyword, with configurable sorting (by time or quality/mass).Register Events (
tool_register_event): Create named event anchors (e.g., a project, trip, or topic) with optional parent-child hierarchy, serving as organizational axes in the memory space.Manually Link Memories (
tool_link_memories): Explicitly create gravity links between two memory nodes with a specified link type (semantic, emotional, or causal) and optional strength override.View Memory Statistics (
tool_get_memory_stats): Get an overview including total memory count, type distribution, high-mass nodes, recent memories, and decay status.Trigger Memory Decay (
tool_decay_memories): Apply a forgetting mechanism that reduces the quality/mass of memories over time without deleting them, allowing strong links to later reactivate them.Conversation Heartbeat (
tool_conversation_heartbeat): Track conversation turns and signal when memory consolidation (batch store) should occur, based on a configurable interval (default every 3 turns).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@spherical-memory-mcp store my idea for a mobile app"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
球状网络标签记忆体系 — MCP Server
一个基于三维球坐标与引力链接的 AI Agent 记忆插件,实现了"球状网络标签记忆体系"论文的核心构想。
任何支持 MCP(Model Context Protocol)的 LLM Agent,接入此插件后即可获得:
空间化记忆存储:每条记忆在闭合球状空间中有唯一的坐标位置
引力联想检索:记忆之间通过语义/情感/因果关联引力自组织为网络
类人遗忘机制:记忆衰减但不删除,可被强关联唤醒
🫀 对话心跳:自动追踪轮次,定时触发记忆固化
快速开始
安装
# 开发安装(推荐)
git clone <this-repo>
cd spherical-memory-mcp
pip install -e .配置到 Agent
WorkBuddy
编辑 ~/.workbuddy/mcp.json:
{
"mcpServers": {
"spherical-memory": {
"command": "/path/to/python",
"args": ["-m", "spherical_memory.server"],
"description": "球状网络标签记忆体系"
}
}
}然后在连接器管理中启用(需要点击 信任)。
Claude Desktop
编辑 Claude Desktop 的 MCP 配置:
{
"mcpServers": {
"spherical-memory": {
"command": "python",
"args": ["-m", "spherical_memory.server"]
}
}
}通用 MCP 客户端
任何支持 MCP stdio 协议的客户端,配置 command + args 同上即可。
Related MCP server: Memsolus MCP Server
工具总览
工具 | 用途 | 调用时机 |
| 存储记忆节点 | 有意义交互后 |
| 引力联想检索 | 用户提及话题时 |
| 坐标精确查询 | 知道时间/类型/事件时 |
| 注册事件锚点 | 新项目/话题出现时 |
| 手动建立引力链接 | 发现深层关联时 |
| 查看记忆概况 | 了解记忆全景 |
| 执行遗忘衰减 | 每 24 小时 |
| 🫀 对话心跳 | 每轮对话结束时 |
🫀 对话心跳机制
每个接入此插件的 Agent 应在每轮对话结束时调用 tool_conversation_heartbeat。
心跳工具自动追踪轮次计数,按配置的间隔(默认每 3 轮)返回 consolidate: true。此时 Agent 应回顾本轮对话的关键信息,批量调用 store_memory 写入球状空间。
对话流程:
第1轮 → heartbeat → consolidate: false
第2轮 → heartbeat → consolidate: false
第3轮 → heartbeat → consolidate: true ← 批量 store_memory
第4轮 → heartbeat → consolidate: false
...可通过环境变量 SM_HEARTBEAT_INTERVAL 调整间隔(默认 3)。
记忆写入原则
该存什么
✅ 用户分享的重要事实、决定、偏好
✅ Agent 做出的关键决策及其理由
✅ 有情感价值的互动
✅ 新知识的习得
✅ 项目进展的里程碑
不该存什么
❌ 日常问候、简单确认
❌ 重复信息
❌ 临时性技术细节
标签是引力链接的生命线
每条 store_memory 必须提供 3–8 个精准的 semantic_tags。标签质量直接决定引力检索效果。
"用户决定辞去大厂工作开始创业" → ["辞职", "创业", "大厂", "职业转型", "勇气"]语义相似度引擎
当前默认使用 Jaccard 标签重叠(零外部依赖,速度快),但存在颗粒度瓶颈——语义相近但文字不同的标签(如"论文"vs"学术写作")Jaccard = 0。
预留了可插拔引擎接口(services/similarity.py),后续接入 bge-small-zh embedding 后,语义相似度将从"精确匹配"升级为"向量余弦",引力链接质量将质的飞跃。
⚠️ EmbeddingSimilarityEngine 当前尚未实现(规划中,欢迎贡献)。目前唯一切换方式是替换为其他
SimilarityEngine的实现类。# 未来切换方式(规划中): # from spherical_memory.services.similarity import set_similarity_engine, EmbeddingSimilarityEngine # set_similarity_engine(EmbeddingSimilarityEngine(model="BAAI/bge-small-zh-v1.5"))
配置项
环境变量 | 默认值 | 说明 |
|
| 数据库路径 |
| 3 | 心跳固化间隔(轮) |
| 0.3 | 引力链接建立阈值 |
| 0.6 | 引力检索激活阈值 |
| 0.95 | 记忆衰减系数 |
| false | 是否启用 embedding 引擎 |
架构
src/spherical_memory/
├── server.py # FastMCP Server 入口,8 个工具注册
├── config.py # 全局配置
├── db/
│ ├── schema.py # 5 张表 + 索引
│ └── connection.py # SQLite 连接管理(WAL 模式)
├── models/
│ ├── memory.py # MemoryNode
│ ├── event.py # Event
│ └── gravity_link.py # GravityLink
└── services/
├── memory_service.py # 记忆 CRUD + 球坐标计算
├── event_service.py # 事件管理
├── gravity_service.py # 引力计算 + 链接建立
├── recall_service.py # 引力扩散 + 坐标检索
├── decay_service.py # 质量衰减 + 唤醒
├── heartbeat_service.py # 🫀 对话心跳
└── similarity.py # 可插拔语义引擎接口核心理念
Agent的记忆体系,不应当是传统的数据库格式。Agent作为强交互载体,其记忆的录入及读取方式应更类人,这样在双方的交互中才能让自然语言有更高效率。
详见配套论文《球状网络标签记忆体系》。
Available Tools
8 toolstool_conversation_heartbeatA
对话心跳 — 追踪轮次并自动触发记忆固化。
🫀 每轮对话结束时调用此工具。它会自动统计轮次数,在达到配置的间隔时返回 consolidate=true,提示你应该执行一次记忆固化(批量 store_memory)。
返回: turn_count: 当前总轮次 consolidate: 是否应该执行记忆固化(批量写入 store_memory) turns_since_consolidation: 距上次固化已过轮数 next_consolidation_at: 下次触发固化的轮次
Inputs: no named parameters.
tool_decay_memoriesA
执行一轮记忆质量衰减(遗忘机制)。
低质量记忆会沉降但不删除,未来可被强引力链接唤醒。 建议定期调用(如每24小时或每100轮对话),而非每次对话都调用。
参数: decay_rate: 每轮衰减系数(可选,默认0.95)。0.95表示每条衰减记忆的质量乘以0.95 batch_size: 每轮处理的记忆数上限(可选,默认100)
Inputs: decay_rate, batch_size.
tool_get_memory_statsA
查看记忆空间的整体状况。
包含总记忆数、类型分布、大质量节点、最近记忆、衰减状态等。 在对话开始时了解记忆全景,或用户问"你记得多少东西?"时调用。
参数: detail_level: 详细程度(可选,默认summary)。可选:summary(概要)、detailed(详细)
Inputs: detail_level.
tool_link_memoriesA
手动为两条记忆建立引力链接,补充自动计算的不足。
当你在对话中识别到两条记忆存在明确的深层关联时调用。自动算法遗漏的因果/类比/对照关系,由此工具补充。 手动建立的链接权重高于自动链接。
参数: source_id: 源记忆ID(必填) target_id: 目标记忆ID(必填) link_type: 链接类型(必填)。可选:semantic(语义相关)、emotion(情感共鸣)、causal(因果关联) strength_override: 手动指定关联因子 0-1(可选)。不提供则自动计算
Inputs: source_id (required), target_id (required), link_type (required), strength_override.
tool_recall_by_coordinateA
坐标精确查询 — 通过时间/类型/事件三轴交叉定位记忆。
当用户明确指定了时间范围或类型时使用。适合精确查找,不适合联想检索。
参数: memory_type: 精确匹配记忆类型(可选)。可选值同 store_memory event_id: 精确匹配事件ID(可选) time_range: 时间范围(可选)。格式:{"from": "2025-06-01", "to": "2025-12-31"} keyword: 内容关键词(可选),用于全文搜索 limit: 返回数量上限(可选,默认10,上限20) sort_by: 排序方式(可选,默认time_desc)。可选:time_desc(时间倒序)、time_asc(时间正序)、mass_desc(质量降序)
Inputs: memory_type, event_id, time_range, keyword, +2 more.
tool_recall_by_gravityA
【核心工具】引力联想检索 — 从入口节点沿引力链接扩散,激活相关联的记忆。
这是球状记忆体系最核心的差异化能力。当用户提到某个话题、需要联想回忆、或说"你还记得..."时,优先使用此工具。
参数: query: 查询描述文本(必填)。纯自然语言,如"用户又提到了辞职的想法" query_tags: 从 query 中提取的关键标签(必填!)。❌ 必填!MCP Server 无推理能力,必须由你从 query 中提取核心概念作为标签。示例:用户说"我又想辞职了" → 提取 ["辞职", "职业", "决定"] max_activations: 最大激活记忆数(可选,默认8,上限8) gravity_threshold: 引力阈值(可选,默认0.6)。低于此值的链接不会被激活。需要更宽泛联想时降至0.4,需要精确匹配时升至0.8 memory_type_filter: 限制记忆类型范围(可选) time_range: 时间范围(可选)。格式:{"from": "2025-06-01", "to": "2025-12-31"} depth: 引力扩散深度(可选,默认2,上限3)。深度越大召回越多但噪声也越多
Inputs: query (required), query_tags (required), max_activations, gravity_threshold, +3 more.
tool_register_eventA
注册一个新事件到事件空间,自动分配极角坐标。
对话中出现新的项目、任务、话题等独立事件线索时调用。Agent 应主动识别事件边界,而非被动等用户声明。 例如:"我们开始开发一个新功能" → 注册事件"XX功能开发";"换个话题,聊聊你的童年" → 注册事件"童年回忆"
参数: event_name: 事件名称(必填)。简洁明确,如"川西旅行"、"Python课程开发"、"辞职与转行" parent_event_id: 父事件ID(可选)。用于创建子事件 description: 事件描述(可选)
Inputs: event_name (required), parent_event_id, description.
tool_store_memoryA
存储一条新记忆到球状记忆空间。
每次对话产生值得记住的信息时调用此工具。应在对话自然停顿点(如完成一个话题时)批量调用,而非逐句调用。
参数: content: 记忆内容全文(必填) memory_type: 一级类型(必填)。可选值:coding(编码开发)、creation(内容创作)、discussion(讨论交流)、planning(规划决策)、emotion(情感陪伴)、life(生活记录)、learning(知识学习) event_ids: 所属事件ID列表,最多3个。不提供则挂在默认事件上 personality_match: 此记忆与 Agent 人格核心的匹配度 0-1(可选,默认0.5)。0=与人格无关,1=高度相关 emotion_intensity: 情感强度 0-1(可选,默认0.3)。0=完全中性,1=极度强烈的情感冲击 emotion_type: 情感类型(可选,默认neutral)。可选值:joy(喜悦)、sadness(悲伤)、anger(愤怒)、fear(恐惧)、surprise(惊讶)、disgust(厌恶)、trust(信任)、anticipation(期待)、neutral(中性) semantic_tags: 语义标签列表(强烈建议提供,3-8个精准关键词)。❌ 不提供会导致引力检索效果极差!标签是引力链接的生命线。推荐:["项目名", "核心概念", "关键实体"] summary: 记忆摘要(可选)。不提供则自动截取前100字 sub_type: 二级子类型(可选)。如 coding.bugfix, creation.writing 等
Inputs: content (required), memory_type (required), event_ids, personality_match, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a specific aspect of memory management: heartbeat for timing, decay for forgetting, stats for overview, link for associations, two recall methods for different search styles, event registration, and memory storage. No overlap in purposes.
All tool names follow a consistent 'tool_' prefix with a clear verb_noun or verb_preposition_noun pattern (e.g., store_memory, recall_by_gravity). The naming convention is uniform and predictable.
With 8 tools, the server is well-scoped for a memory system. It covers creation, retrieval in two modes, linking, decay, statistics, event management, and session tracking without being overwhelming or sparse.
The tool set covers core operations but lacks explicit update or delete tools for memories/events. The decay tool handles forgetting, but direct modifications are absent, which could limit certain workflows.
Related MCP Connectors
Memory system for AI agents with semantic search. Store and recall memories with ease.
Shared long-term memory for AI agents: save and recall context as a searchable knowledge graph.
Long-term memory for AI agents: hybrid vector and full-text recall, rooms, time-travel.
Persistent memory and knowledge graphs for AI agents. Hybrid search, context checkpoints, and more.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenancePersistent memory for AI agents — organized by time and space. Important memories get promoted, noise decays naturally, and related knowledge clusters into a browsable topic tree. Fully automatic.28MIT

Memsolus MCP Serverofficial
AlicenseAqualityDmaintenanceProvides persistent long-term memory for AI agents through semantic search and automated knowledge graph extraction. It enables agents to store, recall, and reason over facts, preferences, and relationships across multiple conversations and sessions.146 npmMIT- AlicenseNot gradedqualityDmaintenanceProvides persistent long-term memory for AI agents with semantic search and activation-based decay. Enables AI systems to remember across sessions through layered memory architecture and automatic context-aware retrieval.MIT
- AlicenseAqualityDmaintenanceEnables AI agents with persistent semantic memory, including semantic recall, knowledge graphs, and instant domain expertise via pre-built Intelligence Packs.1052 npmMIT