Agent Memory Engineのロゴ

Agent Memory Engine

コミュニティ
uudam42

Memory Engine is a local-first MCP server that gives coding agents persistent, evidence-backed project memory. It automatically builds a project knowledge base, retrieves relevant architecture, constraints, incidents, and source context before complex tasks, and retains verified lessons after successful work.

公開者uudam42
リポジトリagent-memory-engine
言語Python
フォーク
2
スター
127
利用可能なツール
0
通信方式stdio
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    Agent Memory Engineは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには127件のスターと2件のフォークがあります。


Agent Memory Engine

A local-first MCP runtime that gives coding agents persistent, evidence-backed project memory and grounded project knowledge across sessions.


Why it exists

Coding agents face a fundamental problem: every session starts cold.

  • They forget project context between sessions.
  • They repeatedly scan repositories to re-learn what modules do.
  • They lose debugging lessons and historical decisions.
  • Flat RAG cannot distinguish stable constraints, past incidents, architecture decisions, and raw code evidence.
  • Even large context windows still require intelligent prioritization and token budgeting.

Memory Engine solves this by maintaining a structured, evidence-backed memory tree alongside an indexed project knowledge base — both local, both automatic, no infrastructure required.


Core capabilities

CapabilityDetails
Persistent memory treeMemoryNode hierarchy: constraints, architecture, modules, decisions, incidents, procedures
Evidence-backed memoryEach node links to source Evidence entries (test output, code references, review notes)
Candidate stagingReflection generates MemoryCandidates before promoting to the live tree
Confidence-aware promotioncreate / update / merge / supersede / discard / needs_review
Conflict detectionHigh-risk areas (auth, schema, state-machine, retry) flagged for review
Ancestor consolidationParent node summaries auto-updated after each promotion
Agent-native recallIntent-aware retrieval before coding tasks — no manual queries
Progressive inspectionDrill down into any memory node, its children, and linked evidence
Automatic post-task reflectionAgent reports outcome → system decides whether and how to retain knowledge
Knowledge ingestionMarkdown, code, ADR, test reports, runtime logs, git diffs
Local FTS5 searchSQLite FTS5 with porter tokenizer; no external search engine
Optional semantic retrievalPersistent local sqlite-vec backend with sentence-transformers / Ollama / FastEmbed (ONNX Runtime) embeddings (Phase 13); default OFF, no required deps
Lexical structured fallbackFull retrieval without vector backend or Docker
Unified ContextPackMemory + knowledge merged, deduplicated, token-budgeted
Retrieval traceabilityPer-signal score breakdown in every response
Local-first privacyAll data stays inside .memory-engine/; no telemetry, no cloud calls
Python MCP serverstdio transport; no TypeScript, no Docker, no external daemon
Zero-touch bootstrapAuto-initializes on first MCP connection
Incremental indexingJSON manifest; only changed files re-indexed on subsequent runs
Git-aware synchronizationDetects branch, HEAD commit, staged/modified files via safe read-only Git commands
Branch-aware retrievalPrefers memory from the current branch; falls back to mainline then global
Branch-scoped memory writesNew memories stamped with branch name and scope; mainline promotion is explicit
Multi-granularity memoryFour retrieval layers (proposition → paragraph → chunk → module summary) created at write-time; selected at query-time by intent
Deterministic proposition extractionAtomic facts extracted from docstrings, security comments, raise statements, markdown bullets — no LLM required
Intent-aware granularity routingbug_fix retrieves constraint/risk propositions; architecture_review retrieves module summaries
Query-time context assemblyProposition hits optionally expand to parent paragraphs; architecture queries attach module summaries
Memory retention & compactionCandidate expiry, stale/superseded archival, multi-source compaction with full lineage — no physical deletion
Protected memory typesconstraint, security_rule, architecture, decision excluded from all auto-archive and auto-compaction
Agent memory policyCanonical AGENT_MEMORY_POLICY.md auto-installed to CLAUDE.md / .cursor/rules/ on first bootstrap; CLI available for manual control
Project context seedingseed_project_context MCP tool + memory seed CLI wizard — write initial constraints, decisions, and project overview on day 1, eliminating the cold-start problem
Windows installerPowerShell installer (scripts/install.ps1) for Windows-native setup without Docker, WSL, or cloud services

Quick Start

macOS / Linux:

