
Conventions MCP
io.github.FedgeNo由 GitHub 账号 FedgeNo 发布v3.1.1更新于 Oct 24, 2026
Memory for coding conventions and standing instructions that persists across sessions.
概览
本地记忆服务器,用 SQLite 保存持久的编码约定与常驻指令,让任意 MCP 客户端跨会话、跨项目调用。
- 可以做什么
- 捕获、更新和删除持久规则,按约定、指令、纠正、偏好或其他分类,可加主题标签和项目范围,并回显已存内容供核对。以语义加关键词的混合检索搜索规则,或按类型列出全部记录。一次确定性调用加载全部全局规则和当前项目规则,内置钩子即依赖此调用。统计总数、类型分布、热门主题和各项目数量。
- 适用场景
- 当你反复向 AI 编码助手解释相同的代码风格规则、常驻指令或长期纠正,且希望跨会话、跨仓库生效时使用。适合想要聚焦编码约定而非通用笔记库的用户,尤其是配合 Claude Code 或 Codex 钩子强制加载的场景。
- 运行要求
- 以 npm 包(Node.js)或 git 检出方式在本地通过 stdio 运行;另有仅限本机的 Streamable HTTP 模式。无需 API 密钥或托管服务。首次使用会下载本地嵌入模型(约 130MB)到用户主目录,并需先初始化数据库。项目范围来自工作目录、MCP root 或 X-Conventions-Project 请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Conventions MCP,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
conventions-mcp
Personal memory for durable coding conventions and standing instructions — one store, any MCP-compatible AI client, available in every project. It holds rules like "always use 2-space indent in this language," "never force-push to main," lasting corrections, and long-lived workflow preferences that should carry across future sessions rather than get re-explained every time. It is deliberately not a history of individual jobs or a place for task-specific directions, temporary decisions, current status, or one-off commands.
Why this one
There's no shortage of memory MCP servers — several well-established ones (mem0/OpenMemory, Zep/Graphiti, the official reference memory server, plus a long tail of smaller projects) already do "remember things across sessions." What's different here:
- Narrow taxonomy, not a general note-taking store. Every capture must be a durable rule for future work and gets classified into one of five purpose-built types — convention, instruction, correction, preference, other — plus a project field and topic tags. Task-specific procedures and work history are excluded so retrieval stays precise instead of noisy.
- Deterministic retrieval, not best-effort. Most memory MCPs rely entirely on the calling model noticing a tool description is relevant and deciding to call it — which fails silently and inconsistently. Codex and Claude Code hooks force the agent to call
list_rules:SessionStartsupplies the instruction, whilePreToolUsedenies every other tool until the call has happened. - Transparent by default, not silent. Every capture and update echoes the verbatim stored content and whether it's global or project-scoped back immediately, so a misheard or misclassified rule is visible and correctable on the spot — not something you discover three sessions later via search.
- Fully local at runtime. SQLite + local embeddings, no hosted service, no per-token costs, no API key. The embedding model is downloaded once on first use (or explicitly with
conventions-mcp warmup) and then runs locally. Classification (type/topics/projectScoped) is done by the calling agent at capture time, guided by the tool description — it already has the full conversation the thought came from, richer context than an isolated content string would give a separate extractor model. - Project-scoped without fuzzy matching. A rule can be global (the default) or tied to one specific codebase. Stdio clients derive the project from their working directory; HTTP clients provide an MCP root or an
X-Conventions-Projectheader. The project identifier is never guessed by an LLM from free text.
If what you want is a general-purpose "remember everything" store, or you're not on Claude Code and don't need the hook-driven determinism, one of the more general options above may fit better. This one is for someone who specifically wants a tight, coding-convention-focused memory that stays accurate and doesn't require trusting the model to remember to check it.
What it's tuned to store
Every capture is classified into one of five types by the calling agent, guided by capture_thought's tool description (src/server.js):
Each thought also gets 1–3 topic tags for filtering. This is deliberately narrow — it's not a general note-taking store — but the taxonomy isn't hardcoded logic, it's just the wording of the tool description and its zod schema in src/server.js. Retuning what counts as a convention vs. an instruction, or adding a new type, is a matter of editing that description text, not restructuring the code. The one wrinkle: the five type names are also referenced in the type filter's enum in list_thoughts (src/server.js) — if you rename or add a type, update that enum too or the new type will get rejected as a filter value. Everything's stored as a JSON blob column, so none of this needs a schema migration.
Every thought gets a project field: null applies everywhere; otherwise it
is the normalized absolute path prefixed by path:. Separators are preserved,
so /work/a-b and /work/a/b identify different projects. The calling agent
only decides whether a rule is project-scoped. Existing hyphen-based IDs
require the explicit, backup-first project migration in upgrading.md.
- Storage: SQLite (
better-sqlite3) +sqlite-vecfor native vector search, FTS5 for keyword search, combined via reciprocal rank fusion. One file, no server, no daemon. - Embeddings: local, via
Xenova/bge-small-en-v1.5(384-dim, quantized, ~130MB). Downloads once to~/.conventions-mcp/models, loads lazily, and needs no GPU. - Classification: done by the calling agent (Claude Code, or any MCP client) at capture time, guided by the tool description — no network call, no external model, no API key.
- Transport: MCP over stdio by default, with an optional localhost-only Streamable HTTP mode for running it as a persistent service.
- Proactive retrieval: Codex and Claude Code hooks (see below) load or enforce standing rules at every context boundary — no project instruction file to keep in sync, no dependence on the model happening to notice a tool description is relevant.
- Scoped retrieval:
list_rulesand semantic search return global rules plus the current project's rules; project-specific rules from other codebases stay out of normal retrieval.list_thoughtsremains the explicit all-records management view.
Setup
Installing with an AI coding agent? Give it this repository and ask it to follow the canonical installation and client-integration runbook. The runbook requires path discovery, config merging rather than overwriting, a real capture/list/delete acceptance test, and cleanup of the test record.
Two ways to get this: a git checkout (if you want to read/modify the source) or the npm package (if you just want it running).
Git checkout:
npm package:
No API key or external service is required. Optional database, model-cache,
transport, and timeout settings are listed in .env.example.
Use conventions-mcp --help to inspect the installed commands and
conventions-mcp --version to confirm which release is on PATH. See
SECURITY.md for the local trust model and private reporting
instructions.
Run conventions-mcp doctor for a non-downloading runtime, database, permission,
vector-extension, and model-cache readiness report.
Legacy databases without format metadata require the backup-first
conventions-mcp migrate-storage <absolute-backup-path> command; declared
incompatible formats are rejected rather than guessed.
Persistent local service
Use Streamable HTTP when the MCP client should connect to one boot-managed server instead of launching a stdio child for every session:
Run that command under the operating system's service manager and configure
the MCP client with http://127.0.0.1:47123/mcp. See
docs/shared-service.md for complete systemd,
launchd, and Windows setup and verification instructions. The server rejects
non-local host headers when bound to localhost. MCP_HTTP_HOST defaults to
127.0.0.1 and MCP_HTTP_PORT defaults to 47123.
The service exposes GET /healthz for loopback readiness checks and bounds
retained sessions with MCP_HTTP_MAX_SESSIONS (default 100) and
MCP_HTTP_SESSION_IDLE_MS (default 30 minutes).
HTTP clients that support MCP roots need no additional project configuration.
For clients that do not, set X-Conventions-Project to the absolute project
path in project-local MCP configuration. An HTTP session without either value
receives global rules only and cannot create a project-scoped capture, which
prevents one project's rules from leaking into another project.
Codex can supply the active workspace to a shared HTTP server dynamically:
Codex runs the helper in the active workspace. The server normalizes that
absolute path and prefixes it with path: for its project identifier.
Register with Claude Code
Register at user scope so it's available in every project, not just one repo — use the claude mcp add CLI, not a hand-edited config file:
Either way, this writes to ~/.claude.json's mcpServers key, which is what the CLI actually reads; a mcpServers entry placed directly in ~/.claude/settings.json is silently inert. Verify with claude mcp list. A new Claude Code session is required to pick up a newly-registered server.
Codex standing-rule hook
hooks/hooks.json contains user-scoped Codex SessionStart and PreToolUse hooks. The first tells the agent to call list_rules; the second denies every other tool until that call happens. The gate is re-armed on every start, resume, /clear, and compaction, even if the restored conversation contains an earlier rule load. The rules themselves are not placed in hook output, so a large rule set cannot be truncated before the agent receives it from the MCP tool.
Install it as ~/.codex/hooks.json. If that file already contains hooks, merge this file's SessionStart and PreToolUse entries instead of replacing the existing configuration. The hook expects the MCP server to be registered as conventions, matching the setup command above, and the installed conventions-mcp command to be on PATH. Open /hooks once in Codex to review and trust the newly installed hooks; a new session is required before a startup hook can fire.
Claude Code standing-rule hooks
Checkout users can invoke the absolute Node executable and bin/cli.js path
for Codex hooks too; see installation. A global npm copy is
not required. Hook gates unlock on an attempted list_rules call, including a
failed call; the calling agent must still handle failures and obtain the rules.
Three hooks in ~/.claude/settings.json enforce list_rules before tool use — the first two provide reminders, the third actually enforces it:
bin/session-rules.jsfires at session start and emits a short reminder to calllist_rulesfirst — rather than embedding rule content in the hook output directly, which doesn't scale (a large enough stored rule set gets silently truncated to a small preview before it ever reaches the model). Every invocation re-arms the enforcement gate, including resume, compaction, and/clear, so an earlier load cannot bypass the new instruction.bin/prompt-reminder.jsfires on every turn with a static reminder to follow the loaded conventions and to capture only genuinely durable rules intended for future sessions or repeated work. It explicitly excludes task-specific directions, temporary choices, current status, incident history, one-job commands, and records of how an individual job was completed.bin/pre-tool-check.jsfires before every tool call and denies it outright untillist_ruleshas run this session — the first two hooks are advisory (reminders only), so this is the layer that actually enforces the requirement. It's forced once per session, not once per turn.
None of the three touch the database directly. list_rules resolves the current project from the stdio working directory, an MCP root, or the HTTP project's X-Conventions-Project header.
npm package: the scripts live inside the global install rather than a known clone path — resolve it first with npm root -g, then point the hook at $(npm root -g)/conventions-mcp/bin/session-rules.js the same way.
Windows: point the command at the .cmd wrapper instead of the .js file directly (no node prefix — the batch file invokes it) — bin\session-rules.cmd / bin\prompt-reminder.cmd / bin\pre-tool-check.cmd for a git checkout, or the equivalent path under npm root -g for the npm package.
Tools
Notes
-
Follow
docs/upgrading.mdfor backup-first upgrades, legacy vector migration, guarded restore, and rollback. -
If a single message states several distinct rules,
capture_thoughtgets called once per rule, each relayed individually — not merged into one capture or summarized together. -
The database lives at
data/memory.dbin a git checkout, or~/.conventions-mcp/memory.dbfor the npm package (override either withMEMORY_DB_PATH). It's gitignored and created with private permissions. Useconventions-mcp backup <absolute-destination>for a live-safe, integrity-checked backup.docs/shared-service.mdshows a scheduled setup. -
The embedding model and dimension are declared in
src/storage-format.js. A model change requires an explicit storage migration that re-embeds existing rules; changing the constant alone makes existing stores incompatible.
来源:README.md,提交 0d0b647
工具
0版本历史
1- v3.1.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分