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

# Python SDK

> Install and use the MemMachine Python Client

The MemMachine Python SDK provides a convenient way to interact with your MemMachine Server. It handles authentication, project management, and memory operations.

## Simple Hello World Example

````python theme={null}
import memmachine_server
from memmachine_server.episodic_memory.episodic_memory_manager import EpisodicMemoryManager
from memmachine_server.episodic_memory.data_types import MemoryContext
from memmachine_server.common.episode_store import ContentType, Episode
from datetime import datetime
import uuid

Install the MemMachine package using pip:

```bash
pip install memmachine-server
````

## Hello World Example

This example demonstrates how to connect to the server, create a project, and add/retrieve memories.

<Note>
  Ensure your MemMachine server is running (see [Quickstart Guide](../getting_started/quickstart)) before running this code.
</Note>

```python theme={null}
from memmachine_client import MemMachineClient

# 1. Initialize the client
# Replace 'http://localhost:8080' with your server's URL if different.
client = MemMachineClient(base_url="http://localhost:8080")

# 2. Create a Project
# Projects organize memories under an Organization.
# If the project already exists, this will return the existing one.
project = client.create_project(
    org_id="my-org",
    project_id="hello-world-project",
    description="My first MemMachine project"
)

print(f"Working with project: {project.org_id}/{project.project_id}")

# 3. Create a Memory Interface
# A Memory interface is scoped to a specific user/agent/session context.
memory = project.memory(
    user_id="user-alice",
    agent_id="agent-bob",
    session_id="session-1"
)

# 4. Add Memories
# Add a user message
memory.add(
    content="My favorite color is blue.",
    role="user"
)

# Add an agent response
memory.add(
    content="I'll remember that your favorite color is blue.",
    role="assistant"
)

print("Memories added.")

# 5. Search Memories
# Search for the information we just added.
results = memory.search("What is my favorite color?")

print("\nSearch Results:")
print(results)
```

## Key Concepts

### Client (`MemMachineClient`)

The entry point for the SDK. It manages the HTTP connection to the MemMachine server.

### Project (`Project`)

Represents a workspace within MemMachine. All memories are isolated within a project. You can create new projects or retrieve existing ones.

### Memory (`Memory`)

The interface for adding and retrieving memories. It is context-aware, meaning you initialize it with specific identifiers:

* **user\_id**: The ID of the human user.
* **agent\_id**: The ID of the AI agent.
* **session\_id**: (Optional) A specific conversation session ID.
* **group\_id**: (Optional) For multi-user/multi-agent groups.

When you call `memory.add()` or `memory.search()`, these identifiers are automatically attached to the operations.