bash
git clone https://github.com/uudam42/agent-memory-engine.git
cd agent-memory-engine
bash scripts/install.sh

Windows (PowerShell):

powershell
git clone https://github.com/uudam42/agent-memory-engine.git
cd agent-memory-engine
.\scripts\install.ps1

The installer checks Git and Python 3.11+, installs uv when needed, resolves dependencies, runs a health check, and prints a ready-to-copy MCP configuration for Cursor or Claude Code. No Docker, WSL, or cloud services required.

Default Deployment Model

Agent Memory Engine runs locally as a stdio MCP server. The default setup uses Python, uv, and local SQLite/FTS5 storage. Docker, cloud databases, and external embedding services are not required for the standard local workflow.

MCP Stdio Mode (recommended)

Runs locally through the MCP client using uv run. Supported by Cursor, Claude Code, and any client that implements the MCP stdio transport.

Option A — explicit project root (Cursor, most clients):

json
{
  "mcpServers": {
    "memory-engine": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/agent-memory-engine",
        "memory-engine-mcp",
        "--project-root",
        "/absolute/path/to/your-project"
      ]
    }
  }
}

Option B — project root via environment variable (Claude Code):

json
{
  "mcpServers": {
    "memory-engine": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/agent-memory-engine",
        "memory-engine-mcp"
      ],
      "env": {
        "MEMORY_ENGINE_PROJECT_ROOT": "/absolute/path/to/your-project"
      }
    }
  }
}

Note: Replace all /absolute/path/to/... with real paths on your machine. Config file location and workspace-variable support differ by client:

  • Cursor: .cursor/mcp.json or global Cursor MCP settings
  • Claude Code: ~/.claude.json or project-level config
  • Run bash scripts/install.sh to get a pre-filled config block with your actual paths.

FastAPI / HTTP Mode (optional)

A FastAPI application (memory_engine/main.py) is included for direct API experimentation, demos, or containerized environments. It is not required for the standard MCP workflow.

bash
uvicorn memory_engine.main:app --reload
# API docs at http://localhost:8000/docs

Manual setup (advanced)

bash
# Install uv once
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv sync

# Run MCP server directly
uv run memory-engine-mcp --project-root /path/to/project --log-level DEBUG

Open your target project and start coding

That's it. Memory Engine starts automatically on the first MCP connection and handles bootstrap, indexing, and memory management from there.


What happens automatically

User opens project
     │
     ▼
MCP client starts memory-engine-mcp via stdio
     │
     ▼
Project root resolved (.git / pyproject.toml / package.json marker)
     │
     ▼
.memory-engine/ created (if first use)
     │
     ▼
README, ADRs, architecture docs, constraints indexed first
     │
     ▼
Broader source files indexed incrementally in background
     │
     ▼
Agent starts non-trivial coding task
     │
     ▼  [automatic]
retrieve_agent_context called
     │   → relevant constraints, incidents, decisions, procedures, source refs
     │
     ▼
Agent implements and validates
     │
     ▼  [automatic, on success]
reflect_and_write called
     │   → system evaluates retention gates
     │   → creates MemoryCandidates if worthy
     │   → promotes to memory tree
     │   → consolidates ancestor summaries
     │
     ▼
memory_status shows updated counts

Architecture


Agent calling chain


Memory lifecycle

Task result
    │
    ▼
ReflectionSkill.analyze()
    │  gates: outcome ≠ failed/reverted, verification_status, confidence ≥ threshold,
    │         summary word count, known-trivial patterns
    │
    ├─ skip → return {skip_reason}
    │
    └─ pass ▼
    │
MemoryCandidate generation
    ├─ constraint     (importance 0.92)
    ├─ procedure      (importance 0.72)
    ├─ incident/debug (importance 0.85)
    ├─ module         (importance 0.62)
    └─ decision       (importance 0.82)
    │
    ▼
PromotionService.promote()
    ├─ create     — new node
    ├─ update     — same title, content refreshed
    ├─ merge      — near-duplicate (Jaccard ≥ 0.80)
    ├─ supersede  — existing node confirmed wrong
    ├─ discard    — low value / already known
    └─ needs_review — conflicts with high-confidence existing node
    │
    ▼
ConsolidationService.update_ancestors()
    │  parent.summary = concat(children.summaries)
    ▼
cache invalidated + memory_revision bumped

