agent-context

agent-context

A stateless MCP server providing persistent, structured project memory for AI coding agents via a markdown folder. It allows agents to record decisions, plans, and notes, which are stored and synced with git.

Category
访问服务器

README

agent-context-mcp

Persistent, harness-agnostic project memory for AI coding agents.

A stateless MCP server that gives any agent — Claude Code, Codex, Kilo Code, OpenCode, Cursor — structured read/write access to a per-project ai_context/ folder of plain markdown. Decisions, plans, constraints and notes live in the repo, sync via git, and stay readable by agents that do not have the server installed.

The agent decides when and what to record. The server decides format and location. That opinionation is the point: give an agent free-form writes and the folder degrades into sludge.

What it is not

No code retrieval, no semantic search, no embeddings, no database, no daemon state. Pure file I/O. It composes with a code-search tool rather than competing with one.

Install

Needs Node ≥ 18. Nothing to install globally — every harness below runs it through npx.

npx agent-context-mcp init

init creates the ai_context/ skeleton, stubs project.md and constraints.md, appends the activation snippet to AGENTS.md, and prints the registration block for your harness. It never overwrites an existing file.

Register with your harness

Claude Code, from the project root:

claude mcp add agent-context -- npx -y agent-context-mcp .

Or commit a .mcp.json so the whole team gets it:

{
  "mcpServers": {
    "agent-context": {
      "command": "npx",
      "args": ["-y", "agent-context-mcp", "."]
    }
  }
}

Codex, in ~/.codex/config.toml:

[mcp_servers.agent-context]
command = "npx"
args = ["-y", "agent-context-mcp", "."]

Kilo Code, OpenCode, Cursor, Windsurf and other MCP clients take the same mcpServers JSON block in their own settings file.

The trailing . makes the server treat the harness's working directory as the project root. Pass an absolute path instead if your harness starts elsewhere. Transport is stdio only.

AGENTS.md snippet

init appends this; add it by hand if you would rather not run init. It is what actually makes agents use the tools:

## 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.

The folder

<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_plan
  • ai_context/ is created lazily on the first write, or up front by init.
  • INDEX.md is regenerated after every write and re-scanned from disk each time. Never hand-edit it.
  • Decisions are append-only. Superseding one means recording a new one that references it; the only edit ever made to an existing ADR is a - Superseded-by: NNNN metadata line.
  • Plans are mutable — update_plan overwrites.
  • project.md and constraints.md are human ground truth. The server reads them and never writes them.

Tools

Tool Input What it does
get_context topic? Reads the index (default), project, constraints, memory, decisions or plans lists, a decision ID like 0003, or a plan slug.
record_decision title, context, decision, consequences, supersedes? Writes decisions/NNNN-<slug>.md as an ADR and links the superseded one both ways.
record_note category, content Appends a dated bullet to memory.md under Gotchas / Conventions / Learnings / Todos. Identical notes are deduplicated.
update_plan name, content Creates or fully overwrites plans/<slug>.md.
list_context — Lists every file under ai_context/ with size and last-modified date.

Length caps are deliberate anti-sludge discipline, not storage limits: title 80 chars, ADR sections 1200 each, notes 500, plans 8000. Exceeding one returns a message stating the actual length and the limit so the agent can summarize and retry.

There is no search_context. Grep over a small markdown folder is enough, and agents already have it.

Safety

  • Every path is resolved through a single guard; nothing outside ai_context/ is ever read or written, and traversal in a slug or topic is rejected rather than quietly sanitized into something else.
  • Writes go to a temp file and are renamed into place, so a crash cannot leave a half-written file.
  • No state between calls, no caches. Edits from a human, a git pull or another agent are picked up on the next call.

Development

npm install
npm test          # unit + stdio integration tests
npm run typecheck # sources and tests
npm run build

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选