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
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceA 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.162210MIT
- AlicenseBqualityBmaintenanceLocal-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.10111MIT
- AlicenseAqualityCmaintenanceA 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.101MIT
- AlicenseAqualityBmaintenanceA local MCP server that provides AI agents with persistent sticky-note memory, storing Markdown notes on disk and offering tools for creating, reading, updating, deleting, searching, and listing notes across sessions.13MIT
Related MCP Connectors
Markdown-based note-taking with a hosted MCP server. Your notes serve you and your AI.
Person-owned, portable AI memory as a remote MCP server, readable and writable by any MCP client.
Cloud-hosted MCP server for durable AI memory
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/gkrisz22/ai_context'
If you have feedback or need assistance with the MCP directory API, please join our Discord server