Skip to main content

Hierarchical markdown memory palace for AI agents — MCP server, skills, and audit tools

Project description

Locus

CI PyPI version License: MIT Python 3.11+

Hierarchical markdown-based memory system for autonomous AI agents. Each directory is a room (locus) in the palace, containing specific knowledge navigated on demand. Named for the atomic unit of the Method of Loci.

Core idea: Keep context windows small. Load only the room you need, not the whole palace.


How it works

palace/
  INDEX.md                    ← always read first (~50 lines max)
  global/
    toolchain/
      toolchain.md            ← canonical facts about tools
  projects/
    my-project/
      my-project.md           ← room overview + key files
      technical-gotchas.md    ← specialty: issues & resolutions
      sessions/
        2026-03-02.md         ← append-only session log

An agent reads INDEX.md, navigates to the relevant room, and reads only that room. Session logs accumulate until consolidation merges them into canonical files.

See the wiki for full documentation.


Quick start

# Install
pip install locus-mcp
# or: uvx locus-mcp --palace ~/.locus  (no install needed)

# Create a palace from the example template
cp -r example-palace ~/.locus
# Edit ~/.locus/INDEX.md to describe your palace

# Run the MCP server
locus-mcp --palace ~/.locus
# or: LOCUS_PALACE=~/.locus locus-mcp

Installation

MCP server (recommended for MCP-capable clients)

pip install locus-mcp

Or run without installing using uvx:

uvx locus-mcp --palace ~/.locus

Claude Code skills

cp -r skills/claude/locus ~/.claude/skills/locus
cp -r skills/claude/locus-consolidate ~/.claude/skills/locus-consolidate

Codex

cp -r skills/codex/locus ~/.codex/skills/locus
cp -r skills/codex/locus-consolidate ~/.codex/skills/locus-consolidate

Gemini

Reference skills/gemini/locus/SKILL.md from your .gemini/ directory or a GitHub Actions workflow (see skills/gemini/).

Agent SDK (Python)

pip install locus-mcp
locus --palace ~/.locus --task "What toolchain conventions are set?"

MCP Server

The locus-mcp command exposes four tools over the Model Context Protocol (stdio transport):

Tool Description
memory_list Returns INDEX.md (no args) or lists a room's files
memory_read Reads any file in the palace
memory_write Atomically writes a file (guarded — cannot write to _metrics/, sessions/)
memory_search Full-text search across the palace (ripgrep or Python fallback)

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "locus": {
      "command": "locus-mcp",
      "args": ["--palace", "/path/to/palace"]
    }
  }
}

Or using uvx (no install required):

{
  "mcpServers": {
    "locus": {
      "command": "uvx",
      "args": ["locus-mcp", "--palace", "/path/to/palace"]
    }
  }
}

Cursor / Zed

{
  "mcp": {
    "servers": {
      "locus": {
        "command": "locus-mcp",
        "args": ["--palace", "/path/to/palace"]
      }
    }
  }
}

Environment variable

All clients support LOCUS_PALACE as an alternative to --palace:

export LOCUS_PALACE=~/.locus
locus-mcp

See MCP Server Configuration for the full client setup guide and spec/mcp-server.md for architecture details.


Benchmarks

Palace navigation loads 52% fewer context lines than flat memory for specific queries, while maintaining full recall. Session-only queries (recent work not yet consolidated) are accessible only via the palace.

Palace: 822 lines / 9 queries found   avg  91 lines/query · 3.2 calls
Flat:  1719 lines / 8 queries found   avg 191 lines/query · 2.0 calls

See docs/benchmarks.md for charts and full methodology.


Structure

example-palace/   Copy-paste palace template to get started
spec/             Palace convention definitions:
  index-format.md       INDEX.md rules and routing
  room-conventions.md   Room structure and naming
  size-limits.md        Context budget thresholds
  write-modes.md        Session logs vs canonical edits
  mcp-server.md         MCP server architecture and safety model
  metrics-schema.md     Run metrics JSON schema
  audit-algorithm.md    Palace health scoring
  health-report-format.md  Audit report structure
  inferred-feedback.md  Disagreement signal classification
templates/        Copy-paste templates for INDEX.md, rooms, session logs
skills/
  claude/         SKILL.md files for Claude Code + Agent SDK
  codex/          Codex-compatible skill files
  gemini/         Gemini CLI + GitHub Actions skill files
docs/
  architecture.md       Mermaid diagrams
  benchmarks.md         Benchmark results and charts
  onboarding.md         Step-by-step agent onboarding
scripts/
  bench-mcp.py          40-case MCP integration benchmark
  bench-compare.py      Palace vs flat recall comparison
  generate-charts.py    Regenerate docs/img/ charts
locus/agent/      Python Agent SDK (CLI + metrics)
locus/audit/      Palace health auditor (locus-audit CLI)
locus/feedback/   Inferred feedback classifier
locus/mcp/        MCP server (locus-mcp CLI)

Roadmap

Milestone Status Focus
v0.1 - Foundation ✅ Complete Spec, conventions, size limits
v0.2 - Core Palace ✅ Complete Templates, skills, Agent SDK, benchmark
v0.3 - Performance Metrics ✅ Complete Context tracking, feedback, suggestions
v0.4 - Self Evaluation ✅ Complete Palace audit, health reports, inferred feedback
v0.5 - MCP Server ✅ Complete MCP server with memory_list/read/write/search
v0.6 - Public release ✅ Complete Benchmarks, docs, CI, PyPI

Contributing

See CONTRIBUTING.md for dev setup, test instructions, and PR guidelines.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locus_mcp-0.6.1.tar.gz (203.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

locus_mcp-0.6.1-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

File details

Details for the file locus_mcp-0.6.1.tar.gz.

File metadata

  • Download URL: locus_mcp-0.6.1.tar.gz
  • Upload date:
  • Size: 203.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for locus_mcp-0.6.1.tar.gz
Algorithm Hash digest
SHA256 7f207107bf05623e4b92c152762134d4be94df0f3f8d3922ac1f188351dc14d1
MD5 0650fc3179f4b099badb2cf2f7773e9e
BLAKE2b-256 b881f44ca3137a0bbec6238d80a0bf082900312f795785295b14694b54948e86

See more details on using hashes here.

Provenance

The following attestation bundles were made for locus_mcp-0.6.1.tar.gz:

Publisher: publish.yml on EDKarlsson/locus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file locus_mcp-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: locus_mcp-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 25.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for locus_mcp-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b9b5da8bc420b459580d240e4b7d99fbe8f4d38b99b9c5fbe9784a1a5e4b7f3
MD5 0943ed834d315675de381f6895c7c588
BLAKE2b-256 48928c53cd26fa2a0234ac0df68a4968bd6359acef9d062a655398b12ab93dc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for locus_mcp-0.6.1-py3-none-any.whl:

Publisher: publish.yml on EDKarlsson/locus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page