Skip to content

AI 工具集成

Memento 支持 MCP (Model Context Protocol) 协议,可以让 Claude、ChatGPT 等 AI 工具直接访问你的 Memento 数据,实现智能助手功能。

什么是 MCP?

MCP 是一种标准协议,让 AI 模型能够安全地连接外部数据源和工具。通过 MCP,你可以:

  • 让 AI 帮你管理笔记、任务、日记
  • 查询账单统计、活动记录
  • 创建日程、联系人等

支持的功能

MCP 服务器提供以下插件的数据访问能力:

插件功能
Chat聊天频道和消息管理
Notes笔记和文件夹管理
Todo任务管理
Diary日记管理
Bill账单和账户管理
Calendar日历事件
Activity活动记录和统计
Goods物品和仓库管理
Checkin签到管理
Contact联系人管理
Tracker目标追踪
Day纪念日管理

安装 MCP 服务器

方式一:NPM 全局安装(推荐)

bash
npm install -g @hunmer/mcp-memento-server

安装后直接运行:

bash
mcp-memento-server

方式二:使用 npx(无需安装)

bash
npx @hunmer/mcp-memento-server

获取 API Key

在配置 AI 工具之前,需要先获取 API Key:

  1. 确保服务器正在运行
  2. 访问管理面板 http://localhost:8080/admin/
  3. 使用默认账号登录:admin / admin123
  4. 进入「API Keys」选项卡
  5. 点击「创建 API Key」
  6. 输入名称、选择过期时间
  7. 重要:从 Memento 客户端获取加密密钥(设置 > 开发者选项)
  8. 保存显示的 API Key 和加密密钥

配置环境变量

创建 .env 文件:

env
# Memento 后端服务器地址
MEMENTO_SERVER_URL=http://localhost:8080

# API Key 认证(从管理面板获取)
MEMENTO_API_KEY=mk_live_your_api_key_here
MEMENTO_ENCRYPTION_KEY=your_base64_encryption_key_here

或通过命令行设置:

powershell
$env:MEMENTO_SERVER_URL="http://localhost:8080"
$env:MEMENTO_API_KEY="mk_live_your_api_key"
$env:MEMENTO_ENCRYPTION_KEY="your_base64_encryption_key"
bash
export MEMENTO_SERVER_URL="http://localhost:8080"
export MEMENTO_API_KEY="mk_live_your_api_key"
export MEMENTO_ENCRYPTION_KEY="your_base64_encryption_key"

配置 Claude Desktop

编辑 Claude Desktop 配置文件:

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

使用全局安装

json
{
  "mcpServers": {
    "memento": {
      "command": "mcp-memento-server",
      "env": {
        "MEMENTO_SERVER_URL": "http://localhost:8080",
        "MEMENTO_API_KEY": "mk_live_your_api_key",
        "MEMENTO_ENCRYPTION_KEY": "your_base64_encryption_key"
      }
    }
  }
}

使用 npx(无需安装)

json
{
  "mcpServers": {
    "memento": {
      "command": "npx",
      "args": ["@hunmer/mcp-memento-server"],
      "env": {
        "MEMENTO_SERVER_URL": "http://localhost:8080",
        "MEMENTO_API_KEY": "mk_live_your_api_key",
        "MEMENTO_ENCRYPTION_KEY": "your_base64_encryption_key"
      }
    }
  }
}

可用工具列表

Chat 插件

工具名描述
memento_chat_getChannels获取聊天频道列表
memento_chat_createChannel创建新的聊天频道
memento_chat_getMessages获取指定频道的消息列表
memento_chat_sendMessage向频道发送消息
memento_chat_searchMessages搜索消息

Notes 插件

工具名描述
memento_notes_getNotes获取笔记列表
memento_notes_createNote创建新笔记
memento_notes_updateNote更新笔记
memento_notes_searchNotes搜索笔记

Todo 插件

工具名描述
memento_todo_getTasks获取任务列表
memento_todo_createTask创建任务
memento_todo_completeTask完成任务
memento_todo_getTodayTasks获取今日任务
memento_todo_getOverdueTasks获取过期任务
memento_todo_getStats获取任务统计

Diary 插件

工具名描述
memento_diary_getEntries获取日记列表
memento_diary_getEntry获取指定日期的日记
memento_diary_createEntry创建日记
memento_diary_searchEntries搜索日记
memento_diary_getStats获取日记统计

Bill 插件

工具名描述
memento_bill_getAccounts获取账户列表
memento_bill_getBills获取账单列表
memento_bill_createBill创建账单
memento_bill_getStats获取账单统计

Calendar 插件

工具名描述
memento_calendar_getEvents获取日历事件
memento_calendar_createEvent创建事件
memento_calendar_completeEvent完成事件
memento_calendar_searchEvents搜索事件

Contact 插件

工具名描述
memento_contact_getContacts获取联系人列表
memento_contact_createContact创建联系人
memento_contact_searchContacts搜索联系人

更多插件

还支持 Activity、Goods、Checkin、Tracker、Day 等插件,提供完整的增删改查和统计功能。

故障排除

认证失败

Error: API Key 无效或已过期

解决方案:

  1. 检查 API Key 是否正确复制(包含 mk_live_ 前缀)
  2. 在管理面板检查 API Key 是否已过期
  3. 确认加密密钥与创建 API Key 时使用的一致

无法连接服务器

Error: fetch failed

解决方案:

  1. 确认 Memento Server 正在运行
  2. 检查 MEMENTO_SERVER_URL 是否正确
  3. 如果使用 HTTPS,确保证书有效

Claude Desktop 未识别 MCP

  1. 确认配置文件路径正确
  2. 确认 JSON 格式有效
  3. 重启 Claude Desktop 应用

Released under the MIT License.