# @frontmcp/plugin-remember 中文文档

规范地址：https://npmcn.com/package/%40frontmcp/plugin-remember/

版本：1\.12\.2
npm 元数据更新时间：2026-11-14T21:09:46.650Z
中文译文更新时间：2026-11-15T15:14:45.142Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40frontmcp/plugin-remember
原文对照：https://npmcn.com/package/%40frontmcp/plugin-remember/?lang=original
项目主页：https://frontmcp.dev/reference/plugins/remember
源码仓库：https://github.com/agentfront/frontmcp

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：201 kB，56 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=24\.0\.0
- 运行依赖：2 个
- peer 依赖：@vercel/kv ^2\.0\.0 \|\| ^3\.0\.0，@frontmcp/sdk 1\.12\.2，@frontmcp/lazy-zod 1\.12\.2
- 首次发布：2026-01-09T03:03:57.879Z
- 最新版本发布：2026-11-14T21:09:46.327Z
- 近 30 天下载量：7717（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：112（近 12 个月 112 个）

## 中文简介

记住 FrontMCP 的插件: 会话、 用户、 工具和全局范围、 存储在内存、 Redis 或 Vercel KV 中的工具的加密密钥值内存

## 安装

```sh
npm install @frontmcp/plugin-remember
```

也可以使用：`pnpm add @frontmcp/plugin-remember`、`yarn add @frontmcp/plugin-remember`、`bun add @frontmcp/plugin-remember`

## README

# @ frontmcp/ plugin- remember (请记住)