Node statuses

StatusMeaningDefault retrieval
candidateStaged, pending promotion decisionExcluded
activeLive, returned in recallIncluded
staleOutdated; preserved for historyPenalized
supersededReplaced by newer nodeExcluded
needs_reviewFlagged conflict; human review recommendedExcluded
archivedHistorical / audit-only (Phase 11)Excluded
compactedSynthesis of source memories (Phase 11)Included with lineage
expiredCandidate never promoted past window (Phase 11)Excluded

Phase 11: Memory Retention

Memory does not grow indefinitely. The MemoryRetentionService runs lifecycle transitions:

bash
# Diagnose
memory retention status <project>
memory retention report <project>

# Apply (dry-run by default)
memory retention run <project>
memory retention run <project> --no-dry-run

# Restore an archived memory
memory retention restore <project> <memory-id>

Protected types (constraint, security_rule, architecture, decision) are never auto-archived or auto-compacted.

See docs/memory_retention_compaction.md.


Knowledge lifecycle

Documents / code / ADRs / tests / logs / diffs
    │
    ▼
redact()  ← 8 patterns: API keys, tokens, passwords, private keys,
           │             connection strings, JWTs, AWS keys, Slack tokens
    ▼
SHA-256 content hash → dedup check
    │
    ▼
Source-type chunker
    ├─ Markdown    → heading-based sections (≤1200 tokens)
    ├─ Code        → class/function blocks   (≤1000 tokens)
    ├─ Test report → result windows
    ├─ Log         → sliding windows         (≤600 tokens)
    └─ Diff/Patch  → hunk-based chunks
    │
    ▼
KnowledgeDocument + KnowledgeChunk (SQLite)
    │
    ├─ FTS5 insert    (lexical — always available)
    └─ Vector upsert  (optional — InMemoryVectorIndex or Qdrant)
    │
    ▼
hybrid retrieval → RRF fusion → source-quality ranking
    │
    ▼
UnifiedContextPack (40% of token budget)

─── Phase 10: multi-granularity write path (runs in parallel) ───────────────

same raw content
    │
    ├─ paragraph_segmenter  → KnowledgeParagraphORM  → knowledge_paragraphs_fts
    ├─ proposition_extractor → KnowledgePropositionORM → knowledge_propositions_fts
    └─ summarizer           → KnowledgeChunkSummaryORM → knowledge_summaries_fts
    │
    ▼
multigranular retrieval (25% of knowledge budget)
    │
    ▼
UnifiedContextPack.multigranular_chunks (independent of knowledge_chunks budget)

Directory structure

memory_engine/
├── main.py                  ← FastAPI app (dev / direct API use)
├── cli.py                   ← Debug CLI
├── config.py                ← Pydantic Settings
│
├── agent/                   ← Stage 8 namespace (re-exports)
│   ├── skills/              → memory_engine.skills
│   ├── policies/            → reflection gate constants
│   └── contracts/           → agent I/O domain models
│
├── skills/                  ← agent-facing behaviors (recall, inspect, reflect)
├── services/                ← domain orchestration (promotion, consolidation)
├── knowledge/               ← ingestion, chunking, FTS5, vector, search, fusion, cache
│                               proposition_extractor, paragraph_segmenter, summarizer,
│                               granularity_router, multigranular_search  (Phase 10)
├── repositories/            ← persistence abstraction (memory_node, candidate, evidence)
├── models/                  ← Pydantic domain + SQLAlchemy ORM
│
├── bootstrap/               ← local runtime (project_root, storage, security, state)
├── runtime/                 ← Stage 8 namespace (re-exports bootstrap + cache + config)
│
├── mcp/                     ← MCP adapter (tools, resources, server, project_context)
├── api/                     ← FastAPI routes
└── db/                      ← SQLite session + init

docs/
├── architecture/            ← system-overview, memory-lifecycle, knowledge-pipeline,
│                               retrieval-pipeline, mcp-integration, local-runtime,
│                               multigranular_memory_architecture  (Phase 10)
└── guides/                  ← quickstart, configuration, privacy-and-security

tests/
├── test_phase4.py – test_phase7.py   ← phase integration tests
└── test_*.py                          ← unit and component tests

MCP tools

