Skip to main content

Mesh

High-speed shared semantic & hybrid memory layer for AI agents.

When one agent learns something, every other agent can recall it — by meaning, keyword, or exact identifier.

PyPI version Python versions License: MIT


The Problem

Every AI agent starts each session with amnesia. Claude in your terminal doesn't know what Claude in your editor discovered. Your coding agent cannot access what your review agent found. Every agent repeats work already done.

The Solution

Mesh provides persistent, shared agent memory with:

  • 3-Stage Hybrid Search: Dense Vector SIMD Cosine (cache.matrix @ q_vec in <0.1 ms) + SQLite FTS5 BM25 + Exact Token Overlap.
  • Unified Local Storage: Pure SQLite WAL per namespace — zero external database daemons, zero multi-process synchronization issues.
  • Smart Deduplication & Contradiction Tracking: Identical facts are reinforced in-place; contradictory facts are flagged for review without silent data loss.
  • Time-to-Live (TTL) Confidence Decay: Ephemeral facts gradually decay towards staleness.
  • Multi-Interface: MCP Server (10 tools for Claude Desktop, Cursor, Windsurf), Web Dashboard, HTTP REST API, and CLI.

Quickstart

1. Installation

pip install mesh-context-layer

2. Python SDK

from mesh import Mesh

# Agent 1: Learns an architecture constraint
agent_a = Mesh(namespace="checkout-service", agent_id="backend-agent")
agent_a.learn(
    "Production PostgreSQL 16 database runs on port 5432 with pgBouncer connection pooling",
    memory_type="fact",
    tags=["db", "postgres", "prod"]
)

# Agent 2: Recalls it without direct communication
agent_b = Mesh(namespace="checkout-service", agent_id="frontend-agent")
results = agent_b.recall("what port does production postgres use?", n=3)

for r in results:
    print(f"[{r['similarity']:.2f}] {r['content']} (from {r['source_agent']})")

MCP Server (Claude Desktop, Cursor & Windsurf)

Mesh provides 10 MCP tools directly to your AI agents.

Claude Desktop Configuration

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "mesh": {
      "command": "mesh-server"
    }
  }
}

Cursor Configuration

Create .cursor/mcp.json in your project root:

{
  "mcpServers": {
    "mesh": {
      "command": "mesh-server"
    }
  }
}

Available MCP Tools

MCP Tool Description
mesh_learn Store a fact, preference, instruction, or decision with deduplication and contradiction checking.
mesh_recall 3-stage hybrid search across shared memory with confidence filtering and score breakdown.
mesh_update Update existing memory content and tags in-place preserving UUID and history.
mesh_forget Remove a specific memory by its ID.
mesh_inspect Browse recent memories in a namespace with pagination and type filtering.
mesh_context Generate formatted context blocks (Markdown, XML, JSON, or Plain) for system prompts.
mesh_patterns Discover frequently accessed topics, memory gaps, and stale memories.
mesh_contradictions Inspect conflicting memories identified during learning.
mesh_resolve_contradiction Mark a contradiction as resolved after reviewing the conflict.
mesh_sync Save a turn summary and automatically capture facts from session transcripts.

Web Dashboard

Launch the zero-build local visualizer:

mesh-dashboard --namespace checkout-service --port 7433

Open http://localhost:7433 in your browser. Features:

  • Real-Time Hybrid Search with instant score breakdowns.
  • Contradiction Inspector: Review and resolve flagged memory conflicts.
  • Memory Gaps & Patterns: See queries agents asked that had low recall similarity.
  • Audit Stream: Real-time log of agent reads and writes.
  • Keyboard Shortcuts: / to focus search, n to create a memory, Esc to close modals.

Memory Types

Type Intended Purpose
fact Objective project realities (e.g., ports, hostnames, library versions).
preference User preferences, code style requirements, framework conventions.
instruction Strict rules and guidelines agents must obey.
decision Architectural and technical decisions with rationale.
process Multi-step workflows and deployment sequences.
context Broad project background or domain context.
result Verification outcomes, benchmark results, test findings.
error Discovered bugs, root causes, and workarounds.
general General unstructured observations.

HTTP REST API

Start the local background server:

mesh-http --port 7701

From any terminal, script, or language:

