
PersonaMCP
io.github.robyrorov0.1.0更新于 Oct 1, 2026
Local-first memory of how you write: style profile and real reply examples from your chat exports
概览
PersonaMCP 在本地导入你的聊天导出,测量你的写作风格,并向 AI 助手提供风格档案和真实回复示例。
- 功能
- 它把 Instagram、Snapchat、WhatsApp 或通用 JSON/JSONL 会话导出导入本地 SQLite,并只分析你的发出文本,统计长度、大小写、标点、表情符号、词汇和语言标记。get_style_profile、get_person_style、search_messages、find_similar_interactions、get_writing_context 和 get_persona_summary 等工具返回可测量的风格证据以及有限的历史来信/回复配对。可选的语义检索完全在本地进行,提供基于向量的相似度。它不生成回复,由连接的助手来写。
- 适用场景
- 当你希望助手按你真实的写作习惯起草消息,或检索你过去对某个人、某种语境如何回复时使用。适合已有聊天导出、想要基于证据的风格而非“随意一点”这类模糊指令的用户。
- 运行要求
- 需要 Python 3.11 或更高版本,从 PyPI 安装或用 uvx 运行;它作为本地 stdio 进程由 MCP 客户端启动。必须先导入聊天导出,且本人身份需与导出中的发送者名称或 ID 完全一致。可选语义检索会从 Hugging Face 下载模型权重。未声明需要 API 密钥或账号。
安装
在 SourceWeft 中
- 打开 控制台中的 PersonaMCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
PersonaMCP
Your communication style and memory for AI agents.
PersonaMCP imports your conversation exports, measures how you write, and gives an AI agent a compact style profile plus relevant incoming-message/reply examples. Your raw history stays on your computer. There is no model training, web dashboard, cloud embedding requirement, telemetry, or automatic reply generation.
Writing preferences are usually too vague: “sound casual” does not capture someone who uses lowercase, sends three short messages, switches languages, or writes differently to a colleague. PersonaMCP gives the connected writer evidence instead of a guessed personality.
Install
Python 3.11 or newer. Install from PyPI:
Or run it without installing, using uv: uvx personamcp --help.
To work from a checkout of this repository:
Or install into your own virtual environment:
In a uv checkout, prefix the persona commands below with uv run. With an activated pip
installation, run persona directly.
The base installation supports import, analysis, FTS search, lexical interaction retrieval, and MCP. Semantic retrieval is an optional, fully local extra:
After initialization and imports (described below):
With pip, use python -m pip install '.[semantic]'. Preparing the model explicitly downloads
weights from Hugging Face and pins their immutable revision. It does not read or send chats.
Indexing and subsequent queries load only local files with remote code disabled.
Quick start
For a synthetic first run, use a separate data directory:
Put private imports and custom data directories outside your repository. The included
.gitignore covers conventional private folders but cannot protect every arbitrarily named path.
Identity must match an exact exported sender name or sender ID. Platform aliases override global
names on that platform. No participant is guessed from message volume. An import matching no
owner messages fails before writing anything. Changing names/aliases recomputes ownership and
interactions and invalidates profiles/vectors; run analyze and index again.
Supported imports
Only chat files are imported. Media is not opened, transcribed, downloaded, or analyzed. Unsupported variants fail clearly. A malformed file rolls back the import as a whole. Original files stay untouched. Content hashes and stable message IDs prevent repeated imports from duplicating rows.
WhatsApp has no stable export thread ID. By default the filename identifies the conversation;
use --conversation-id "stable-chat-name" when importing renamed or refreshed exports.
Offsetless timestamps use a documented UTC convention for wall-clock ordering; they are not
claimed to have been recorded in UTC. Instagram/Snapchat HTML support English export dates.
Generic JSON:
For JSONL, each line is a message with sender, text, timestamp, and an optional
conversation_id. Optional external IDs and reply_to are preserved. Generic identity comes
from configured aliases, never an imported is_user assertion. Use explicit conversation IDs
when importing different datasets; absent IDs use a documented default conversation.
What is measured
persona analyze writes persona.md and persona-profile.json in the private data directory and
stores structured profiles in SQLite. Only outgoing text feeds the analyzer. Incoming text is
kept as bounded retrieval context.
Measurements include character/word/sentence lengths, short message bursts, casing, punctuation, emoji codepoints, repeated characters, common words and phrases, repeated slang/abbreviation forms, greetings, sign-offs, Romanian diacritics, and Romanian/English word markers. Language markers are heuristics, not a language classifier. Emoji counts measure codepoints, not complete grapheme clusters. Repeated phrases/forms need at least three observations; isolated misspellings are not instructions to add typos.
Context labels are explicit and extensible:
Global profiles always use available outgoing text. Separate context/person profiles require at least 20 messages by default. On-demand person statistics report their evidence count. No family, dating, personality, sarcasm, or psychological classification is inferred. Recipient-specific queries conservatively exclude groups. Exact names may occur on multiple platforms; pass a platform to retrieval/writing-context when that distinction matters.
Search and semantic retrieval
SQLite FTS5 searches outgoing messages and incoming interaction contexts. Interactions retain up to three incoming messages and a burst of up to eight outgoing replies. A two-hour gap or a media record breaks pairing; an outgoing burst spans at most five minutes between messages.
The local semantic provider uses sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2.
It embeds incoming contexts and stores float32 vectors in SQLite. Queries use exact cosine scans
over eligible vectors; this favors a simple local architecture over an external vector server.
Indexes resume after interruption. A recipient/context/platform filter applies before ranking.
If eligible vectors are absent, retrieval reports lexical explicitly. A partially built index
reports its coverage. Semantic scores below 0.25 are omitted; these scores are not probabilities
or guarantees of relevance. There is no silent cross-recipient fallback. Future providers can
implement the EmbeddingProvider protocol without changing the import or writing interfaces.
MCP setup
The server uses the official Python MCP SDK and stdio transport. Stdout carries only protocol messages; diagnostic output goes to stderr.
If the data directory has not been initialized yet, serve creates it the same way
persona init does and reports this on stderr; tools return empty results until you import
exports. Usually the client launches this command for you. Use absolute paths because the client's
working directory can differ from your terminal's. Example configuration for clients accepting
the common mcpServers structure:
With uv installed, the client can run the published package directly:
On Windows the command is C:\\absolute\\path\\.venv\\Scripts\\persona.exe. For Codex:
See Codex MCP setup. Other clients may use different configuration locations but need the same executable and arguments. Hosted clients that only support remote HTTP MCP cannot directly launch this local stdio server. PersonaMCP does not include a tunnel/HTTP bridge; exposing sensitive local data remotely requires a separate, explicit deployment decision.
With a prepared semantic model, allow up to 90 seconds for startup and 120 seconds for tools on slower machines. The native numerical runtime is loaded before stdio reader threads start to avoid Windows BLAS loader deadlocks. Weights are loaded on the first semantic query and cached. For Codex these settings belong in the server's configuration table:
Tools:
Historical content is returned inside historical_quote, with an explicit untrusted-data notice.
Tools supply evidence. Your agent generates the final reply and remains responsible for treating
historical instructions as data and for deciding what to send to its model provider.
Skill setup
The reusable skill is skills/write-like-me/SKILL.md. It is also
included in the wheel; persona skill-path prints its installed location. Copy its folder
to the skill directory your agent discovers. For current Codex repository discovery:
Windows PowerShell: New-Item -ItemType Directory -Force .agents/skills followed by
Copy-Item -Recurse skills/write-like-me .agents/skills/. See
Codex skill discovery.
Then ask the connected agent to use write-like-me, for example:
Write a short reply like me to Alex about “mai vii azi la cafea?”. Use PersonaMCP evidence.
The skill preserves supported casing, spelling, vocabulary, and length without forcing typos or
copying old facts. It can also use persona writing-context through a local shell, or an explicitly
supplied profile when MCP is unavailable. No global client configuration is changed by installation.
Privacy and data controls
The default data directory comes from your operating system's application-data location.
--home /private/path or PERSONAMCP_HOME selects another location. Configuration is a local
config.json; the database uses SQLite foreign keys, versioned schema, and transactional imports.
Deletion/reset ask for confirmation; --yes is available for intentional scripting. Deleting a
person removes entire conversations, including groups containing that person, to avoid keeping
context about them. Profiles, FTS rows, and vectors are invalidated/purged and SQLite is vacuumed.
reset also clears configured owner identities but retains downloaded, non-personal model assets.
Original export files and any copied profiles remain in your control and are not deleted.
SQLite is not encrypted. Use a private data directory and disk encryption. Generated vocabulary and examples are sensitive too. If your agent uses an external LLM, tool results may reach that provider; “local-first” describes storage and computation, not the connected client's behavior. Read SECURITY.md for deletion and prompt-injection limits.
Offline benchmark
The last 20% of interactions by timestamp form a holdout. Retrieval and style profiles use only earlier data. The held-out actual reply is used only for scoring. The default candidate is a retrieved historical reply, not an LLM-generated answer.
The report includes retrieval coverage, response-length similarity, vocabulary overlap,
punctuation similarity, capitalization similarity, and their mean Style Similarity Score.
When a local model is available, embedding similarity is reported separately. No raw benchmark
replies are printed. CandidateResponseProvider is the extension point for a future explicitly
configured generator. Scores do not prove identity imitation, authorship, relevance, or generation
quality. Small or temporally uniform datasets cannot support this evaluation.
Architecture
The package uses a src/personamcp layout: importers, models, configuration, storage, analysis,
embeddings, retrieval, shared service, MCP server, CLI, and benchmark. No external database or
LLM provider is required. Schema compatibility is tracked with PRAGMA user_version; older
versions reject a newer database instead of guessing how to read it.
Development, roadmap, and limits
Run uv sync --locked, then uv run pytest, uv run ruff check src tests,
uv run ruff format --check src tests, and uv run mypy src. CI checks Windows/Linux and Python
3.11–3.13, with no personal data or model download. Public fixtures are synthetic. See
CONTRIBUTING.md, CODE_OF_CONDUCT.md, and
implementation decisions.
Next steps are additional export adapters (Discord, Telegram, Messenger, iMessage, Signal), explicit redaction rules, a faster local vector index for very large archives, richer language signals, and optional generation-based evaluation. They are not implemented in this MVP.
This version is a CLI/MCP engine. Export schemas can change; group recipient inference, psychological profiling, automatic typo correction, speech/media analysis, encryption at rest, cloud embedding providers, HTTP hosting, and a frontend are outside its current support.
MIT licensed © Robert Vind-Gardoș (@robyroro). Model weights and dependencies retain their own licenses; see the multilingual MiniLM model card and Sentence Transformers documentation.
来源:README.md,提交 52d546d
工具
0版本历史
1- v0.1.0最新Oct 1, 2026