> ## Documentation Index
> Fetch the complete documentation index at: https://artemiscity.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Artemis Agentic Memory Layer

> This document describes the integration between **Artemis City** core and the **Artemis Agentic Memory Layer** (MCP Server), enabling agents to interact with Obsidian vault as a persistent knowledge base.

This document describes the integration between **Artemis City** core and the **Artemis Agentic Memory Layer** (MCP Server), enabling agents to interact with Obsidian vault as a persistent knowledge base.

## Overview

The memory integration bridge connects the Python-based Artemis City agent system with the Node.js MCP server, allowing:

* **Persistent Context Storage**: Agents can store and retrieve context across sessions
* **Trust-Based Access Control**: Memory operations filtered by agent trust scores
* **Structured Knowledge Base**: Obsidian vault acts as versioned source of truth
* **Agent-Vault Interaction**: Search, tag, and organize knowledge programmatically

***

## Components

### 1. Memory Client (`memory/integration/memory_client.py`)

Python REST client for the MCP server with full coverage of 8 MCP operations.

**Features:**

* Bearer token authentication
* Standardized response format (MCPResponse)
* Automatic error handling
* Built-in HTTP client (no external dependencies)

**Operations:**

* `get_context(path)` - Read note content
* `append_context(path, content)` - Append to note
* `update_note(path, content)` - Replace note content
* `search_notes(query)` - Search vault
* `list_notes(folder)` - List notes in folder
* `delete_note(path)` - Delete note
* `manage_frontmatter(path, action, key, value)` - YAML frontmatter ops
* `manage_tags(path, action, tags)` - Tag management
* `search_replace(path, search, replace)` - Find and replace

**Example:**

```python theme={null}
from memory.integration import MemoryClient

client = MemoryClient(
    base_url="http://localhost:3000",
    api_key="your_mcp_api_key"
)

# Read a note
response = client.get_context("Daily/2025-11-23.md")
if response.success:
    print(response.data['content'])

# Store agent context
client.store_agent_context(
    "artemis",
    "Completed ATP integration successfully"
)
```

### 2. Trust Interface (`memory/integration/trust_interface.py`)

Trust-based access control for memory operations with decay model.

**Features:**

* Trust scores for agents (0.0-1.0)
* Trust levels (FULL, HIGH, MEDIUM, LOW, UNTRUSTED)
* Operation permission matrix
* Natural trust decay over time
* Reinforcement/penalty system

**Trust Levels & Permissions:**

| Level     | Score Range | Allowed Operations                       |
| --------- | ----------- | ---------------------------------------- |
| FULL      | 0.9-1.0     | read, write, delete, search, tag, update |
| HIGH      | 0.7-0.89    | read, write, search, tag, update         |
| MEDIUM    | 0.5-0.69    | read, write, search, tag                 |
| LOW       | 0.3-0.49    | read, search                             |
| UNTRUSTED | 0.0-0.29    | none                                     |

**Example:**

```python theme={null}
from memory.integration import get_trust_interface

trust = get_trust_interface()

# Check permission
if trust.can_perform_operation('artemis', 'write'):
    # Perform write operation
    trust.record_success('artemis')  # Reinforce trust
else:
    print("Access denied - insufficient trust")

# Get trust report
report = trust.get_trust_report()
print(f"Total entities: {report['total_entities']}")
```

### 3. Context Loader (`memory/integration/context_loader.py`)

High-level interface for loading and organizing context from vault.

**Features:**

* Load notes as ContextEntry objects
* Search vault with relevance scoring
* Load by tags or folders
* Agent history tracking
* Related content discovery
* Date range filtering

### With Artemis Persona

Artemis can store and load context for continuity:

```python theme={null}
from agents.artemis import ArtemisPersona, ReflectionEngine
from memory.integration import MemoryClient, ContextLoader

persona = ArtemisPersona()
client = MemoryClient()
loader = ContextLoader()

# Load historical context
history = loader.load_agent_history("artemis", limit=20)

# Feed to reflection engine
engine = ReflectionEngine()
for entry in history:
    engine.add_conversation(entry.content)

# Generate synthesis
synthesis = engine.synthesize()

# Store synthesis back to vault
client.store_agent_context("artemis", synthesis, "Reflections")
```

### With Instruction Hierarchy

Memory can provide agent-specific instructions:

```python theme={null}
from core.instructions import InstructionLoader
from memory.integration import ContextLoader

loader = ContextLoader()

# Load agent instructions from vault
agent_instructions = loader.load_note("Agents/artemis/instructions.md")

if agent_instructions:
    # Instructions loaded from Obsidian override local
    print("Using vault-stored instructions:")
    print(agent_instructions.content)
```

Planned improvements aligned with the plan:

1. **Enhanced CLI Integration**
   * Automatic context loading on startup
   * Persistent conversation history
   * Cross-session memory
2. **MCP Configuration Helper**
   * Auto-discovery of MCP server
   * Configuration validation
   * Health monitoring
3. **Agent Communication**
   * Message protocol with context hashing
   * Shared workspace in vault
   * Cross-agent knowledge graphs
4. **Advanced Search**
   * Semantic search with embeddings
   * Relevance ranking algorithms
   * Context-aware suggestions


## Related topics

- [Secrets and environment setup](/Documentation/operations/secrets-setup.md)
- [Agentic Memory Layer (MCP server)](/Documentation/integrations/agentic-memory-layer.md)
- [Changelog](/Changelog/changelog.md)
- [What Is Artemis City?](/Documentation/Introduction/what-is-artemis-city.md)
- [Memory Lawyer Protocol](/Documentation/concepts/memory_lawyer.md)
