Persistent memory for AI coding agents, built on MCP
memcp is a persistent memory layer for AI coding assistants, built as an MCP (Model Context Protocol) server. It gives LLM agents the ability to remember findings, evolve their persona, and build domain expertise across chat sessions.
π§ Work in Progress β Core functionality is implemented. Contributions, feedback, and ideas are welcome!
graph TD
IDE["π₯οΈ IDE (Cursor / VS Code)"]
IDE --> SM["Standalone MCP<br/><i>agent_recall, agent_save, agent_session</i>"]
IDE --> CM["Composed MCP<br/><i>Proxy backend MCP servers + agent tools</i>"]
IDE --> SH["Shim Mode<br/><i>Transparent observation pipe</i>"]
SM --> CE
CM --> CE
SH --> CE
CE{"βοΈ Core Engine<br/>Memory Manager Β· Context Builder<br/>Observer Β· Persona Β· Session Mgr<br/>Skills Router"}
CE --> DB[("πΎ SQLite (WAL)<br/>findings Β· tool_calls<br/>sessions Β· profile")]
CE --> SF["π Soul Files<br/>SOUL.md Β· IDENTITY.md Β· MEMORY.md"]
DB -- "Evolution Loop π" --> SF
DA["π€ Daemon (optional)"] --> CE
DA --> J["Jira"]
DA --> E["Email"]
DA --> G["Git"]
style IDE fill:#1a1a2e,stroke:#e0e0e0,color:#fff
style SM fill:#0d3b42,stroke:#00d2ff,color:#fff
style CM fill:#2d1b4e,stroke:#a855f7,color:#fff
style SH fill:#3b2e1a,stroke:#f59e0b,color:#fff
style CE fill:#1a1a3e,stroke:#6366f1,color:#fff
style DB fill:#1a2a1a,stroke:#22c55e,color:#fff
style SF fill:#2a1a1a,stroke:#ef4444,color:#fff
style DA fill:#1a1a2e,stroke:#8b8b8b,color:#fff
| Feature | Description |
|---|---|
| Hybrid Semantic Memory | Save and recall findings using Ollama Vector Embeddings and pure-Go Cosine Similarity (fallback to FTS5) |
| Soul / Persona System | Three-file persona (SOUL.md, IDENTITY.md, MEMORY.md) that evolves as the agent works |
| ADD / UPDATE / NOOP Pipeline | Smart deduplication β new facts are added, existing facts are merged, redundant facts are skipped |
| Credential Sanitization | Passwords, tokens, and secrets are auto-redacted before storage |
| Tiered Context Recall | Budget-aware context assembly from persona, working memory, findings, and history |
| Session Management | Organize work into named sessions |
| Observer System | Transparent fact extraction from tool calls (environments, errors, trace IDs) |
| Evolution System | Automatically distills findings into learned patterns in persona files |
| Domain Skills | Pluggable skill files that partition memory by domain with independent evolution |
| Background Daemon | Optional task queue polling external services (Jira, email, Git) |
| Three Operating Modes | Standalone, Composed (proxy backends), or Shim (transparent observation) |
- Go 1.25+
- An MCP-compatible IDE (e.g., Cursor, VS Code)
- Ollama (Optional, but highly recommended for Semantic Vector Search)
git clone https://github.com/sivakumar455/memcp.git
cd memcp
make build # builds bin/memcpAdd to your IDE's MCP configuration:
{
"mcpServers": {
"memcp": {
"command": "/path/to/memcp",
"env": { "MEMCP_CONFIG": "standalone" }
}
}
}| Tool | Description |
|---|---|
agent_recall |
Recall context from persistent memory (call first every conversation) |
agent_save |
Save a finding to persistent memory |
agent_session |
Manage chat sessions (list, create, switch) |
# Agent recalls context at start of conversation
agent_recall(query="timeout certificate staging")
# Agent saves a discovery
agent_save(key="service-x-rootcause", content="Root cause: expired certificate", tags="rootcause,timeout", importance=2)
# Agent manages sessions
agent_session(operation="create", name="PROJ-1234-investigation")
Standard MCP server over stdio. Provides agent_* tools alongside other MCP servers registered independently.
Spawns backend MCP servers as subprocesses and proxies their tools. Every tool call is automatically observed β facts are extracted and persisted.
{
"mcpServers": {
"memcp": {
"command": "/path/to/memcp",
"env": { "MEMCP_CONFIG": "composed" }
}
}
}Acts as a transparent stdio pipe between IDE and any backend MCP server. Observes all tool calls without altering behavior.
{
"mcpServers": {
"my-backend": {
"command": "/path/to/memcp",
"args": ["--shim", "--name", "my-backend", "--", "/path/to/backend-mcp", "--stdio"]
}
}
}Enable background polling with --daemon flag or MEMCP_DAEMON=true. Works with any mode.
memcp's persona system uses three markdown files that define and evolve the agent's identity:
soul/
βββ SOUL.md β Immutable core personality (you control this)
βββ IDENTITY.md β Domain knowledge + auto-generated "Learned Patterns"
βββ MEMORY.md β Accumulated findings with progressive summarization
- SOUL.md β Never modified by the system. Defines behavior, boundaries, and working style.
- IDENTITY.md β Contains your domain knowledge plus a
## Learned Patternssection that auto-updates. - MEMORY.md β Entirely managed by evolution. Findings are organized by age (active β recent β archived).
Configuration is loaded from configs/standalone.yaml. Override with environment variables:
| Env Var | Description |
|---|---|
MEMCP_CONFIG |
Config file name (default: standalone) |
MEMCP_DATA_DIR |
Data directory for DB, soul files, logs |
MEMCP_LOG_LEVEL |
Log level: debug, info, warn, error |
memcp/
βββ cmd/memcp/ # Main binary
β βββ main.go
β βββ extensions_site.go # Company extensions (build tag: site)
βββ extensions/ # Upstream extension examples
β βββ webhook/ # Generic webhook watcher
βββ configs/
β βββ standalone.yaml # Default config
βββ soul/ # Default persona templates
β βββ SOUL.md # Immutable core personality
β βββ IDENTITY.md # Evolving domain knowledge
β βββ MEMORY.md # Auto-populated findings
βββ skills/ # Default skills (empty, user-populated)
βββ internal/ # Core library
β βββ config/ # Configuration loading
β βββ engine/ # Core orchestrator
β βββ memory/ # SQLite store (CRUD, FTS5, vector search)
β βββ mcp/ # MCP server + tool handlers
β βββ session/ # Session lifecycle
β βββ persona/ # Soul/persona file loader
β βββ observation/ # Tool call observer
β βββ evolution/ # Soul evolution system
β βββ skills/ # Domain skill routing
β βββ daemon/ # Background task queue
β βββ gateway/ # HTTP gateway server
β βββ shim/ # Transparent observation proxy
β βββ embedding/ # Ollama vector embeddings
β βββ webui/ # Live dashboard
β βββ logger/ # Structured logging
βββ site/ # Company overrides (excluded from upstream)
β βββ configs/ # Company-specific configs
β βββ soul/ # Company persona files
β βββ skills/ # Domain-specific skills
β βββ extensions/ # Company watchers (Jira, email, etc.)
βββ scripts/setup.go # Bootstrap script for ~/.memcp
βββ data/ # Auto-created at runtime
βββ memory.db # SQLite database
memcp supports compile-time extensions via Go build tags and the site/ directory.
- Upstream extensions live under
extensions/(e.g.,extensions/webhook/). - Company/private extensions live under
site/extensions/and are gated behind thesitebuild tag. - The
site/directory is excluded from upstream via.gitattributes.
Create a new directory under extensions/ implementing the Watcher interface:
package myext
import "github.com/sivakumar455/memcp/internal/daemon"
type MyWatcher struct{}
func NewWatcher() *MyWatcher { return &MyWatcher{} }
func (w *MyWatcher) Name() string { return "my-extension" }
func (w *MyWatcher) Poll(ctx context.Context) ([]daemon.Event, error) { ... }
func (w *MyWatcher) Close() error { return nil }Register it in cmd/memcp/main.go's registerExtensions.
# Upstream build (no site extensions):
make build
# Full build with site extensions:
go build -tags site -o bin/memcp ./cmd/memcpThe site/ directory is never part of upstream, so pulling updates is conflict-free:
git subtree pull --prefix=memcp-servers/memcp memcp-upstream main --squash
make buildContributions are welcome! See CONTRIBUTING.md for guidelines.
Areas where help is especially appreciated:
- Testing β Unit and integration tests
- Daemon Watchers β GitHub Issues, Slack, etc.
- New Skill Domains β Skill files for common dev domains
- Cross-platform β Testing on Windows and Linux
This project is licensed under the MIT License.
Built with β€οΈ for the MCP ecosystem