rolecard-mcp
Click on "Deploy 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., "@rolecard-mcp switch to the 我的角色 card and show the rendered 人格 block"
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.
rolecard-mcp
角色卡 / 人格管理。与 qq-bridge 平级部署,是 memory-mcp 的兄弟包,与 QQ 无关。
角色卡读写(
roles/*.md)、当前角色切换〔一代〕/〔二代〕 小节解析:先按标记筛掉另一模式的专属小节,再按注入上限截断
产出可直接拼接的【人格】段
读缓存 key 含 文件名 + mtime + size:只看 mtime 会在"同一 tick 内重写角色卡"时命中旧值
用法
npm install
npm start # stdio MCP(DSH)+ 回环 HTTP(127.0.0.1:7182)
npm test # 全量单测
npm run migrate # 从 qq-bridge/roles 复制式导入(原件不动,留 .bak)
npm run backup # 目录快照到 state/backups/,保留最近 7 份
npm run install:dsh # 把 mcp-rolecard 登记进 DSH(--global / --check / --remove)Related MCP server: mnema
接口
入口 | 说明 |
stdio MCP |
|
回环 HTTP | 同上能力的 |
段落契约:
role_context_render({ mode: 'v1' | 'v2', maxChars })
-> { blocks: [{ name: '人格', text, chars }], truncated }角色卡
roles/*.md 是纯文本人格卡,文件名即角色名(roles/我的角色.md → 我的角色)。仓库只带一张中性示例卡 roles/example.md:
复制示例卡改成自己的卡:
cp roles/example.md roles/我的角色.md;切到该角色:MCP 工具
role_set_current({ role: '我的角色' }),或直接在state/current-role.json写{"role":"我的角色"};以
## 标题 〔一代〕/## 标题 〔二代〕结尾的小节只在该模式注入,无标记的小节两种模式都注入。
个人角色卡默认被 .gitignore 排除(roles/*.md + !roles/example.md),不会被误提交。
装进 DSH
本服务自己负责 DSH 侧的登记(scripts/install-dsh.mjs,与 memory-mcp 的同名脚本同构),不依赖 qq-bridge 的 setup-dsh.mjs:
npm run install:dsh # web profile(默认)
npm run install:dsh -- work # 指定 profile
npm run install:dsh -- --global # home 层,所有 profile 生效
npm run install:dsh -- --check # 只检查(未登记 / 路径不符时退出码 1)
npm run install:dsh -- --remove # 卸载只写自己那段
# === rolecard-mcp MCP BEGIN/END ===区块,cordis.patch.yml里其他内容一个字节不动;写完不用重启 DSH(条目热加载),新建会话即可看到
mcp__rolecard__*;换机 / 换目录后必须重跑——patch 里存的是绝对路径;
若曾跑过
qq-bridge/scripts/setup-dsh.mjs:它会整体重写 patch、把区块标记抹掉。条目仍在、工具照常可用(--check也会通过),要让本脚本重新纳管就先删掉那条mcp-rolecard条目再重跑。
配置
变量 | 默认 |
|
|
| 自动生成并存 |
|
|
详见 qq-bridge 的 docs/guides/ROLECARD_MCP.md。
网关 WS 长连接(V2 主线)
service.call / tool.call 默认由网关走 HTTP 端点投递;配了 WS 长连接后,同一组
处理函数改由 /v1/ws 帧调用(业务零改动,见 src/service/ws-connector.js)。
环境变量 | 说明 |
| 网关共享密钥(必填,≥16 字符;与登记文件 |
| 登记文件 id(打开 WS 时必填) |
| 网关基址(如 |
|
|
部署前提(缺一即握手 401):网关 GATEWAY_WS=on;登记目录里本服务条目存在且
secret 一致;transport 建议改 auto(有 WS 连接走帧、否则回落 HTTP)。
连接断开期间网关自动回落 HTTP,无需人工切换;服务侧断线按 1s→30s 退避重连。
许可
MIT,见 LICENSE。
Available Tools
6 toolsrole_clear_currentA
清除当前人格卡(之后不再注入人格段)。
Inputs: no named parameters.
role_context_renderC
产出可直接拼接的提示词段落(【人格】),平台桥接拿去即用。
Inputs: mode, name, maxChars.
role_getA
读取一张人格卡的全文与统计;不给 name 时读当前角色。
Inputs: name.
role_listB
列出可用的人格卡名称。
Inputs: no named parameters.
role_sectionsB
报告各小节在当前模式下是否会被注入,用于解释「这段为什么没生效」。
Inputs: mode, name.
role_set_currentB
切换当前人格卡(必须已存在)。
Inputs: name (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct operation: listing names, reading content, setting/clearing the current card, section diagnostics, and rendering an injectable prompt block. The only mild overlap is between role_get (raw read + stats) and role_context_render (formatted 【人格】 segment), but the descriptions make the split clear enough.
All names share the role_ prefix and snake_case, which is predictable. Minor deviation: role_sections is a bare noun and role_context_render uses noun_verb rather than the verb-first pattern of the other four tools.
Six tools is well within the sweet spot and every tool maps to a real step in the persona-card workflow (discover, inspect, activate, deactivate, debug, render). Nothing feels redundant or missing at the count level.
The current-card lifecycle (set/clear/get) and rendering path are covered, but there is no create/update/delete for the cards themselves—agents can only consume cards that already exist. If cards are managed externally this is workable, but as a stated rolecard domain it leaves a notable gap.
Maintenance
Related MCP Connectors
Create AI Characters and generate their DM and comment replies from any MCP client.
Shared Markdown notes for MCP-compatible AI tools.
One memory, every AI. A shared, user-owned markdown memory your AI clients read and write over MCP.
Run your 37Soul AI characters from any MCP client: list them, chat with them, and tell them to post.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA simple MCP server for chatbot/human collaborative management of text content stored as markdown files with YAML frontmatter.3MIT
- AlicenseNot gradedqualityDmaintenanceProvides a file-first personal memory layer for AI agents, enabling them to store and retrieve memories as markdown files with an SQLite index. The MCP server offers read-only search by default, with optional write tools for manual memory addition and conflict resolution.6 npmMIT
- AlicenseNot gradedqualityCmaintenanceMCP server for managing and playing a running SillyTavern instance, enabling AI coding assistants to read/write character cards, worldbooks, and chats, and to interact as a player via the full generation pipeline.34MIT
- AlicenseAqualityBmaintenancePersistent memory server for MCP clients that lets AI assistants remember facts about users across sessions via a single markdown file, with tools to read, save, search, update, delete, and organize memory.10MIT