ToolPurpose
seed_project_contextCall once on new projects. Write initial constraints, decisions, project description, and conventions directly as active memory nodes. Auto-extracts from README.md when fields are omitted. Eliminates cold-start problem.
retrieve_agent_contextRetrieve memory + knowledge before a coding task. Phase 10: pass task_intent, preferred_layers, proposition_types to guide granularity routing.
inspect_memoryDrill into a MemoryNode, its children, and evidence
inspect_knowledgeInspect a KnowledgeChunk or source file range (redacted)
reflect_and_writeReport validated work to the reflection pipeline
memory_statusProject health, retrieval mode, index counts, revisions
refresh_project_knowledgeTrigger incremental rescan; also builds Phase 10 proposition/paragraph/summary layers

MCP resources

ResourceContent
memory://project/current/constraintsActive project constraints
memory://project/current/architectureArchitecture and module summaries
memory://project/current/statusBootstrap state, retrieval mode, health
memory://project/current/recent-incidentsRecent debug incidents
memory://project/current/memory-tree-summaryMemory tree outline
memory://project/current/agent-policyGenerated agent policy
memory://project/current/git-contextCurrent Git state (branch, HEAD, staged/modified files — no remote URLs)
memory://project/current/branch-memory-summaryMemories organized by branch scope
memory://project/current/sync-statusIncremental sync and index freshness
memory://project/current/retention-statusLifecycle counts, archive/expiry candidates (Phase 11)
memory://project/current/compaction-reportCompaction group candidates (Phase 11)

Phase 11: Agent Memory Policy

The policy is installed automatically. On first bootstrap (first MCP tool call after setup), Memory Engine writes a workflow policy block directly into the project's CLAUDE.md (Claude Code) and generates .memory-engine/generated/AGENT_MEMORY_POLICY.md. No manual step required.

The policy block contains explicit call/skip decision rules for both tools:

  • retrieve_agent_context — call before editing production code, tests, CI, dependencies, or config; before debugging; when touching ≥ 2 files or any unfamiliar subsystem. Skip for pure explanations, single-line typo fixes, or when already called for the same task this session.
  • reflect_and_write — call after tests_passed or build_success on ≥ 2 changed files or a non-trivial architectural decision. Skip if tests failed, task was reverted, only one trivial file changed, or no validation ran.

For manual control or Cursor adapter installation:

bash
# Re-generate policy (idempotent, preserves user content outside markers)
memory policy generate --project-root .

# Install or update client adapters explicitly
memory policy install --project-root . --client claude-code
memory policy install --project-root . --client cursor

# Check adapter installation status
memory policy status --project-root .

See docs/agent_memory_policy.md.


Local storage

your-project/.memory-engine/
├── config.yaml              ← edit to customize; never overwritten
├── project_state.json       ← bootstrap status, revisions
├── memory.db                ← all data (memories, knowledge, candidates)
├── indexes/manifests/       ← incremental indexing file manifest
├── generated/
│   └── AGENT_MEMORY_POLICY.md
├── bootstrap/bootstrap_report.json
├── constraints.md           ← human-authored; safe to commit
├── team-rules.md            ← human-authored; safe to commit
└── decisions.md             ← human-authored; safe to commit

Add .memory-engine/ to .gitignore (generated hint on first bootstrap). The three human-authored .md files may optionally be committed.

Reset: rm -rf your-project/.memory-engine/


Project context seeding (Phase 12)

On a brand-new project the memory database is empty, so retrieve_agent_context returns nothing useful for the first several sessions. Seeding eliminates this cold-start problem by writing initial memory nodes on day one.

Option A — MCP tool seed_project_context (agent-driven)

Call once when memory_status shows active_memories == 0:

json
{
  "description": "Task scheduling system with retry and lifecycle management.",
  "constraints": [
    "Terminal states (COMPLETED, FAILED) must never be exited.",
    "Concurrent execution of the same task is forbidden."
  ],
  "decisions": [
    "SQLite over PostgreSQL — zero-infrastructure local deployment.",
    "Event sourcing for audit trail."
  ],
  "tech_stack": ["Python", "FastAPI", "SQLite"],
  "conventions": ["PRs require one reviewer.", "No force-push to main."]
}

All fields are optional. When description is omitted, README.md is auto-scanned for constraint/decision headings and bullet lists (no LLM). Nodes are written directly as active with confidence=1.0 — authoritative human input bypasses the candidate/promotion pipeline.