# Store a memory
curl -s -X POST http://localhost:7701/learn \
  -H "Content-Type: application/json" \
  -d '{"content": "Auth service requires JWT RS256 signatures", "memory_type": "instruction"}'

# Recall memories
curl -s -X POST http://localhost:7701/recall \
  -H "Content-Type: application/json" \
  -d '{"query": "auth JWT algorithm", "n": 3}'

# Format context directly into agent system prompts
curl -s -X POST http://localhost:7701/context \
  -H "Content-Type: application/json" \
  -d '{"count": 10, "format": "markdown"}'

Portability & Privacy

Privacy Flags

Mark sensitive memories as local_only=True to guarantee they are never exported or synced:

mesh.learn("Staging DB password: secret-pass", local_only=True, tags=["credentials"])

Backup & Restore

# Export all public memories to JSON
mesh-export backup.json --namespace checkout-service

# High-speed batch import (with automatic deduplication)
mesh-import backup.json --namespace checkout-staging --merge-strategy skip_existing

Detailed Changelog

v0.5.1 (Latest)

  • High-Speed Batch Import/Export: import_namespace now commits all memories in a single atomic SQLite WAL transaction via upsert_batch() and utilizes O(1) in-memory vector cache ID lookups, removing N+1 database queries. Missing embeddings are computed in a single forward pass.
  • MCP Stdio Redirection Safety: Added thread-safe stdout redirection to ensure print statements never corrupt stdio JSON-RPC payloads in Claude Desktop or Cursor.
  • Optimized Context Generation: Streamlined single-pass context assembly for /context HTTP endpoint and mesh_context MCP tool with tag and memory type filtering.
  • Fast-Path Registry: Added lockless fast-path lookups to the HTTP server's Mesh instance registry.
  • Showcase Suite: Added examples/full_showcase.py verifying all 11 core engine stages end-to-end.
  • Windows Console Resiliency: Safe UTF-8 console output handling preventing CP1252 character map errors.

v0.5.0

  • ChromaDB Removal: Transitioned to a unified SQLite WAL + NumPy SIMD in-memory vector cache engine, eliminating external C++ dependencies, multi-database sync bugs, and heavy binary bloat.
  • 3-Stage Hybrid Search: Combines Dense Cosine Similarity (<0.1 ms), SQLite FTS5 BM25 lexical ranking, and exact token overlap boosting.
  • Automatic Deduplication Engine: Near-identical memories ($\ge 0.985$ similarity) reinforce existing records rather than creating duplicate rows.
  • Contradiction Tracking: Conflicting statements ($\ge 0.82$ similarity with numeric/negation polarity changes) are stored and recorded in a contradiction log for review.
  • Time-to-Live (TTL) & Confidence Decay: Linear time-based confidence decay for temporary facts.
  • Full 10-Tool MCP Server: Complete tool suite for LLMs.
  • Interactive Web Dashboard: Single-file dark/light UI with search, contradiction management, pattern analysis, and audit trails.
  • Passive Capture & Daily Digests: Automated memory extraction from AI session logs (mesh-capture) and Markdown summary generation (mesh-digest).

License

MIT © billighost

Metadata

Release files for mesh-context-layer 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mesh-context-layer 0.5.1
File Size Uploaded
mesh_context_layer-0.5.1.tar.gz 103.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mesh-context-layer 0.5.1
File Interpreter ABI Platform
mesh_context_layer-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 177.9 kB

Release files / mesh_context_layer-0.5.1.tar.gz

Download URL mesh_context_layer-0.5.1.tar.gz
Size 103.1 kB
Tags Source
SHA-256 checksum
How to use checksums
15cba2f93b6e16b7b1891f8c99b1938acc5d2dfb88234838df753ede98e9d0b9
BLAKE2b-256 checksum
How to use checksums
9f1f4db8db83e64d6a279964eb25d0b02f0f0fbeb0beed52cb811c5621e4f6ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / mesh_context_layer-0.5.1-py3-none-any.whl

Download URL mesh_context_layer-0.5.1-py3-none-any.whl
Size 74.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c70e19c207d906510a0b96d8ed4dc51d46e4f531069a803db351cd418858cc9
BLAKE2b-256 checksum
How to use checksums
f0d92378f0738df9abf0a54ab6652356b6522f0231640ae8d8e2cd007ca85625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release history Release notifications | RSS feed

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.3

2 release files

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page