agent-context
agent-context-mcp
为 AI 编码代理提供持久化、与工具无关的项目记忆。
一个无状态的 MCP 服务器,让任何代理(Claude Code、Codex、Kilo Code、OpenCode、Cursor)都能对每个项目中的 ai_context/ 纯 Markdown 文件夹进行结构化读写。决策、计划、约束和笔记都存放在仓库中,通过 git 同步,并且即使代理未安装该服务器也能读取。
代理决定何时记录以及记录什么。服务器决定格式和位置。这种主观设计正是关键:如果让代理自由写入,文件夹很快就会变成一团糟。
它不是什么
没有代码检索、没有语义搜索、没有嵌入、没有数据库、没有守护进程状态。纯粹的文件 I/O。它与代码搜索工具互补,而非竞争。
Related MCP server: Jarvis Markdown MCP
安装
需要 Node ≥ 18。无需全局安装任何东西——下面每个工具都通过 npx 运行它。
npx agent-context-mcp initinit 会创建 ai_context/ 骨架,生成 project.md 和 constraints.md 的模板,将激活片段追加到 AGENTS.md,并打印你的工具所需的注册块。它绝不会覆盖已有文件。
注册到你的工具
Claude Code,在项目根目录下:
claude mcp add agent-context -- npx -y agent-context-mcp .或者提交一个 .mcp.json,让整个团队都能使用:
{
"mcpServers": {
"agent-context": {
"command": "npx",
"args": ["-y", "agent-context-mcp", "."]
}
}
}Codex,在 ~/.codex/config.toml 中:
[mcp_servers.agent-context]
command = "npx"
args = ["-y", "agent-context-mcp", "."]Kilo Code、OpenCode、Cursor、Windsurf 以及其他 MCP 客户端,在其各自的设置文件中使用相同的 mcpServers JSON 块。
末尾的 . 让服务器将工具的工作目录视为项目根目录。如果你的工具从其他位置启动,请改为传递绝对路径。传输仅支持 stdio。
AGENTS.md 片段
init 会追加此内容;如果你不想运行 init,也可以手动添加。它才是真正让代理使用这些工具的关键:
## Persistent project context
This project uses the agent-context MCP server. At session start, call
`get_context` (no arguments) to orient yourself. When you make or the user
confirms a significant architectural/technical decision, call
`record_decision`. Persist gotchas and conventions with `record_note`.
Human-curated ground truth lives in ai_context/project.md and
ai_context/constraints.md — read them, never contradict them.文件夹
<project-root>/
AGENTS.md entry point — yours, never written except by `init`
ai_context/
INDEX.md auto-maintained table of contents (server-owned)
project.md what this project is (yours; server reads, never writes)
constraints.md hard rules and good practices (yours; read-only to the server)
memory.md notes, written via record_note
decisions/
0001-use-postgres.md ADRs, written via record_decision
plans/
auth-refactor.md mutable plans, written via update_planai_context/在首次写入时惰性创建,或由init预先创建。INDEX.md在每次写入后重新生成,并每次从磁盘重新扫描。切勿手动编辑。决策是仅追加的。取代一个决策意味着记录一个新的决策并引用它;对现有 ADR 的唯一编辑是添加
- Superseded-by: NNNN元数据行。计划是可变的——
update_plan会覆盖。project.md和constraints.md是人工维护的真相来源。服务器只读取它们,从不写入。
工具
工具 | 输入 | 功能 |
|
| 读取索引(默认)、 |
|
| 将 |
|
| 在 |
|
| 创建或完全覆盖 |
| — | 列出 |
长度上限是刻意的防混乱纪律,而非存储限制:标题 80 字符,ADR 各节 1200 字符,笔记 500 字符,计划 8000 字符。超出限制会返回一条消息,说明实际长度和限制,以便代理总结后重试。
没有 search_context。对一个小型 Markdown 文件夹进行 grep 就足够了,而且代理已经具备该能力。
安全性
每个路径都通过单一守卫解析;
ai_context/之外的内容绝不会被读取或写入,slug 或 topic 中的路径遍历会被拒绝,而不是被静默清理成其他内容。写入先进入临时文件,再重命名到位,因此崩溃不会留下半写入的文件。
调用之间无状态,无缓存。来自人工、
git pull或其他代理的编辑会在下次调用时被拾取。
开发
npm install
npm test # unit + stdio integration tests
npm run typecheck # sources and tests
npm run build许可证
MIT
Available Tools
5 toolsget_contextGet project contextARead-only
Read the project's persistent AI context: index, project description, constraints, decisions, plans, memory. Call with no arguments at session start to orient yourself.
| Name | Required | Description | Default |
|---|---|---|---|
| topic | No | What to read. One of "index" (default, the table of contents), "project", "constraints", "memory", "decisions" (list only), "plans" (list only), a decision ID like "0003", or a plan slug. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations declare readOnlyHint=true and openWorldHint=false, so the description does not repeat that. It adds context about the content being 'persistent' and that 'index' is the default topic, which is useful. However, it does not disclose details like what happens if a topic is not found, or the exact format of the response (e.g., plain text vs JSON). Since annotations already cover safety, a 3 is appropriate—description adds some value but lacks behavioral depth beyond the schema.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences: the first lists what the tool reads, the second gives a clear usage instruction. No fluff, every word earns its place. It front-loads the purpose and immediately follows with actionable guidance, making it highly scannable for an AI agent.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity (single optional parameter, no output schema, benign read operation), the description is nearly complete. It explains the tool's role and how to invoke it. However, it could mention what happens with a specific decision ID (like returns that decision) but that is implied. The lack of output schema means the description should hint at the format, but since the schema already covers parameters, this is still rated high.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents each topic value. The description adds a little by mentioning 'index' as default and that 'decisions' and 'plans' are list-only, which is not in the schema. It also explains the purpose of the parameter ('What to read'). Since schema does the heavy lifting, a 3 is baseline, but the extra specification of list-only and default raises it to 4.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool reads the project's persistent AI context and lists the specific content types (index, project description, constraints, decisions, plans, memory). It distinguishes itself from siblings like record_note and record_decision by emphasizing it is a read operation, and it differentiates from list_context by targeting specific context areas. The verb 'Read' plus the resource 'persistent AI context' is specific and actionable.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly instructs to call with no arguments at session start to orient, which is a clear when-to-use guideline. It also implies that for listing all context, you might use list_context, but it does not explicitly exclude alternatives. However, the instruction to use at session start is a strong usage signal, and the sibling list_context likely covers the 'when not' implicitly. The guidance is clear and actionable.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_contextList context filesARead-only
List all files in the project's ai_context folder with sizes and dates.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| files | Yes | Every file under ai_context/, empty when the folder does not exist yet. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true, and the description is fully consistent with that. It adds useful behavioral context by specifying the scoped folder and that sizes and dates are included, which helps the agent know what to expect beyond the annotation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clearly worded sentence that immediately states the action, target, and output contents. No wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter, read-only listing tool with an output schema available, the description is complete. It names the exact folder and the output attributes, and the annotations plus output schema cover the remaining context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are zero parameters, so the schema provides no burden for the description to explain. Baseline of 4 is appropriate because no parameter semantics are needed.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('List') and resource ('all files in the project's ai_context folder') and adds output details ('with sizes and dates'). This clearly distinguishes it from sibling tools like get_context, which likely retrieves a single file, and record_note/record_decision, which are write operations.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly indicates the tool is for listing all context files in a specific folder, which implies its use when an overview is needed. It does not explicitly mention when not to use it or name alternatives, but the context is clear enough for the simple listing case.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
record_decisionRecord a decisionA
Record an architectural or otherwise important project decision as a permanent ADR. Call this whenever you make or the user confirms a significant technical choice.
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Short decision title, max 80 chars. | |
| context | Yes | Why this came up — forces and constraints. Max 1200 chars. | |
| decision | Yes | What was decided, stated plainly. Max 1200 chars. | |
| supersedes | No | ID of a decision this replaces, e.g. "0003". Must already exist. | |
| consequences | Yes | What this makes easier or harder afterwards. Max 1200 chars. |
Output Schema
| Name | Required | Description |
|---|---|---|
| id | Yes | Zero-padded decision ID. |
| path | Yes | Path of the new ADR, relative to the project root. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description adds behavioral context beyond the annotations by specifying that the record is 'permanent' and an 'ADR', implying immutability and a formal structure. It does not enumerate side effects, but this is sufficient given the write intent and non-destructive annotation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—two sentences that cover purpose and usage—with no redundancy or filler. It front-loads the key action and includes a clear trigger condition.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description provides sufficient context for the tool's role (permanent ADR storage) and when to invoke it, and combined with the detailed schema, it gives a complete picture for the simple use case. It does not mention return values or errors, but that is not required given the lack of an output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema already provides detailed descriptions for each parameter (e.g., 'Short decision title, max 80 chars.'), and the tool description does not add additional semantic meaning to the parameters. Thus, it meets the baseline for schema coverage without enhancing parameter understanding.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states that the tool records architectural or important project decisions as permanent ADRs, and specifies when to call it (upon making or confirming a significant technical choice). This distinguishes it from sibling tools like record_note and update_plan.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides a clear trigger condition ('Call this whenever you make or the user confirms a significant technical choice'), which guides usage. It does not explicitly contrast with record_note, but the phrasing implies a decision-specific use case, making the guidance effective.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
record_noteRecord a noteA
Persist a short project note: a gotcha, convention, learning, or todo that future sessions should know.
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | The note itself, one sentence or two. Max 500 chars. | |
| category | Yes | Which section of memory.md the note belongs in. |
Output Schema
| Name | Required | Description |
|---|---|---|
| path | Yes | Path of memory.md, relative to the project root. |
| category | Yes | The section the note was filed under. |
| duplicate | Yes | True when an identical note already existed and nothing was written. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations are not contradictory: readOnlyHint=false, openWorldHint=false, destructiveHint=false. The description conveys a write operation but doesn't discuss overwriting, updates, or whether existing entries get merged. It adds the intended persistence context, which annotations alone would not provide.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One sentence, 3 clauses, completely dense, no filler. Packs a lot of informational words: resource, content categories, purpose. Well-formatted and front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
There is an output schema, a simple model, and sibling tools that create no ambiguity. The description doesn't explain all edge cases like duplicates or retention policy, but with full schema and a single-purpose persist tool this reaches the high end of viable.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema covers both params (content, category) at 100% coverage with descriptions. The 'category' description specifies which memory section it belongs to, and 'content' adds length/format limits. Description here slightly enriches the schema on intended use.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses the specific verb 'persist' with the resource 'project note' and lists note types (gotcha, convention, learning, todo), distinguishing it from sibling tools that manage context, decisions, plans, or context lists. It does not explicitly name alternative tools or when-not conditions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description states the note should be remembered by future sessions, implying cross-session persistence. It doesn't mention when to prefer this over alternatives, but the category and memory intent provide clear context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
update_planCreate or overwrite a planADestructiveIdempotent
Create or fully overwrite a named project plan. Plans are mutable working documents, unlike decisions.
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Plan name; slugified for the filename. Max 50 chars of slug. | |
| content | Yes | Full markdown body — this replaces the file. Max 8000 chars. |
Output Schema
| Name | Required | Description |
|---|---|---|
| path | Yes | Path of the plan, relative to the project root. |
| slug | Yes | Slug the plan is stored under. |
| created | Yes | True for a new plan, false when an existing one was replaced. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare destructiveHint=true and idempotentHint=true; the description's 'fully overwrite' confirms this but adds no major new behavioral detail beyond the 'mutable working documents' framing. With annotations present, the added value is modest.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence that is front-loaded with the core action and includes a meaningful comparison. No filler or redundant content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With complete parameter schema, annotations covering destructive/idempotent behavior, an output schema present, and sibling differentiation, the description is sufficient for a simple two-parameter tool. Nothing critical is missing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with detailed explanations for both parameters including slugification and file replacement. The description itself adds no parameter-level semantics, so the baseline score of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb and resource ('Create or fully overwrite a named project plan') with clear scope. It also differentiates from siblings by contrasting plans with decisions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides context that plans are mutable working documents 'unlike decisions', indicating when this tool should be used over the decision-recording alternative. It does not explicitly enumerate all sibling alternatives or state when not to use it for other tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
get_context - First observed
list_context - First observed
record_decision - First observed
record_note - First observed
update_plan
TDQS
Scored across 5 tools
Each tool targets a distinct action: reading full context, listing files, recording a note, recording a decision, and updating a plan. The only potential overlap is between get_context and list_context, but their descriptions clearly differentiate content retrieval from file listing.
All tool names follow a consistent verb_noun pattern (get_context, record_note, record_decision, update_plan, list_context) using snake_case. The verbs are descriptive and the pattern is uniform across the set.
With 5 tools, the server is well-scoped for managing AI context. Each tool serves a clear purpose without redundancy, and the count is appropriate for the narrow domain.
The set covers the core workflow: reading the full context, listing stored files, and writing notes, decisions, and plans. Minor gaps exist (e.g., no direct note or decision deletion/editing), but these are acceptable given the 'permanent' nature of decisions and the mutable plan overwrite capability.
Maintenance
Related MCP Connectors
One memory, every AI. A shared, user-owned markdown memory your AI clients read and write over MCP.
Hosted MCP memory for coding agents: persistent across sessions, editable markdown, team sharing.
Markdown-based note-taking with a hosted MCP server. Your notes serve you and your AI.
Google Keep-style notes app with an MCP server for AI agents to read/write notes.
Related MCP Servers
- AlicenseAqualityCmaintenanceA self-hosted MCP server that gives AI agents shared, long-term memory over a git-backed folder of markdown, enabling persistent knowledge search, read, and write without a database.1667 npm18MIT
- AlicenseBqualityDmaintenanceLocal-first memory server for AI coding agents that stores work sessions, tasks, and durable memories in Markdown files, exposed through MCP tools for session management and memory retrieval.1011 npm1MIT
- AlicenseAqualityBmaintenanceA local-first MCP server that provides a shared Markdown-based memory for AI coding agents, enabling cross-agent context persistence via tools like memory_search and memory_capture.161MIT
- AlicenseNot gradedqualityDmaintenanceMCP server providing persistent, local-first memory for AI agents via Markdown files in a git repo, with search, branching, and auditability.5 npm2MIT