Option B — CLI wizard memory seed (interactive)

bash
memory seed my-project --project-root /path/to/project

Runs a step-by-step prompt for description, tech stack, constraints, decisions, and conventions, then writes nodes immediately.


Phase 13 — Local Persistent Vector Retrieval

Lexical FTS5 retrieval misses cross-wording matches: a query for "DB schema upgrade" will not rank a chunk that says "database migration". Phase 13 adds a persistent local semantic index so retrieval also matches on meaning, while keeping the default install lightweight.

Query
  ├── FTS5 lexical retrieval        (always active)
  ├── sqlite-vec semantic retrieval (optional, default OFF)
  ├── Branch / revision / lifecycle filters
  ├── RRF candidate fusion
  ├── Deterministic multi-signal ranker
  └── Token-budgeted UnifiedContextPack

Design guarantees

  • Default uv sync installs nothing extra — no model downloads, no new required deps.
  • sqlite-vec is the persistent backend: no Docker, no external service.
  • sentence-transformers, Ollama, and FastEmbed are optional local embedding providers. No cloud APIs.
  • FTS5 lexical fallback is unchanged when semantic is disabled.
  • Branch / revision / lifecycle safety filters are never bypassed by semantic results.
  • Content is redacted before embedding (same redact() path as the rest of the engine).

Enable it

Option A — installer prompt (recommended for new installs)

The installer asks whether to enable semantic retrieval at the end:

bash
bash scripts/install.sh
# → "Enable semantic retrieval? [y/N]"
# → y: installs sentence-transformers + sqlite-vec

Then activate per project (writes to .memory-engine/config.yaml, persists across restarts):

bash
memory semantic status --enable --project-root /your/project

Option B — manual

bash
# 1. Install deps (choose one provider)
uv pip install 'memory-engine[semantic-transformers]'   # sentence-transformers + sqlite-vec
# or: uv pip install 'memory-engine[semantic-ollama]'        # Ollama + sqlite-vec
# or: uv pip install 'memory-engine[semantic-fastembed]'     # FastEmbed (ONNX Runtime) + sqlite-vec

# 2. Persist to project config (survives terminal restarts)
memory semantic status --enable --project-root /your/project

Option C — env vars (CI / temporary override)

bash
export MEMORY_ENGINE_SEMANTIC_ENABLED=1
export MEMORY_ENGINE_EMBEDDING_PROVIDER=sentence_transformers
export MEMORY_ENGINE_EMBEDDING_MODEL=BAAI/bge-small-en-v1.5

Env vars always take precedence over config.yaml. When enabled and available, retrieval_mode becomes hybrid; otherwise the engine stays in lexical_structured_fallback and memory_status returns a suggestions field explaining how to activate it.

CLI

bash
memory semantic status  --project-root .   # provider/backend/model + embedded counts
memory semantic doctor  --project-root .   # availability, dimension, orphan checks
memory semantic reindex --project-root .   # incremental embedding (--full to rebuild)
memory semantic clear   --project-root . --confirm   # clears vectors only

Vectors live in .memory-engine/vector.db. clear never touches source knowledge or memory trees. Full details: docs/local_vector_retrieval.md.


Human-authored seed knowledge

Create these files to provide stable project knowledge that cannot be safely inferred from code alone:

.memory-engine/constraints.md

markdown
# Project Constraints

## Auth
Do not bypass JWT validation. All routes require Bearer token.

## Database
Never use raw SQL. SQLAlchemy ORM only.

## Scheduler
Terminal task states (COMPLETED, FAILED, CANCELLED) are immutable.

.memory-engine/team-rules.md

markdown
# Team Rules

- PRs require 2 approvals before merge
- All public APIs must have OpenAPI documentation
- Log structured JSON only (no print statements in production code)

These files are indexed as high-priority knowledge on bootstrap and returned in context before relevant tasks.


Retrieval modes

Default local mode: lexical_structured_fallback

Active when no persistent vector backend is available (default for local use).

Signals used for ranking:

  • SQLite FTS5 lexical match (BM25)
  • Module-path overlap with current task files
  • Symbol overlap with current task symbols
  • Memory tree proximity
  • Node importance and confidence
  • Freshness (recency weighting)
  • Project-scoped TTL cache

Enhanced mode: hybrid (Phase 13)

