Hey everyone,
Like many of you, I hit a recurring wall when running long projects with Cursor: the agent forgets architectural decisions between sessions.
The standard fixes usually come with major trade-offs:
- Dumping everything into
.cursorrules: Your baseline token count explodes before you even type a single line, and the model starts suffering from context dilution. - Vector DB plugins: Often pull outdated code snippets because semantic similarity doesn’t understand when a pattern was deprecated or refactored.
Over the weekend, I built and open-sourced a lightweight, zero-cloud MCP server called OpenContext to solve this deterministically using plain markdown in Git.
How this workflow works in Cursor
Instead of cramming rules into the system prompt, Cursor gets two lightweight MCP tools: read_context and save_context.
- Lightweight Index (~100 tokens): Cursor checks an auto-generated topic list and only loads what it actually needs for the current task (e.g.,
read_context("api-contracts")). - In-place updates: When an architectural invariant changes, the agent updates
.opencontext/<topic>.mddirectly. No hallucinated duplicates in vector space. - Git-native & Transparent: Context lives as plain
.mdfiles in your repo. You can review memory updates directly in your Git diffs/PRs or.gitignorethem for private local sessions.
Cursor Setup (1 Minute)
Add this to your Cursor MCP settings (Cursor Settings > Features > MCP or your config file):
{
"mcpServers": {
"opencontext": {
"command": "npx",
"args": ["-y", "opencontext-mcp"]
}
}
}
Recommended Agent Instruction
Add this simple rule to your system prompt or .cursorrules:
“Before making structural changes, check available context using
read_context. Whenever a new architectural decision or invariant is established, record it usingsave_context.”
It’s completely free, MIT-licensed, and runs locally over stdio without third-party services.
- GitHub: https://github.com/slxca/opencontext
- Docs & Details: https://opencntx.dev
Curious to hear how others here are managing persistent architectural rules across sessions—are you mostly sticking to custom rules files or experimenting with MCP tools?