mindcore-memory 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mindcore_memory-0.1.0/.github/workflows/ci.yml +64 -0
- mindcore_memory-0.1.0/.gitignore +12 -0
- mindcore_memory-0.1.0/LICENSE +21 -0
- mindcore_memory-0.1.0/PKG-INFO +217 -0
- mindcore_memory-0.1.0/README.md +189 -0
- mindcore_memory-0.1.0/examples/basic_usage.py +72 -0
- mindcore_memory-0.1.0/pyproject.toml +58 -0
- mindcore_memory-0.1.0/server.json +17 -0
- mindcore_memory-0.1.0/src/__init__.py +13 -0
- mindcore_memory-0.1.0/src/eval_framework.py +353 -0
- mindcore_memory-0.1.0/src/http_app.py +118 -0
- mindcore_memory-0.1.0/src/memory_engine.py +369 -0
- mindcore_memory-0.1.0/src/server.py +334 -0
- mindcore_memory-0.1.0/tests/test_memory.py +124 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
pip install -e ".[dev]"
|
|
27
|
+
|
|
28
|
+
- name: Run tests with coverage
|
|
29
|
+
run: |
|
|
30
|
+
pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=xml
|
|
31
|
+
|
|
32
|
+
- name: Run eval framework
|
|
33
|
+
run: |
|
|
34
|
+
python -m mindcore_memory.eval_framework
|
|
35
|
+
|
|
36
|
+
- name: Lint with ruff
|
|
37
|
+
run: |
|
|
38
|
+
ruff check src/ tests/
|
|
39
|
+
|
|
40
|
+
- name: Type check with mypy
|
|
41
|
+
run: |
|
|
42
|
+
mypy src/ --ignore-missing-imports
|
|
43
|
+
|
|
44
|
+
build:
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
needs: test
|
|
47
|
+
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
|
|
51
|
+
- name: Set up Python
|
|
52
|
+
uses: actions/setup-python@v5
|
|
53
|
+
with:
|
|
54
|
+
python-version: "3.12"
|
|
55
|
+
|
|
56
|
+
- name: Build package
|
|
57
|
+
run: |
|
|
58
|
+
pip install build
|
|
59
|
+
python -m build
|
|
60
|
+
|
|
61
|
+
- name: Verify build
|
|
62
|
+
run: |
|
|
63
|
+
pip install dist/*.whl
|
|
64
|
+
python -c "from mindcore_memory import MemoryEngine; print('Import OK')"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 woshilaohei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mindcore-memory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP Server for AI long-term memory and context management
|
|
5
|
+
Author-email: woshilaohei <1410770089@qq.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: agent,ai,context,llm,mcp,memory
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: json-rpc>=1.5.0
|
|
17
|
+
Requires-Dist: mcp[cli]>=1.0.0
|
|
18
|
+
Requires-Dist: pydantic>=2.0.0
|
|
19
|
+
Requires-Dist: structlog>=24.0.0
|
|
20
|
+
Requires-Dist: tinydb>=4.8.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=1.9.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff>=0.3.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# 🧠 MindCore Memory MCP
|
|
30
|
+
|
|
31
|
+
**让 AI 记住一切,不再遗忘。生产级长期记忆 MCP Server。**
|
|
32
|
+
|
|
33
|
+
> "The best AI agent isn't the smartest — it's the one that remembers."
|
|
34
|
+
|
|
35
|
+
[](https://github.com/woshilaohei/mindcore-memory-mcp/stargazers)
|
|
36
|
+
[](https://opensource.org/licenses/MIT)
|
|
37
|
+
[](https://python.org)
|
|
38
|
+
|
|
39
|
+
## ⚡ 一句话价值
|
|
40
|
+
|
|
41
|
+
**MindCore Memory** 解决 AI Agent 最大痛点:上下文窗口有限、长对话信息丢失、跨session记忆断裂。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 🎯 解决什么问题
|
|
46
|
+
|
|
47
|
+
| 痛点 | 现状 | MindCore Memory |
|
|
48
|
+
|------|------|----------------|
|
|
49
|
+
| AI 上下文忘性大 | 对话结束什么都忘 | ✅ 持久化长期记忆 |
|
|
50
|
+
| 跨session无法回忆 | 每次都重新教 | ✅ 跨会话知识复用 |
|
|
51
|
+
| 记忆混乱无优先级 | 所有记忆权重一样 | ✅ 重要性分级+置信度 |
|
|
52
|
+
| RAG暴力灌入 | 上下文过载质量下降 | ✅ 精准上下文窗口 |
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 🚀 3行上手
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1. 安装
|
|
60
|
+
pip install mindcore-memory
|
|
61
|
+
|
|
62
|
+
# 2. 启动 MCP Server
|
|
63
|
+
mindcore-memory
|
|
64
|
+
|
|
65
|
+
# 3. 在你的 AI Agent 中调用
|
|
66
|
+
memory_id = memory_store("用户说他叫张三,周三有空")
|
|
67
|
+
context = memory_recall("用户的时间安排")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 📊 Eval Framework 实测
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
✅ Storage Integrity: 100% (存储持久化正确)
|
|
76
|
+
✅ Recall Relevance: 100% (相关记忆优先召回)
|
|
77
|
+
✅ Confidence Calibration: 100% (置信度正确校准)
|
|
78
|
+
✅ Importance Weighting: 100% (高优先级记忆排名靠前)
|
|
79
|
+
✅ Context Efficiency: 100% (上下文窗口不过载)
|
|
80
|
+
|
|
81
|
+
Overall Score: 100%
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🔧 核心工具
|
|
87
|
+
|
|
88
|
+
### `memory_store` - 存储记忆
|
|
89
|
+
```python
|
|
90
|
+
memory_store(
|
|
91
|
+
content="Python是荷兰人Guido van Rossum创建的",
|
|
92
|
+
importance=3, # 1-4级重要性
|
|
93
|
+
tags=["python", "history"],
|
|
94
|
+
confidence=0.95, # 置信度
|
|
95
|
+
source="agent" # agent/user/tool
|
|
96
|
+
)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### `memory_recall` - 召回记忆
|
|
100
|
+
```python
|
|
101
|
+
memory_recall(
|
|
102
|
+
query="Python创始人是谁",
|
|
103
|
+
tags=["python"], # 可选标签过滤
|
|
104
|
+
limit=10 # 返回数量
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `memory_context` - 构建上下文窗口
|
|
109
|
+
```python
|
|
110
|
+
# 为当前任务构建最优上下文(自动去重+优先级排序)
|
|
111
|
+
context = memory_context(
|
|
112
|
+
query="当前项目状态",
|
|
113
|
+
max_tokens=2000 # 自动截断
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### `memory_stats` - 系统状态
|
|
118
|
+
```python
|
|
119
|
+
# 查看记忆统计:总数/分布/置信度
|
|
120
|
+
stats = memory_stats()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 💰 定价
|
|
126
|
+
|
|
127
|
+
| 方案 | 价格 | 能力 |
|
|
128
|
+
|------|------|------|
|
|
129
|
+
| **Free** | $0/月 | 100次存储/天 |
|
|
130
|
+
| **Pro** | $25/月 | 无限次 + 优先队列 |
|
|
131
|
+
| **Enterprise** | $99/月 | 私有部署 + SLA |
|
|
132
|
+
|
|
133
|
+
**[→ 获取 API Key](https://github.com/woshilaohei/mindcore-memory-mcp/wiki/API-Key)**
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 🏗️ 项目结构
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
mindcore-memory-mcp/
|
|
141
|
+
├── src/
|
|
142
|
+
│ ├── memory_engine.py # 核心记忆引擎
|
|
143
|
+
│ ├── server.py # MCP Server(stdio+HTTP双传输)
|
|
144
|
+
│ ├── http_app.py # HTTP端点(生产部署)
|
|
145
|
+
│ └── eval_framework.py # 评测框架
|
|
146
|
+
├── tests/
|
|
147
|
+
│ └── test_memory.py # 单元测试
|
|
148
|
+
├── .github/workflows/
|
|
149
|
+
│ └── ci.yml # CI/CD
|
|
150
|
+
├── pyproject.toml
|
|
151
|
+
├── README.md
|
|
152
|
+
└── LICENSE
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🔌 集成方式
|
|
158
|
+
|
|
159
|
+
### Claude Desktop
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"mcpServers": {
|
|
163
|
+
"mindcore-memory": {
|
|
164
|
+
"command": "pip",
|
|
165
|
+
"args": ["install", "--editable", "."]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### VS Code AI
|
|
172
|
+
直接在扩展市场搜索 `MindCore Memory`。
|
|
173
|
+
|
|
174
|
+
### HTTP API(生产环境)
|
|
175
|
+
```bash
|
|
176
|
+
curl -X POST http://localhost:8080/mcp \
|
|
177
|
+
-H "Content-Type: application/json" \
|
|
178
|
+
-H "Authorization: Bearer YOUR_TOKEN" \
|
|
179
|
+
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"memory_store","arguments":{"content":"test"}},"id":1}'
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 📐 生产级标准
|
|
185
|
+
|
|
186
|
+
| 标准 | 实现 |
|
|
187
|
+
|------|------|
|
|
188
|
+
| **JSON-RPC 2.0** | ✅ stdio + HTTP 双传输 |
|
|
189
|
+
| **Bearer Token认证** | ✅ HTTP端点可选认证 |
|
|
190
|
+
| **输入验证** | ✅ Pydantic schemas |
|
|
191
|
+
| **CI/CD** | ✅ GitHub Actions |
|
|
192
|
+
| **单元测试** | ✅ pytest + 覆盖率 |
|
|
193
|
+
| **Eval Framework** | ✅ 5项核心指标 |
|
|
194
|
+
| **可观测性** | ✅ structlog完整日志 |
|
|
195
|
+
| **用户数据主权** | ✅ JSONL本地文件,无vendor lock-in |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 🤝 贡献
|
|
200
|
+
|
|
201
|
+
欢迎提交 Issue 和 PR!
|
|
202
|
+
|
|
203
|
+
## 📄 许可证
|
|
204
|
+
|
|
205
|
+
MIT License - 详见 [LICENSE](LICENSE)
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
<!-- MCP registry metadata -->
|
|
210
|
+
<!-- mcp-name: io.github.woshilaohei/mindcore-memory-mcp -->
|
|
211
|
+
<!-- mcp-registry: https://registry.modelcontextprotocol.io -->
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
<p align="center">
|
|
216
|
+
<strong>让 AI 拥有记忆,让人类更信任 AI。</strong>
|
|
217
|
+
</p>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# 🧠 MindCore Memory MCP
|
|
2
|
+
|
|
3
|
+
**让 AI 记住一切,不再遗忘。生产级长期记忆 MCP Server。**
|
|
4
|
+
|
|
5
|
+
> "The best AI agent isn't the smartest — it's the one that remembers."
|
|
6
|
+
|
|
7
|
+
[](https://github.com/woshilaohei/mindcore-memory-mcp/stargazers)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://python.org)
|
|
10
|
+
|
|
11
|
+
## ⚡ 一句话价值
|
|
12
|
+
|
|
13
|
+
**MindCore Memory** 解决 AI Agent 最大痛点:上下文窗口有限、长对话信息丢失、跨session记忆断裂。
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 🎯 解决什么问题
|
|
18
|
+
|
|
19
|
+
| 痛点 | 现状 | MindCore Memory |
|
|
20
|
+
|------|------|----------------|
|
|
21
|
+
| AI 上下文忘性大 | 对话结束什么都忘 | ✅ 持久化长期记忆 |
|
|
22
|
+
| 跨session无法回忆 | 每次都重新教 | ✅ 跨会话知识复用 |
|
|
23
|
+
| 记忆混乱无优先级 | 所有记忆权重一样 | ✅ 重要性分级+置信度 |
|
|
24
|
+
| RAG暴力灌入 | 上下文过载质量下降 | ✅ 精准上下文窗口 |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 🚀 3行上手
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. 安装
|
|
32
|
+
pip install mindcore-memory
|
|
33
|
+
|
|
34
|
+
# 2. 启动 MCP Server
|
|
35
|
+
mindcore-memory
|
|
36
|
+
|
|
37
|
+
# 3. 在你的 AI Agent 中调用
|
|
38
|
+
memory_id = memory_store("用户说他叫张三,周三有空")
|
|
39
|
+
context = memory_recall("用户的时间安排")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 📊 Eval Framework 实测
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
✅ Storage Integrity: 100% (存储持久化正确)
|
|
48
|
+
✅ Recall Relevance: 100% (相关记忆优先召回)
|
|
49
|
+
✅ Confidence Calibration: 100% (置信度正确校准)
|
|
50
|
+
✅ Importance Weighting: 100% (高优先级记忆排名靠前)
|
|
51
|
+
✅ Context Efficiency: 100% (上下文窗口不过载)
|
|
52
|
+
|
|
53
|
+
Overall Score: 100%
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🔧 核心工具
|
|
59
|
+
|
|
60
|
+
### `memory_store` - 存储记忆
|
|
61
|
+
```python
|
|
62
|
+
memory_store(
|
|
63
|
+
content="Python是荷兰人Guido van Rossum创建的",
|
|
64
|
+
importance=3, # 1-4级重要性
|
|
65
|
+
tags=["python", "history"],
|
|
66
|
+
confidence=0.95, # 置信度
|
|
67
|
+
source="agent" # agent/user/tool
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### `memory_recall` - 召回记忆
|
|
72
|
+
```python
|
|
73
|
+
memory_recall(
|
|
74
|
+
query="Python创始人是谁",
|
|
75
|
+
tags=["python"], # 可选标签过滤
|
|
76
|
+
limit=10 # 返回数量
|
|
77
|
+
)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### `memory_context` - 构建上下文窗口
|
|
81
|
+
```python
|
|
82
|
+
# 为当前任务构建最优上下文(自动去重+优先级排序)
|
|
83
|
+
context = memory_context(
|
|
84
|
+
query="当前项目状态",
|
|
85
|
+
max_tokens=2000 # 自动截断
|
|
86
|
+
)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `memory_stats` - 系统状态
|
|
90
|
+
```python
|
|
91
|
+
# 查看记忆统计:总数/分布/置信度
|
|
92
|
+
stats = memory_stats()
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## 💰 定价
|
|
98
|
+
|
|
99
|
+
| 方案 | 价格 | 能力 |
|
|
100
|
+
|------|------|------|
|
|
101
|
+
| **Free** | $0/月 | 100次存储/天 |
|
|
102
|
+
| **Pro** | $25/月 | 无限次 + 优先队列 |
|
|
103
|
+
| **Enterprise** | $99/月 | 私有部署 + SLA |
|
|
104
|
+
|
|
105
|
+
**[→ 获取 API Key](https://github.com/woshilaohei/mindcore-memory-mcp/wiki/API-Key)**
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🏗️ 项目结构
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
mindcore-memory-mcp/
|
|
113
|
+
├── src/
|
|
114
|
+
│ ├── memory_engine.py # 核心记忆引擎
|
|
115
|
+
│ ├── server.py # MCP Server(stdio+HTTP双传输)
|
|
116
|
+
│ ├── http_app.py # HTTP端点(生产部署)
|
|
117
|
+
│ └── eval_framework.py # 评测框架
|
|
118
|
+
├── tests/
|
|
119
|
+
│ └── test_memory.py # 单元测试
|
|
120
|
+
├── .github/workflows/
|
|
121
|
+
│ └── ci.yml # CI/CD
|
|
122
|
+
├── pyproject.toml
|
|
123
|
+
├── README.md
|
|
124
|
+
└── LICENSE
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## 🔌 集成方式
|
|
130
|
+
|
|
131
|
+
### Claude Desktop
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"mindcore-memory": {
|
|
136
|
+
"command": "pip",
|
|
137
|
+
"args": ["install", "--editable", "."]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### VS Code AI
|
|
144
|
+
直接在扩展市场搜索 `MindCore Memory`。
|
|
145
|
+
|
|
146
|
+
### HTTP API(生产环境)
|
|
147
|
+
```bash
|
|
148
|
+
curl -X POST http://localhost:8080/mcp \
|
|
149
|
+
-H "Content-Type: application/json" \
|
|
150
|
+
-H "Authorization: Bearer YOUR_TOKEN" \
|
|
151
|
+
-d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"memory_store","arguments":{"content":"test"}},"id":1}'
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 📐 生产级标准
|
|
157
|
+
|
|
158
|
+
| 标准 | 实现 |
|
|
159
|
+
|------|------|
|
|
160
|
+
| **JSON-RPC 2.0** | ✅ stdio + HTTP 双传输 |
|
|
161
|
+
| **Bearer Token认证** | ✅ HTTP端点可选认证 |
|
|
162
|
+
| **输入验证** | ✅ Pydantic schemas |
|
|
163
|
+
| **CI/CD** | ✅ GitHub Actions |
|
|
164
|
+
| **单元测试** | ✅ pytest + 覆盖率 |
|
|
165
|
+
| **Eval Framework** | ✅ 5项核心指标 |
|
|
166
|
+
| **可观测性** | ✅ structlog完整日志 |
|
|
167
|
+
| **用户数据主权** | ✅ JSONL本地文件,无vendor lock-in |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🤝 贡献
|
|
172
|
+
|
|
173
|
+
欢迎提交 Issue 和 PR!
|
|
174
|
+
|
|
175
|
+
## 📄 许可证
|
|
176
|
+
|
|
177
|
+
MIT License - 详见 [LICENSE](LICENSE)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
<!-- MCP registry metadata -->
|
|
182
|
+
<!-- mcp-name: io.github.woshilaohei/mindcore-memory-mcp -->
|
|
183
|
+
<!-- mcp-registry: https://registry.modelcontextprotocol.io -->
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
<p align="center">
|
|
188
|
+
<strong>让 AI 拥有记忆,让人类更信任 AI。</strong>
|
|
189
|
+
</p>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Example: Basic usage of MindCore Memory MCP.
|
|
3
|
+
|
|
4
|
+
Run:
|
|
5
|
+
python examples/basic_usage.py
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from mindcore_memory import MemoryEngine
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
engine = MemoryEngine() # Uses ~/.mindcore/memory/
|
|
12
|
+
|
|
13
|
+
print("🧠 MindCore Memory - Basic Usage\n")
|
|
14
|
+
|
|
15
|
+
# Store important memories
|
|
16
|
+
print("📝 Storing memories...")
|
|
17
|
+
|
|
18
|
+
m1 = engine.store(
|
|
19
|
+
content="User: 张三, Company: 某科技公司, Role: 产品经理",
|
|
20
|
+
importance=4,
|
|
21
|
+
tags=["user_profile", "contact"],
|
|
22
|
+
confidence=0.98,
|
|
23
|
+
source="user",
|
|
24
|
+
)
|
|
25
|
+
print(f" ✓ Stored profile: {m1[:8]}...")
|
|
26
|
+
|
|
27
|
+
m2 = engine.store(
|
|
28
|
+
content="Project Alpha deadline is 2026-06-30, priority=high",
|
|
29
|
+
importance=4,
|
|
30
|
+
tags=["project", "deadline"],
|
|
31
|
+
confidence=0.95,
|
|
32
|
+
)
|
|
33
|
+
print(f" ✓ Stored deadline: {m2[:8]}...")
|
|
34
|
+
|
|
35
|
+
m3 = engine.store(
|
|
36
|
+
content="用户偏好:中文回复,周报用表格格式",
|
|
37
|
+
importance=3,
|
|
38
|
+
tags=["preference"],
|
|
39
|
+
confidence=0.9,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
m4 = engine.store(
|
|
43
|
+
content="I think the API might be down",
|
|
44
|
+
importance=1,
|
|
45
|
+
confidence=0.4,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
# Recall relevant memories
|
|
49
|
+
print("\n🔍 Recall test: 'deadline'")
|
|
50
|
+
results = engine.recall("deadline", limit=5)
|
|
51
|
+
for r in results:
|
|
52
|
+
print(f" [{r.relevance:.2f}] {r.memory.content[:60]}")
|
|
53
|
+
|
|
54
|
+
print("\n🔍 Recall test: 'user profile'")
|
|
55
|
+
results = engine.recall("张三", tags=["user_profile"])
|
|
56
|
+
for r in results:
|
|
57
|
+
print(f" [{r.relevance:.2f}] {r.memory.content}")
|
|
58
|
+
|
|
59
|
+
# Build context window
|
|
60
|
+
print("\n📄 Context window for '当前任务' (max_tokens=500):")
|
|
61
|
+
context = engine.get_context_window("当前任务", max_tokens=500)
|
|
62
|
+
print(context[:300] if context else "(empty)")
|
|
63
|
+
|
|
64
|
+
# System stats
|
|
65
|
+
print("\n📊 Memory Stats:")
|
|
66
|
+
stats = engine.get_stats()
|
|
67
|
+
for k, v in stats.items():
|
|
68
|
+
print(f" {k}: {v}")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
main()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mindcore-memory"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP Server for AI long-term memory and context management"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "woshilaohei", email = "1410770089@qq.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["mcp", "memory", "context", "ai", "llm", "agent"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
dependencies = [
|
|
26
|
+
"mcp[cli]>=1.0.0",
|
|
27
|
+
"pydantic>=2.0.0",
|
|
28
|
+
"tinydb>=4.8.0",
|
|
29
|
+
"json-rpc>=1.5.0",
|
|
30
|
+
"structlog>=24.0.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=8.0.0",
|
|
36
|
+
"pytest-asyncio>=0.23.0",
|
|
37
|
+
"pytest-cov>=4.0.0",
|
|
38
|
+
"ruff>=0.3.0",
|
|
39
|
+
"mypy>=1.9.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
mindcore-memory = "mindcore_memory.server:main"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
asyncio_mode = "auto"
|
|
50
|
+
testpaths = ["tests"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
line-length = 100
|
|
54
|
+
target-version = "py310"
|
|
55
|
+
|
|
56
|
+
[tool.mypy]
|
|
57
|
+
python_version = "3.10"
|
|
58
|
+
strict = true
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
|
|
3
|
+
"name": "io.github.woshilaohei/mindcore-memory-mcp",
|
|
4
|
+
"title": "MindCore Memory",
|
|
5
|
+
"description": "Long-term memory for AI agents. Supports emergent engine + causal reasoning + boundary system.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"packages": [
|
|
8
|
+
{
|
|
9
|
+
"registryType": "pypi",
|
|
10
|
+
"identifier": "mindcore-memory",
|
|
11
|
+
"version": "0.1.0",
|
|
12
|
+
"transport": {
|
|
13
|
+
"type": "stdio"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|