feat: tao-mcp-go core features

This commit is contained in:
OpenClaw Agent
2026-03-14 16:09:09 +08:00
parent ebaf325222
commit a9c26fae45
7 changed files with 1604 additions and 0 deletions

182
README.md Normal file
View File

@@ -0,0 +1,182 @@
# Tao Memory MCP Server (Go)
面向 MCP 的“道场记忆”服务SSE + JSONRPC 2.0,支持移动端、异步响应、灵感/日记/周月季半年年炼化与归档剪枝。
---
## 功能总览
- **MCP 协议**SSE + `/mcp/message` 异步响应POST 返回 202
- **鉴权**Header Bearer 或 `?token=`
- **工具体系**:检索、灵感、日记、周/月/季/半年/年总结、归档剪枝、代码巡检提案
- **存储结构**六级流转YEAR/H1|H2/Q/Month/Wxx
- **归档剪枝**:月度归档至 `_Archive`,检索默认跳过归档
---
## 目录结构(六级流转)
```
knowledge_ocean/
2026/
H1_Upper/
Q1/
03_March/
W11/
2026-03-14_Saturday.md
Week_Summary.md
Month_Summary.md
Semiannual_Summary.md
H2_Lower/
...
Year_Summary.md
Inspirations/
Idea_1710400000.md
_Archive/
2026/03/...
_Proposals/
proposal_20260314_150405.md
```
---
## MCP 端点
- **SSE**`/mcp/sse?token=...`
- **消息**`/mcp/message?token=...`
**特性:**
- `POST /mcp/message` 只返回 `202 Accepted`
- 所有 JSONRPC 响应通过 SSE `event: message` 返回
- CORS 已放行(含 `OPTIONS`
---
## 工具清单
### 1) query_memory
全文检索(默认不搜索归档)
- `q` (string)
- `mode` (exact|causal, 默认 exact)
- `related_terms` (array<string>) 仅 mode=causal
- `include_archive` (bool, 默认 false)
**causal 输出标注:** `[命中: 关键词]` / `[关联: 关键词]`
---
### 2) get_week_data / record_summary
- `get_week_data(weekOffset)`:获取周素材
- `record_summary(content, weekOffset)`:写入 `Week_Summary.md`
- 若缺少 `### 📅 时空坐标`,自动套“炼丹笔记”模板
---
### 3) capture_idea
捕获灵感并**双写**
- 写入 `Inspirations/Idea_*.md`YAML Frontmatter + tags
- 同时写入当天日记category=idea
参数:
- `content` (string)
- `tags` (array<string>, 可选;默认 Unsorted)
---
### 4) record_daily
写入当日日记(不会进入灵感库)
参数:
- `content` (string)
- `karma` (int, 默认 1)
---
### 5) 月/季/半年/年炼化
- `get_month_data` / `record_month_summary`
- `get_quarter_data` / `record_quarter_summary`
- `get_semiannual_data` / `record_semiannual_summary`
- `get_year_data` / `record_year_summary`
产物:
- `Month_Summary.md`
- `Quarter_Summary.md`
- `Semiannual_Summary.md`
- `Year_Summary.md`
---
### 6) housekeep_memory
归档剪枝(按月)
参数:
- `target_month` (YYYY-MM)
逻辑:
- 校验 `Month_Summary.md` 存在且大小≥100字节且包含 `###`
- 将该月 `Wxx/` 目录及非 Month_Summary 文件移动到 `_Archive/YYYY/MM/`
- 生成 `ARCHIVED.txt`
- `query_memory` 默认跳过 `_Archive`
---
### 7) inspect_and_propose
检视代码与灵感,生成补丁建议清单(不自动应用)
参数:
- `repo_path` (可选,默认 `/root/.openclaw/workspace/tao_mcp_go`)
行为:
- `git pull`(失败不阻断)
- 扫描 `Inspirations``#Todo/#Fix`
- 生成 `_Proposals/proposal_<timestamp>.md`
- 当日日记记录摘要
---
## OpenClaw 接入(示例)
**Base URL**
```
https://mcp.good.xx.kg
```
**Auth Token**
```
a3c60a86ed2a7d317b8855faa94a05d1
```
**Instructions粘贴**
```
你接入的 MCP 服务器名为 Tao-Memory-Pro。
调用工具时遵循以下规则:
1) 重要灵感/架构设计 → 使用 capture_idea可带 tags
2) 日常记录/普通对话 → 使用 record_daily
3) 周总结使用 record_summary自动套用炼丹模板
4) 检索默认 query_memory需要查归档时 include_archive=true
```
---
## 编译与运行
```bash
cd /root/.openclaw/workspace/tao_mcp_go
go build -o tao-mcp
./tao-mcp
```
## Systemd
```bash
systemctl restart tao-mcp-go
systemctl status tao-mcp-go
```
---
## 备注
- SSE 已设置 `X-Accel-Buffering: no`
- MCP 协议版本:`2025-06-18`
- `TAO_ENDPOINT_STYLE=message` 避免 `/mcp/mcp` 叠加