Active when semantic retrieval is enabled and both sqlite-vec and a local embedding provider are available. Adds real cosine similarity over chunk, paragraph, proposition, and summary embeddings via RRF fusion. The semantic_similarity score in the retrieval trace reflects the actual vector score (no longer always 0.0). See the Phase 13 section above.

Vector retrieval is optional. The default local mode works without sqlite-vec, Qdrant, Docker, or any external service.

Phase 10: multi-granularity retrieval

Active automatically when Phase 10 knowledge is indexed (created by refresh_project_knowledge or the normal ingest path).

Four retrieval layers, created deterministically at write-time (no LLM):

LayerUnitTypical use
PropositionOne atomic fact (shell=False is enforced)Bug fixes, security audits
ParagraphOne function or heading sectionFeature work, code explanation
ChunkFixed-size content block (existing)General keyword search
Module summaryWhole-file digest with key symbolsArchitecture review, onboarding

The layer selected for a query is determined by task_intent:

python
# in retrieve_agent_context:
task_intent = "bug_fix"        # → propositions first (constraint/security_rule/risk)
task_intent = "architecture_review"  # → module summaries first
task_intent = "feature_implementation"  # → paragraphs + propositions + summaries

Callers can also override directly:

python
preferred_layers = ["proposition"]          # force proposition-only
proposition_types = ["security_rule"]       # sub-filter by type

Results appear in multigranular_chunks alongside the existing knowledge_chunks.

See docs/architecture/multigranular_memory_architecture.md for the full design.


Privacy and security

  • Local-only: all data stays in .memory-engine/; nothing leaves your machine
  • No telemetry: no usage data sent anywhere
  • No cloud embedding: no external API calls by default
  • No Docker: not required for any feature
  • Path boundaries: all file reads restricted to resolved project root
  • Symlink protection: links escaping project root rejected
  • Secret redaction: runs before persistence and before MCP output
  • Default exclusions: .env, secrets/, *.pem, *.key, node_modules/, .git/, binary files, files over 5 MB
  • No auto Git commits: never — Git is read-only (rev-parse, branch, status, merge-base only)
  • No remote URL exposure: Git remote URLs are never returned in any output
  • No Git identity exposure: user name and email are never collected or returned
  • No destructive Git commands: commit, reset, push, clean, checkout, merge, rebase, fetch are all blocked
  • No writes outside .memory-engine/: guaranteed

Configuration

Generated at .memory-engine/config.yaml on first bootstrap:

yaml
project:
  name: auto
  root_path: auto

runtime:
  auto_bootstrap: true
  auto_recall: true
  auto_reflect: true
  auto_index_on_start: true
  incremental_indexing: true

privacy:
  mode: local
  redact_secrets: true
  allow_network_embedding: false