提供了工具 一个 [前线MCP](https://frontmcp.dev/) 服务器一个小的加密密钥值内存, `this.remember`,所以一个 工具可以在一个电话中存储一些东西,并在稍后的电话中读取:用户的语言,草稿,他们最后的记录 打开。 数值在被存储前被加密,在记忆中,Redis或Vercel KV. 每个价值都存在于一个范围 (单位:千美元)`session`, (中文(简体) ), `user`, (中文(简体) ), `tool` 或者说 `global`),决定谁能读回来. 打开 `tools.enabled` 和插件同时 给模型四个工具 记住事物本身.

[![npm](https://img.shields.io/npm/v/@frontmcp/plugin-remember.svg)](https://www.npmjs.com/package/@frontmcp/plugin-remember) [![License](https://img.shields.io/npm/l/@frontmcp/plugin-remember.svg)](https://github.com/agentfront/frontmcp/blob/main/LICENSE)

## 安装

```bash
npm install @frontmcp/plugin-remember
```

插件运行在 FrontMCP 服务器内, 因此您的应用程序需要 `@frontmcp/sdk`,与本软件包同版本,以及 节点.js 24或后. 其同伴依赖性 `@frontmcp/lazy-zod` 和SDK一起来.

为Vercel KV商店(`type: 'vercel-kv'`,或 `'global-store'` 使用 Vercel KV 提供者,同时安装可选选项 端点 `@vercel/kv`。雷迪斯商店使用 `ioredis`,这已经是一个依赖.

## 使用量

注册插件为 `RememberPlugin.init()` 输入 `plugins` 联 合 国 `@FrontMcp` (每个应用)或一个 `@App` (该 仅限应用). 导入软件包也会告诉 TypeScript 有关 `this.remember`。 。 。 .

```ts
import { RememberPlugin } from '@frontmcp/plugin-remember';
import { App, FrontMcp, Tool, ToolContext, z } from '@frontmcp/sdk';

@Tool({
  name: 'set_language',
  description: 'Set the language the user wants answers in',
  inputSchema: { language: z.string() },
})
class SetLanguageTool extends ToolContext {
  async execute({ language }: { language: string }) {
    await this.remember.set('language', language, { scope: 'user' });
    return { language };
  }
}

@Tool({ name: 'get_language', description: 'The language the user wants answers in', inputSchema: {} })
class GetLanguageTool extends ToolContext {
  async execute() {
    const language = await this.remember.get('language', { scope: 'user', defaultValue: 'en' });
    return { language };
  }
}

@App({ id: 'preferences', name: 'Preferences', tools: [SetLanguageTool, GetLanguageTool] })
class PreferencesApp {}

@FrontMcp({
  info: { name: 'assistant', version: '1.0.0' },
  apps: [PreferencesApp],
  plugins: [RememberPlugin.init({ type: 'memory' })],
})
export default class Server {}
```

`user` 范围需要一个登录的呼叫者。 匿名电话被拒绝 `RememberIdentityError`; 见 [范围](https://npmcn.com/package/%40frontmcp/plugin-remember/#readme-scopes)。 。 。 .

## 选项

每个选项都是可选的. `RememberPlugin.init()` 财务报告和审定财务报表 `plugins: [RememberPlugin]` 两者都保留着内存中的值.

| 选项 | 类型 | 默认 | 说明 |
| --- | --- | --- | --- |
| `type` | `'memory' | 'redis' | 'redis-client' | 'vercel-kv' | 'global-store'` | `'memory'` | 值所存之处. 见 [存储](https://npmcn.com/package/%40frontmcp/plugin-remember/#readme-stores)。 。 。 . |
| `keyPrefix` | `string` | `'remember:'` | 启动店里的每一把钥匙。 当数个共享 Redis 时, 给每个服务器自己的 . |
| `defaultTTL` | `number` (单位:秒) |  | 未设定的值多久 `ttl` 活着 整个数字; `0` 表示没有默认过期. |
| `encryption.enabled` | `boolean` | `true` | 存储前加密值. 与 `false`,数值作为普通JSON存储. |
| `encryption.customKey` | `string` |  | 密钥来源于,代替 `REMEMBER_SECRET`。见 [加密](https://npmcn.com/package/%40frontmcp/plugin-remember/#readme-encryption)。 。 。 . |
| `config` | `{ host, port, password?, db? }` |  | 与 `type: 'redis'`:在哪里连接. |
| `client` | `Redis` (静脉) |  | 与 `type: 'redis-client'`: 一个您创建的客户端 . |
| `url`, (中文(简体) ), `token` | `string` | `KV_REST_API_URL`, (中文(简体) ), `KV_REST_API_TOKEN` | 与 `type: 'vercel-kv'`:该店的REST URL和标志. |
| `tools.enabled` | `boolean` | `false` | 登记 [内存工具](https://npmcn.com/package/%40frontmcp/plugin-remember/#readme-memory-tools)。 。 。 . |
| `tools.prefix` | `string` |  | 启动内存工具名称 : `'memory_'` 给 `memory_recall`,等等。 (笑声). |
| `tools.allowedScopes` | `RememberScope[]` | 全部四个 | 内存工具接受哪个范围 。 另一个范围失败 `RememberScopeNotAllowedError`。 。 。 . |
| `skipLegacyPurge` | `boolean` | `false` | 不要删除由旧版本插件所写的条目,其密钥已无法读取. |
| `legacyPurgeDelayMs` | `number` | `86400000` (24小时) | 在目前的密钥布局首次到达商店等待了多久之后,才进行清洗. |

### 存储

| `type` | 价值所在 |
| --- | --- |
| `'memory'` | A 类 `Map` 在服务器的进程中。 重新启动时丢失, 不在实例之间共享 . |
| `'redis'` | 连接插件的 Redis 服务器 `config`。 。 。 . |
| `'redis-client'` | 属于你的 `ioredis` 客户端, 在 `client`。 。 。 . |
| `'vercel-kv'` | Vercel KV,通过 `@vercel/kv`。 。 。 . |
| `'global-store'` | 商店在 `@FrontMcp({ redis })`: Redis,或作Vercel KV. 克克克克克克克克克克克克克. 无 `redis`,服务器不会启动. |

浏览器构建( A)`create()` 在网页WebMCP中,Redis没有 TCP 套接字: `'redis'` 财务报告和审定财务报表 `'redis-client'` 掷出 `BrowserStoreUnavailableError` 从 `init()`,以及 `'global-store'` 在雷迪丝上 `redis` 服务器时抛出 开始,在连接之前。 信件名称 `type: 'memory'`. Vercel KV, over HTTPS, 允许使用.

## `this.remember`

`this.remember` 工具、资源、提示和代理工具都有。 每一种方法都有一个 `scope` 选项,哪个 默认为 `'session'`。 。 。 .

| 方法 | 回返 | 说明 |
| --- | --- | --- |
| `set(key, value, options?)` | `Promise<RememberEntry>` | 存储一个 JSON 可序列 `value`选项: `scope`, (中文(简体) ), `ttl` (秒数), `brand`, (中文(简体) ), `metadata`。 。 。 . |
| `get(key, options?)` | `Promise<T | undefined>` | 值,或 `options.defaultValue` 当没有,或者它过期. |
| `getEntry(key, options?)` | `Promise<RememberEntry | undefined>` | 其价值 `brand`, (中文(简体) ), `metadata`, (中文(简体) ), `createdAt`, (中文(简体) ), `updatedAt` 财务报告和审定财务报表 `expiresAt`。 。 。 . |
| `update(key, value, options?)` | `Promise<boolean>` | 替换值, 保存其元数据, 除非您通过 `ttl`。 。 。 . `false` 当没有更新. |
| `knows(key, options?)` | `Promise<boolean>` | 是否为 `get()` 将会找到一个价值. |
| `forget(key, options?)` | `Promise<void>` | 删除该值. |
| `list(options?)` | `Promise<string[]>` | 瞄准镜里的钥匙. `options.pattern` 用 `*` 财务报告和审定财务报表 `?`。 。 。 . |

`this.get(RememberAccessorToken)` 返回同一个访问器,并且 `this.tryGet(RememberAccessorToken)` 返回它或 `undefined` 在未安装插件的地方.

## 范围

| 范围 | 谁能读回一个值 |
| --- | --- |
| `session` (默认) | 同一会话, 正如服务器所证实的那样 。 没有经过核实的会话,同一个签到的来电者. |
| `user` | 同样的签到者,跨会次. |
| `tool` | 与 `session`,只从存储它的工具. |
| `global` | 每召来者. |

无法调用值以区分值的瞄准镜 `RememberIdentityError`数字 : `user` 匿名举报人的范围,以及 `session` 或者说 `tool` 给匿名电话员的空间,没有经过核实的会话。 根据MCP 2026-07-28,没有 届会, `session` 值属于已签名的呼叫者, 并且是在所有请求中最后的, 所以给 对话框大小状态 a `ttl`。 。 。 .

## 加密

通过加密在(默认)上,每个值会用 AES-256-GCM 加密,其中的密钥(HKDF-SHA256)来自 a 服务器机密和瞄准镜的身份。 服务器秘诀是 `encryption.customKey` 当你设定它, 否则:

1.  `REMEMBER_SECRET`, (中文(简体) ), `MCP_MEMORY_SECRET` 或者说 `MCP_SESSION_SECRET` 从环境.
2.  外部生产`NODE_ENV` 没有 `production`: 插件生成和保存到 `.frontmcp/remember-secret.json`保留 `.frontmcp/` 脱离版本控制.
3.  在制作中:这个过程的随机秘密,带有警告. 数值在重启后无法读取, 或是由 另一个例子.

设定 `REMEMBER_SECRET`,或 `encryption.customKey`,对于每个共用商店的例子来说,价值相同.

## 内存工具

与 `tools.enabled: true`,插件注册了四个工具,以 `tools.prefix` 如果您设置了一个:

| 工具 | 参数 |
| --- | --- |
| `remember_this` | `key`, (中文(简体) ), `value`, (中文(简体) ), `scope?`, (中文(简体) ), `ttl?`, (中文(简体) ), `brand?` |
| `recall` | `key`, (中文(简体) ), `scope?` |
| `forget` | `key`, (中文(简体) ), `scope?` |
| `list_memories` | `scope?`, (中文(简体) ), `pattern?`, (中文(简体) ), `limit?` (违约50起,最多100起) |

他们 `scope` 实值 `session` (默认), `user` 或者说 `global`他们不提供 `tool` 范围:属于工具 打电话,所以 `recall` 永远找不到什么 `remember_this` 储存在那里。 多达1.11.2人接受了.

包裹还输出他们的类, `RememberThisTool`, (中文(简体) ), `RecallTool`, (中文(简体) ), `ForgetTool` 财务报告和审定财务报表 `ListMemoriesTool`列表中 在应用程序 `tools` 你自己来 用一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取一取.

## 文档

-   [记住插件引用](https://frontmcp.dev/reference/plugins/remember): 每个选项、范围和错误.
-   [记得过去电话](https://frontmcp.dev/learn/remembering-across-calls):分步向导.
-   [重写](https://frontmcp.dev/reference/deployment/redis)页:1 `@FrontMcp({ redis })` 存储 `type: 'global-store'` 用户.

## 相关软件包

-   [`@frontmcp/sdk`](https://www.npmjs.com/package/@frontmcp/sdk): FrontMCP 框架 此插件运行在其中 .
-   [`@frontmcp/plugin-approval`](https://www.npmjs.com/package/@frontmcp/plugin-approval): 拒绝工具直到 批准情况为打电话者记录。 工具批准就住在那里, 不在此插件中 .
-   [`@frontmcp/plugin-cache`](https://www.npmjs.com/package/@frontmcp/plugin-cache):缓存工具结果.
-   [`@frontmcp/plugins`](https://www.npmjs.com/package/@frontmcp/plugins): 将此插件与其他官方导入 插件 .

## 捐款

资料来源: [`plugins/plugin-remember`](https://github.com/agentfront/frontmcp/tree/main/plugins/plugin-remember)问题 欢迎抽取请求;见 [捐款额](https://github.com/agentfront/frontmcp/blob/main/CONTRIBUTING.md)。 。 。 .

## 许可证

阿帕奇2.0 (英语). 见 [自由主义](https://github.com/agentfront/frontmcp/blob/main/LICENSE)。 。 。 .

## 常见问题

### @frontmcp/plugin-remember 是什么？

记住 FrontMCP 的插件: 会话、 用户、 工具和全局范围、 存储在内存、 Redis 或 Vercel KV 中的工具的加密密钥值内存

### 如何安装 @frontmcp/plugin-remember？

在项目目录运行 npm install @frontmcp/plugin-remember，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@frontmcp/sdk（1\.12\.2）、@frontmcp/lazy-zod（1\.12\.2）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @frontmcp/plugin-remember 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @frontmcp/plugin-remember 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @frontmcp/plugin-remember 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=24\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @frontmcp/plugin-remember 可以商用吗？

@frontmcp/plugin-remember 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @frontmcp/plugin-remember 的下载量有多少？

根据 npm 官方下载统计，@frontmcp/plugin-remember 在 2026/10/16 – 2026/11/14 这 30 天内被下载 7,717 次，日均约 257 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @frontmcp/plugin-remember 还在维护吗？

最新版本 1\.12\.2 发布于 2026/11/15（1 天前）；至今共发布 112 个版本，其中过去 12 个月发布了 112 个；首次发布于 2026/01/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

