Metadata-Version: 2.4
Name: n1mem-mcp
Version: 0.1.1
Summary: N1Mem MCP server (BYOK, zero dependencies) — let Claude / Cursor / OpenClaw talk to N1Mem long-term memory via MCP
Author: N1Mem (powered by T1Mem engine)
License: Proprietary
Project-URL: Homepage, https://www.n1mem.com
Keywords: mcp,memory,llm,agent,n1mem,t1mem,claude,cursor,openclaw
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# n1mem-mcp · N1Mem 记忆 MCP Server

> powered by T1Mem engine · BYOK（自带 Key）· 零依赖（仅标准库）

让 Claude / Cursor / OpenClaw 之类支持 MCP 的客户端，直接获得 N1Mem 的**长期记忆**能力。

- `memory_write`：写入一段记忆（持久化 + 建向量，写入即可召回）
- `memory_recall`：按自然语言问题召回记忆；返回的 `answer` 已基于命中记忆接地，`retrieved` 给出命中的明文记忆
- `memory_health`：查看服务健康与 provider 可用性

本 Server 是**薄层透传**：不含任何记忆逻辑，只把工具调用转发到 N1Mem C-2 API（`https://api.n1mem.com`）。因此零依赖、可塞进任意环境。

## 安装

```bash
pip install n1mem-mcp
```

## 获取 Key

试用 Key 当前由 N1Mem 团队发放（自助注册 / 定价页在路上）。拿到形如 `tk_xxx` 的 Key。

## 配置（Cursor / Claude / OpenClaw）

把下面片段加进你的 MCP 配置（`~/.cursor/mcp.json`、Claude 的 `claude_desktop_config.json`、或 OpenClaw 的 MCP 配置）：

```json
{
  "mcpServers": {
    "n1mem": {
      "command": "n1mem-mcp",
      "env": { "N1MEM_API_KEY": "tk_xxx" }
    }
  }
}
```

或用模块方式启动（无需 `pip install` 也可，只要能 import）：

```json
{
  "mcpServers": {
    "n1mem": {
      "command": "python",
      "args": ["-m", "n1mem_mcp"],
      "env": { "N1MEM_API_KEY": "tk_xxx" }
    }
  }
}
```

## 环境变量

| 变量 | 说明 | 默认 |
|---|---|---|
| `N1MEM_API_KEY` | 你的试用 Key（必填） | 空 |
| `N1MEM_BASE_URL` | C-2 API 地址 | `https://api.n1mem.com` |
| `N1MEM_MCP_TIMEOUT` | 单条调用超时（秒） | `90` |

## 已知限制（诚实告知）

- 暂无 `delete` / `update` 工具（服务端未就绪，故不暴露）；需要删记忆请联系团队。
- `health()` 可能返回 `status: degraded`：这是设计使然（部分上游 provider 未配置），核心记忆链路（存储 / 嵌入 / 写入 / 召回）正常。

## 与 `n1mem` 的区别

| 包 | 形态 | 用途 |
|---|---|---|
| `n1mem` | Python SDK（函数调用） | 代码里直接 `m.ingest() / m.recall()` |
| `n1mem-mcp` | MCP Server（stdio） | 让 MCP 客户端（Claude/Cursor/OpenClaw）以工具方式调用记忆 |
