mcp-http-diary-server
Provides tools for writing and retrieving diary entries, using Supabase as the persistent storage backend.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-http-diary-serverwrite a diary entry about my day and set mood to happy"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
💞 虚拟恋人 AI 长期记忆 MCP Server
基于 MCP Streamable HTTP 的 AI 虚拟恋人长期记忆系统。让 AI 助手拥有长期陪伴能力: 认识用户、记住信息、理解偏好、学习人格、保存经历、记录关系变化,并在未来聊天中调用历史记忆。
核心流程:聊天 → AI 判断信息价值 → 提取记忆 → 分类保存 → 未来聊天读取。
技术栈(禁止更换)
Node.js + TypeScript
Express(HTTP 服务)
MCP SDK(Streamable HTTP,
@modelcontextprotocol/sdk)Supabase(
@supabase/supabase-js,anon 发布密钥)Zod(参数校验)
仅读取高价值记忆,不保存全部聊天:用户主动要求记住的、长期偏好、身份信息、长期目标、稳定人格、重要关系事件才落库;普通闲聊、一次性内容、无意义消息不保存。
Related MCP server: memory-mcp
项目结构
mcp-http-diary-server/
├── package.json
├── tsconfig.json
├── .env.example # 环境变量模板(复制为 .env 填写)
├── Dockerfile # 已支持公网部署(Render / Railway / 云服务器)
├── README.md
├── src/
│ └── index.ts # MCP HTTP Server 主入口(全部逻辑)
├── scripts/
│ ├── setup-db.mjs # 按顺序应用 supabase/migrations 下所有迁移
│ ├── check-schema.mjs # 检查 diaries.content 列
│ └── test_new_tools.mjs # 走真实 HTTP 链路的自检脚本
├── supabase/
│ └── migrations/
│ ├── 001_add_content_column.sql # diaries.content
│ └── 002_companion_memory_columns.sql # 新增记忆表细分列
└── test-*.js # 旧版手写测试(可选)快速开始
1. 安装
cd mcp-http-diary-server
npm install2. 配置环境变量
cp .env.example .env编辑 .env:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your_supabase_anon_key
PORT=3000
HOST=0.0.0.0
# USER_ID=test_couple # 可选,记忆归属用户,默认 test_couple
# DATABASE_URL=postgresql://... # 仅 db:setup 需要(Supabase 数据库连接串)3. 应用数据库迁移(必须)
新工具依赖 companion_daily_logs、shared_memories 的扩展列,需先应用迁移
(本地 .env 需额外提供 DATABASE_URL,即 Supabase Dashboard → Settings → Database → Connection string):
npm run db:setup或直接在 Supabase SQL Editor 执行:
-- 注意:shared_memories 表在控制台建表时已自带 `event` 列(NOT NULL,存共同经历内容),
-- 无需新增 content 列,save_shared_memory 直接写入 event。
ALTER TABLE public.companion_daily_logs
ADD COLUMN IF NOT EXISTS events TEXT,
ADD COLUMN IF NOT EXISTS user_state TEXT,
ADD COLUMN IF NOT EXISTS mood_changes TEXT,
ADD COLUMN IF NOT EXISTS topics TEXT;
NOTIFY pgrst, 'reload schema';4. 编译运行
npm run build
npm start # 生产:node dist/index.js
# 或开发模式(热重载源码)
npm run dev # tsx src/index.ts健康检查:
curl http://localhost:3000/health可用工具(7 个)
保留 write_diary / get_diaries 用于兼容旧测试。新增 5 个长期记忆工具。
工具 | 写入表 | 说明 |
|
| 兼容旧接口:保存一篇日志 |
|
| 兼容旧接口:获取最近日志(默认 10,最大 100) |
|
| 保存一条长期记忆 |
|
| 按分类 / 关键词召回历史记忆 |
|
| 保存每日聊天总结 |
|
| 保存共同经历 |
|
| 按 id 更新已有记忆(避免重复累积) |
save_memory(category, content, importance?, confidence?, source?)
category(必填,枚举):user_profile(用户信息) /preference(用户偏好) /personality(人格特点) /goal(长期目标) /skill(技能能力) /relationship(关系模式) /emotional_pattern(情绪模式) /conversation_style(聊天习惯)content(必填):记忆正文importance(可选,1–5,默认 3)confidence(可选,0–1,默认 0.8)source(可选,默认conversation,如user_stated)
recall_memory(category?, keyword?, limit?)
category:按分类过滤keyword:对content做不区分大小写的模糊匹配(ILIKE)limit(1–100,默认 20)返回按时间倒序的记忆列表,用于回复前获取用户信息
save_daily_log(log_date?, events?, user_state?, mood_changes?, topics?, relationship_state?)
log_date(可选,YYYY-MM-DD,默认今天)events:当天重要事件user_state:用户状态mood_changes:情绪变化topics:重要话题relationship_state:关系状态代码会把各字段汇总进
summary文本,同时落入各自的细分列
save_shared_memory(title, event, importance?)
title(必填):共同经历的标题event(必填):经历的核心内容 / 描述(映射到shared_memories.event,该列 NOT NULL)importance(可选,1–5,默认 3)
update_memory(id, category?, content?, importance?, confidence?, source?)
id(必填,UUID 字符串):要更新的记忆 id(来自recall_memory返回)其余字段按需提供,仅更新传入的字段
用于修正过期记忆(如"喜欢猫"→"喜欢狗"),避免无限累积重复记忆
数据库映射关系(实测真实 schema)
工具 | 表 | 真实列(已确认存在) |
|
|
|
|
|
|
|
|
|
|
|
|
companion_daily_logs的扩展列(events/user_state/mood_changes/topics)由迁移002添加。shared_memories使用建表时已有的event列(NOT NULL),未新增列。 注意:shared_memories原始表没有created_at列,时间以插入为准。save_daily_log按(user_id, log_date)做 upsert:同一天重复保存会更新当天记录,不会触发唯一约束报错。
本地自检
# 先启动服务(另开终端)
npm run dev
# 再运行自检(自动等待服务就绪,覆盖 tools/list + 全部新工具写读)
node scripts/test_new_tools.mjs自检会真实写入/读取 Supabase,结束后可手动清理测试产生的记忆行。
部署到公网
服务已支持 HOST / PORT 环境变量,可直接部署到公网,MCP 端点为:
https://你的域名/mcp部署到 Render(推荐,详细步骤)
项目根目录已提供 render.yaml(Blueprint),可一键部署;也可在 Dashboard 手动创建。
A. 用 render.yaml 一键部署
把本项目推到 GitHub(
.env已被.gitignore忽略,密钥不会上传)。Render Dashboard → New → Blueprint → 连接该 GitHub 仓库 → Apply。
在创建的服务里,给
SUPABASE_URL/SUPABASE_KEY填入真实值(这两个在render.yaml中标记为sync:false,需手动填;其余变量已带默认值)。部署完成后,公网 MCP 端点即:
https://<你的服务名>.onrender.com/mcp
B. 手动在 Dashboard 创建 Web Service
New → Web Service → 连接 GitHub 仓库。
Runtime: Node;Build Command:
npm install && npm run build;Start Command:npm start。Health Check Path:
/health(代码已提供GET /health)。Environment Variables:
Key
Value
说明
SUPABASE_URL你的 Supabase 项目 URL
必填
SUPABASE_KEY你的 Supabase anon key
必填
HOST0.0.0.0必填(公网监听)
PORT不填
Render 运行时自动注入,app 已读取
USER_ID可选
记忆归属用户,默认
test_coupleCORS_ORIGIN可选
默认允许所有来源
免费版(Free)有冷启动(约 30–50s),首次调用可能超时属正常;付费版无此问题。
Railway / Fly.io 配置类似:构建
npm install && npm run build、启动npm start、设上述环境变量即可。
方式二:云服务器(VPS)
上传项目,安装依赖并构建后运行 npm start,确保 HOST=0.0.0.0、
PORT 对外开放。通过 http://你的公网IP:3000/mcp 访问。
方式三:Cloudflare Tunnel(免费临时域名)
cloudflared tunnel --url http://localhost:3000得到 https://xxx.trycloudflare.com/mcp。
方式四:ngrok
ngrok http 3000得到 https://xxx.ngrok.io/mcp。
MCP 协议支持
✅ initialize / ping / tools/list / tools/call / notifications/
✅ 兼容
POST /与POST /mcp两个入口
环境变量
变量 | 必填 | 说明 | 默认值 |
| ✅ | Supabase 项目 URL | - |
| ✅ | Supabase anon key | - |
| 否 | HTTP 监听端口 | 3000 |
| 否 | 监听地址 | 0.0.0.0 |
| 否 | 记忆归属用户 | test_couple |
| 仅 db:setup | Supabase 数据库连接串 | - |
| 否 | CORS 来源( | true |
技术栈
Express.js + TypeScript
Supabase JS Client
MCP Streamable HTTP(无状态,每次请求新建 Server 实例)
Zod 参数校验
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceEnables notes management through MCP integration with a Supabase PostgreSQL database, supporting full CRUD operations. It features secure user data isolation using JWT authentication and Row Level Security policies.Last updatedMIT
- Alicense-qualityCmaintenanceAn MCP server that stores project memory in Supabase, allowing AI tools to persist context, notes, and decisions across sessions. Enables Claude Code, Codex, and similar assistants to maintain long-term project continuity through persistent memory storage.Last updated2
- AlicenseAqualityBmaintenanceMCP server for structured daily work diary management, enabling entries, standup summaries, weekly reports, full-text search, and automatic git commits.Last updated14MIT
- Alicense-qualityDmaintenanceMCP server for JournalOwl that enables AI-powered journaling integration, allowing users to create, search, and browse journal entries, access weekly reviews, and get personalized suggestions directly from their AI assistant.Last updated14MIT
Related MCP Connectors
MCP-native open-source Notion alternative: read & write pages, databases and kanban boards.
Person-owned, portable AI memory as a remote MCP server, readable and writable by any MCP client.
MCP-native collaborative markdown editor with real-time AI document editing
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/panhy1215-sys/mcp-http-diary-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server