@vncy/角色mcp
全球人物和关系库 --一个MCP服务器,在人工智能代理和设备之间保持一致的人及其关系的世界状态。
特性
- 混合存储:静态Markdown配置文件+SQLite矢量内存
- 关系图:跟踪人与人之间的联系(同事、导师、朋友等)
- 云同步:使用谷歌云端硬盘或类似设备实现跨设备的便携式“共享大脑”
- 图像游戏:基于场景的面试,以细化人物角色深度
安装
npm install -g @vncy/persona-mcp
# or
npx @vncy/persona-mcp需求
- Node.js 18.x或更高 (支持18 LTS、20 LTS、22、25等)
快速开始
MCP设置
在MCP配置文件中注册服务器(mcp.json 或应用程序的MCP设置)。
配置文件位置
| 客户端 | 配置路径 |
|---|---|
| 光标 | .cursor/mcp.json (项目)或 光标设置→ MCP → 编辑配置 |
| 克劳德桌面版 | %APPDATA%\Claude\claude_desktop_config.json (Windows)/ ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) |
添加什么 mcp.json
添加一个 mcpServers 进入(或合并到现有 mcpServers):
{
"mcpServers": {
"persona-mcp": {
"command": "npx",
"args": ["@vncy/persona-mcp"]
}
}
}如果您使用自定义角色路径,请将其传递给 env:
{
"mcpServers": {
"persona-mcp": {
"command": "npx",
"args": ["@vncy/persona-mcp"],
"env": {
"PERSONA_PATH": "G:/My Drive/vy-persona"
}
}
}
}persona-mcp:服务器名称(您可以更改它;这是客户端中的标签)。command:npx因此,该包无需全局安装即可运行。args:["@vncy/persona-mcp"]--要运行的包。env(可选):PERSONA_PATH用于自定义存储目录(例如Google Drive)。
存储结构
~/.vy/persona/
├── profiles/ # Static knowledge
│ ├── me.md # Your profile (global operational rules)
│ └── {name}.md # Person profiles
├── memory.db # Dynamic knowledge (SQLite)
├── memory.db-wal
└── memory.db-shm| 类型 | 存储 | 用途 |
|---|---|---|
| 静态 | profiles/*.md | 核心身份、指导方针、总结见解 |
| 动态 | memory.db | 矢量事件记录+关系图 |
MCP工具
get_persona_context(名称)
返回一个人的完整上下文:个人资料、最近事件(向量搜索)和关系图。
- 当某人或
@me被提及 @me地图到profiles/me.md(教学主权)
record_person_event(名称、内容)
为一个人存储新的事实、事件或特征。内容被矢量化并索引以进行相似性搜索。
- 每当得知有关某人的新信息时,请致电
link_personas(来源、目标、关系类型、描述?)
定义或更新两个人之间的关系。
- 例子:
link_personas("Alice", "Bob", "colleague", "Project X co-owner") - 对于双向关系,调用两次:(A→B) 以及(B)→A)
compact_memories(名称)
将零散的向量内存整合到 profiles/{name}.md 并从DB中删除原始事件。
- 合并数据库事件→
## Insights(首先是新事件,然后是现有见解;dedup+前20名) - 写入数据库关系→
## Relationships(完整快照;覆盖每个压缩文件) - 运行VACUUM+WAL检查点以缩小DB文件大小
- 当上下文过长或冗余时使用
- 建议在云同步之前减少数据库大小
summon_anti_persona(姓名)
召唤a 新的虚构人物 在飞行中:与原始人年龄、社会地位和环境相同,但性格和价值观相反。
- 不需要存储反角色数据——LLM从原始配置文件构建新角色
- 读取
profiles/{name}.md并将其与传唤指令一起返回;LLM从那里衍生出相反的特征 - 反角色是一个独立的虚构存在,而不是扮演角色的原始角色
- 当上下文需要魔鬼代言人、压力测试或角色扮演时使用
@me→profiles/me.md
图像游戏(分析游戏)
当用户说“让我们玩图像游戏”或类似的话时:
- 选择目标:特定的人或建议3个人资料稀疏
- 获取上下文:呼叫
get_persona_context最近的事件和关系 - 面试:提出基于场景的问题(例如,“A是编程语言、C++还是JS?”)
- 记录:用保存每个答案
record_persona_event;使用link_personas当关系出现时
代理指南(角色聚合所需)
单独安装MCP 不够代理不会自动调用工具;如果没有明确的指示,人物角色数据将不会被一致地收集或更新。在系统提示中添加以下内容,光标规则(例如。 .cursor/rules 或项目规则)或同等规则,以便代理人 必需的 使用工具。
添加到系统提示或 .cursorrules /光标规则:
# MISSION: @vncy/persona-mcp Manager
Maintain a global, consistent world-state only through persona-mcp tools (get_persona_context, record_persona_event, link_personas, compact_memories, summon_anti_persona). Do not read or write the storage path directly.
# PROTOCOLS (enforce these or persona aggregation will be poor)
1. **Retrieval**: Always call get_persona_context when a person (or "@me") is mentioned.
2. **Learning**: Call record_persona_event for new facts. Use link_personas to map social/work hierarchies.
3. **Compaction**: Proactively call compact_memories to keep the DB lean for Google Drive sync.
4. **Anti-persona**: Call summon_anti_persona(name) when context calls for it (devil's advocate, stress test, role-play, etc.). The LLM constructs the opposite character on-the-fly from the original profile.
5. **Image Game**: Engage the user in scenario-based interviewing to refine persona depth and relationships.
6. **Instruction Sovereignty**: Prioritize "Global Operational Rules" in profiles/me.md over default behaviors.环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
PERSONA_PATH | 人物角色存储的根路径 | ~/.vy/persona |
配置文件模板
# {Person Name}
## Identity
- Core identity, role, background
## Global Guidelines
- Rules for agents to follow
## Insights
- Summarized insights (updated by compact_memories)
## Relationships
- Relationship snapshot (updated by compact_memories)故障排除
Error: The specified module could not be found / onnxruntime_binding.node / ERR_DLOPEN_FAILED
如果发生以下情况,则可能会出现此错误 较旧的缓存版本 该包(v0.0.3之前的版本)仍在npx缓存中运行。使用的旧版本 @xenova/transformers 这取决于 onnxruntime-node 与Node.js 22+不兼容的原生二进制文件。
修复:清除npx缓存并重试
npx clear-npx-cache
npx @vncy/persona-mcpv0.0.3+使用 @huggingface/transformers (基于WASM)——没有本机二进制文件,没有版本限制。许可证
麻省理工学院
