AI聊天记忆服务器

一个用于AI聊天的记忆服务器,支持MCP接口,能够存储聊天消息并在需要时返回对话摘要。

  • by Gelembjuk
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 Gelembjuk/cleverchatty-memory

使用说明

带MCP接口的AI聊天存储服务器

这是一个用于AI聊天的内存服务器示例。它遵循工具支持的界面 聪明健谈.

MCP服务器的接口为:

{
    "tools": [
    {
      "name": "remember",
      "description": "Remember a chat message to extract a context later for the memory",
      "inputSchema": {
        "properties": {
          "role": { "type": "string" },
          "message": { "type": "string" }
        },
        "required": ["role", "message"]
      }
    },
    {
      "name": "recall",
      "description": "Returns the summary of the previous conversations",
      "inputSchema": {
        "properties": {
        },
        "required": []
      }
    }
    ]
}

此工具可以与 CleverChatty命令行界面 创建具有记忆的AI聊天。服务器将记住这些消息,并在收到请求时返回之前对话的摘要。

如何运行服务器

  1. 克隆存储库
git clone git@github.com:Gelembjuk/cleverchatty-memory.git
cd cleverchatty-memory
  1. 如果尚未安装,请安装uv
curl -Ls https://astral.sh/uv/install.sh | sh
  1. 创建虚拟环境
uv venv
  1. 在Linux/macOS上激活虚拟环境(在其他平台上可能不同)
source .venv/bin/activate
  1. 安装依赖项
uv sync
  1. 运行服务器
fastapi run mcp_server.py --port 8001

这将通过端口8001上的SSE传输启动MCP服务器。您可以通过修改端口来更改 --port 争论。它将通过URL访问 http://localhost:8001/mcp。您也可以使用 --host 更改主机的参数。默认情况下,它只能从localhost访问。您可以将其更改为 --host 0.0.0.0 使其可以从任何IP地址访问。

测试和调试

此工具还包含用于测试服务器的CLI。

python manager.py COMMAND

示例:

python manager.py clear-memory
python manager.py remember "user" "Some message from user"
python manager.py remember "assistant" "Some response from assistant"
python manager.py patch-memories
python manager.py recall
python manager.py history-dump