knowledge:
  include:
    - README.md
    - docs/**
    - src/**
    - app/**
    - lib/**
    - tests/**
  exclude:
    - node_modules/**
    - .git/**
    - .venv/**
    - dist/**
    - build/**
    - .env
    - secrets/**
  max_file_size_mb: 5

retrieval:
  default_token_budget: 6000
  cache_enabled: true
  vector_backend: auto
  allow_degraded_fallback: true
  # Phase 9: branch-aware retrieval
  branch_aware_ranking: true
  prefer_current_branch: true
  include_ancestor_branch_memory: true
  include_mainline_fallback: true

runtime:
  # Phase 9: Git-aware synchronization
  git_aware_sync: true
  check_git_status_on_retrieval: true
  auto_incremental_sync: true

memory:
  # Phase 9: branch-scoped write policy
  branch_scope_on_feature_work: current_branch
  mainline_promotion_requires_confirmation: true

privacy:
  # Phase 9: Git identity protection
  expose_git_remote_url: false
  redact_git_identity: true

User edits are preserved on re-bootstrap.


Demo scenario

Scheduler project. Task: Add exponential retry backoff without breaking terminal task state semantics.

  1. Agent calls retrieve_agent_context:
json
{
  "constraints": [
    {
      "title": "Terminal State Immutability",
      "summary": "COMPLETED, FAILED, CANCELLED are terminal states. Any operation that transitions out of a terminal state is a critical bug.",
      "importance": 0.95
    }
  ],
  "incidents": [
    {
      "title": "Retry Loop Re-entered Terminal Task",
      "summary": "In v0.8.2, a retry race condition re-entered a COMPLETED task. Root cause: retry check did not verify terminal status before re-queuing.",
      "importance": 0.88
    }
  ],
  "knowledge_chunks": [
    {
      "source_path": "docs/adr/003-retry-policy.md",
      "preview": "Decision: use exponential backoff with jitter. Max 5 retries..."
    }
  ],
  "retrieval_trace": [...],
  "meta": {
    "retrieval_mode": "lexical_structured_fallback",
    "vector_backend": "ephemeral",
    "warnings": ["Semantic vector retrieval is unavailable..."]
  }
}
  1. Agent implements retry logic with terminal-state guard.
  2. Tests pass. Agent calls reflect_and_write:
json
{
  "outcome": "persisted",
  "candidates_promoted": 2,
  "consolidation_notes": ["Parent 'Scheduler Core' summary updated"]
}

Debug CLI

For maintainers, demos, and troubleshooting only. Not the normal workflow.

bash
memory-engine debug status --project-root /path/to/project
memory-engine debug bootstrap --project-root /path/to/project
memory-engine debug index --project-root /path/to/project
memory-engine debug recall "add retry backoff" --project-root /path/to/project
memory-engine debug inspect <node-id>
memory-engine debug reset-project --project-root /path/to/project

Testing

bash
# Run all tests
pytest -v

# Run focused
pytest tests/test_phase7.py -v
pytest tests/test_phase6.py -v
pytest -k "recall" -v

511 tests currently passing. All deterministic. No external services required. (Semantic retrieval tests use mocked providers or pytest.importorskip("sqlite_vec") — no models are downloaded during the test run.)


Limitations and future work

  • Persistent local vector backend — current InMemoryVectorIndex does not survive process restarts
  • Optional Qdrant backend — interface exists; client not installed by default; enables semantic cross-lingual retrieval
  • PyPI publishing — pip install memory-engine-mcp not yet available
  • Binary packaging — no binary installer yet
  • Streamable HTTP remote mode — stdio only; no team-shared HTTP transport yet
  • Team-shared memory — each project has isolated local storage; no shared team memory yet
  • Authentication and permissions — no per-user or per-team access control yet
  • Richer code parsing — chunking is line-range based; AST-aware parsing is future work
  • Larger repository benchmarks — not yet validated at monorepo scale
  • Retention scheduling — memory retention run is explicit; no background daemon

Contributing

  1. Read docs/architecture/system-overview.md first.
  2. Preserve service-layer boundaries: MCP/API layers stay thin.
  3. Keep business logic in skills/, services/, knowledge/.
  4. New knowledge source types → knowledge/chunkers.py + new SourceType enum value.
  5. New MCP tools → mcp/tools.py, thin wrapper only; delegate to services.
  6. New domain model → models/domain.py or models/knowledge_domain.py.
  7. Add tests for all new behavior.
  8. Never weaken project-root security boundaries.
  9. Run pytest -v and confirm all tests pass before opening a PR.

Development

bash
# Install dev dependencies (includes pytest, httpx)
uv sync --extra dev

# Run tests
uv run pytest -v

# Start FastAPI service (dev / direct API use — not required for MCP)
uvicorn memory_engine.main:app --reload
# API docs at http://localhost:8000/docs

# Run MCP server directly (stdio, blocks until client disconnects)
uv run memory-engine-mcp --project-root /path/to/project --log-level DEBUG

Agent Memory EngineのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度Agent Memory Engineに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

Agent Memory Engineをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. Agent Memory EngineのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "agent-memory-engine": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてAgent Memory EngineのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. Agent Memory EngineのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
Agent Memory Engineを使ってこのタスクを手伝ってもらえますか?
Agent Memory Engine
はい、読みました。
Agent Memory Engineで調べた結果をお伝えします。

よくある質問

Agent Memory Engine MCPサーバーは何に使いますか?

Agent Memory Engineは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでAgent Memory Engine MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでAgent Memory Engineを利用できます。

TypingMindでAgent Memory Engine MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。Agent Memory Engineを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

Agent Memory Engine MCPをTypingMindに接続するにはどうすればよいですか?

Agent Memory EngineはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでAgent Memory Engine MCPのどのようなツールを利用できますか?

Agent Memory EngineはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

Agent Memory Engine MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。Agent Memory Engineで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