Skip to main content
Glama
gwq0514

cognitive-harness-mcp

by gwq0514
README.md
---
AIGC:
  ContentProducer: '001191110102MAD55U9H0F10002'
  ContentPropagator: '001191110102MAD55U9H0F10002'
  Label: '1'
  ProduceID: '0bf1a272-39fc-4f88-8fad-189948a77516'
  PropagateID: '0bf1a272-39fc-4f88-8fad-189948a77516'
  ReservedCode1: '38e2655c-0184-453c-9751-e961162b2613'
  ReservedCode2: '38e2655c-0184-453c-9751-e961162b2613'
---

# cognitive-harness-mcp

认知 Harness 的 TeleAgent MCP Server — 让 LLM Agent 具备用户认知记忆能力。

## 能力

通过 MCP 工具为 TeleAgent 提供认知记忆中间件:

| 工具 | 说明 |
| --- | --- |
| `cognitive_search` | 按关键词/类型/生活域检索用户记忆(支持分页) |
| `cognitive_write` | 写入用户认知记忆(七类内容 × 三轴模型,自动元数据) |
| `cognitive_update` | 更新记忆字段 |
| `cognitive_forget` | 删除/版本化降级记忆 |
| `cognitive_summary` | 获取压缩认知画像(交互偏好/核心画像/分域认知/已知事实/待跟进) |
| `cognitive_stats` | 记忆统计(总量/类型分布/域分布/规则数) |
| `cognitive_list` | 列出全部记忆(分页) |

## 架构

```
cognitive-harness-mcp/
├── package.json
├── tsconfig.json
├── src/
│   ├── index.ts                  # MCP Server 入口(stdio)
│   ├── core/                    # 复用认知 Harness 核心逻辑(纯 TS,零 Cordis 依赖)
│   │   ├── index.ts
│   │   ├── types.ts             # 七类内容 × 三轴认知模型
│   │   ├── mode-types.ts
│   │   ├── events.ts
│   │   ├── store.ts             # FileMemoryStore + resolveConflict
│   │   ├── summary.ts           # SummaryService(认知摘要)
│   │   ├── recall.ts            # RecallInjector + 记忆工具接口
│   │   ├── id.ts
│   │   └── ingest.ts
│   ├── services/
│   │   └── memory-service.ts    # MemoryService(存储+摘要封装)
│   └── tools/
│       ├── registry.ts          # 工具注册助手
│       └── memory-tools.ts      # 7 个认知记忆工具
└── dist/                        # 构建产物(node dist/index.js)
```

## 构建

```bash
npm install
npm run build
```

## 部署(TeleAgent,stdio)

1. 构建:`npm run build`
2. 在 TeleAgent「工具设置 → MCP 配置」中添加以下 JSON:

```json
{
  "mcpServers": {
    "cognitive-harness": {
      "command": "node",
      "args": ["/Users/gwen/Desktop/vibe coding 项目/认知 harness/cognitive-harness-mcp/dist/index.js"]
    }
  }
}
```

3. 保存后确认 MCP 状态为「已连接」

### 环境变量(可选)

| 变量 | 说明 | 默认值 |
| --- | --- | --- |
| `COGNITIVE_MEMORY_PATH` | 记忆 JSON 文件路径 | `~/.local/share/TeleAgent/memory/cognitive-memory.json` |

## 记忆文件

记忆持久化为人类可读 JSON(默认存于 TeleAgent 记忆目录),可人工编辑/预填。格式为 `MemoryEntry[]`(见 `src/core/types.ts`)。

## 设计要点

- 规则类记忆(protocol/pragmatic)必须带**因果说明**(记"为什么"而非扁平结论)
- 支持版本化降级(`cognitive_forget` 的 degrade 模式),用户想法变了不删旧规则,降级保留证据
- 认知摘要为压缩画像,token 消耗对数增长
- 复用自研认知 Harness 核心(`认知 harness` 仓库),仅去掉 Cordis 依赖

## License

MIT

TDQS

A4.1/5.0

Scored across 7 tools

Disambiguation5/5

Each tool targets a distinct operation: search, list, stats, summary, write, update, and forget are clearly separated by purpose. Search and list both retrieve memories but are differentiated by query-based filtering versus chronological browsing.

Naming Consistency4/5

All tools share the cognitive_ prefix and mostly use verb-style names like cognitive_search, cognitive_write, and cognitive_update. The pattern is slightly weakened by noun-style names cognitive_stats and cognitive_summary, but the convention remains highly predictable.

Tool Count5/5

Seven tools is well-scoped for a memory management server: full CRUD plus search, statistics, and aggregated summary. Each tool earns its place without redundancy or bloat.

Completeness5/5

The tool surface fully covers the memory lifecycle: write, read via search/list/summary, update, and forget with both degrade and delete modes. The addition of stats and summary fills retrieval and introspection needs, leaving no obvious gaps.

Maintenance

ActivityMaintained
ResponsivenessNo issues