Metadata-Version: 2.4
Name: mesa-memory
Version: 0.10.0
Summary: Enterprise AI agent memory engine
Author: MESA Core Team
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Yasou13/MESA
Project-URL: Repository, https://github.com/Yasou13/MESA
Project-URL: Documentation, https://github.com/Yasou13/MESA/tree/main/docs
Project-URL: Changelog, https://github.com/Yasou13/MESA/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/Yasou13/MESA/issues
Keywords: ai,memory,agents,knowledge-graph,llm,cognitive
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: aiosqlite>=0.22.0
Requires-Dist: anyio>=4.0.0
Requires-Dist: httpx>=0.28.0
Requires-Dist: mcp<2.0.0,>=1.30.0
Requires-Dist: cryptography>=42.0.0
Requires-Dist: uvicorn>=0.29.0
Requires-Dist: fastapi<0.142,>=0.139.0
Requires-Dist: starlette>=1.3.1
Requires-Dist: slowapi>=0.1.9
Requires-Dist: prometheus_client>=0.20.0
Requires-Dist: openai>=2.36.0
Requires-Dist: pydantic<3,>=2.13.0
Requires-Dist: pydantic-settings>=2.14.0
Requires-Dist: lancedb<0.42,>=0.30.0
Requires-Dist: pyarrow>=24.0.0
Requires-Dist: pypdf<8,>=6.14.2
Requires-Dist: python-docx<2,>=1.2.0
Requires-Dist: openpyxl<4,>=3.1.5
Requires-Dist: numpy>=2.2.0
Requires-Dist: tenacity>=9.0.0
Requires-Dist: psutil>=7.0.0
Requires-Dist: structlog>=24.0.0
Requires-Dist: python-dotenv>=1.2.0
Requires-Dist: tiktoken>=0.12.0
Requires-Dist: alembic>=1.13.0
Requires-Dist: sqlalchemy>=2.0.51
Requires-Dist: typing_extensions>=4.16.0
Provides-Extra: adapters
Provides-Extra: ml
Requires-Dist: torch>=2.11.0; extra == "ml"
Requires-Dist: transformers>=5.8.0; extra == "ml"
Requires-Dist: tokenizers>=0.22.0; extra == "ml"
Requires-Dist: safetensors>=0.7.0; extra == "ml"
Requires-Dist: huggingface_hub>=1.14.0; extra == "ml"
Requires-Dist: sentence-transformers>=3.0.0; extra == "ml"
Provides-Extra: loadtest
Requires-Dist: aiohttp>=3.14.3; extra == "loadtest"
Requires-Dist: locust>=2.29.0; extra == "loadtest"
Provides-Extra: dev
Requires-Dist: pytest>=7.4.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
Requires-Dist: cyclonedx-bom>=5.1.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Requires-Dist: datasets>=2.14.0; extra == "dev"
Requires-Dist: PyYAML>=6.0.0; extra == "dev"
Dynamic: license-file

# MESA — Memory Engine for Structured Agents

[![MESA CI](https://github.com/Yasou13/MESA/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/Yasou13/MESA/actions/workflows/ci.yml?query=branch%3Amain)
[![Release](https://img.shields.io/github/v/release/Yasou13/MESA)](https://github.com/Yasou13/MESA/releases/latest)
[![License: Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/Yasou13/MESA/blob/main/LICENSE)
[![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB?logo=python&logoColor=white)](https://github.com/Yasou13/MESA/blob/main/pyproject.toml)

MESA stores source documents and finds passages an application is authorized to read. Every search hit links to its document, revision and location. Ingestion and BM25 search work without models. Add an embedding model for semantic search or a chat model for answers with citations and document summaries.

Package version: **0.10.0**. V4 is the current API. Production qualification remains at the release candidate stage: **NO-GO** until the [release gates](https://github.com/Yasou13/MESA/blob/main/docs/release.md) pass.

## Installation

```bash
pip install mesa-memory
```

Supported natively on Linux, macOS (Apple silicon), and Windows 10/11 (Python 3.12–3.14), with no WSL or Docker required. Install this checkout with `pip install -e .` to try unreleased features.

## Start the server

```bash
mesa start
```

Starts the local server on `http://127.0.0.1:8000`, initializes storage at `~/.mesa/data`, and creates credentials at `~/.mesa/credentials.json` (mode 0600).

## Add and search documents

In another terminal, add and search documents immediately:

```bash
mesa add document.pdf
mesa search "your query"
```

## Python SDK

```python
from mesa_client import Mesa

with Mesa() as mesa:
    document = mesa.add_file("document.pdf", wait=True)
    print(mesa.search("your query", document_ids=[document["document_id"]]))
```

`Mesa()` uses `MESA_API_KEY` and `MESA_BASE_URL` when they are set, otherwise the local credentials in `~/.mesa/credentials.json`.

See [Law versions](docs/getting-started.md#law-versions) to store revisions of a law and search the wording in force on a date.

## Optional models and answers

Run `mesa setup` to choose embeddings and a chat model. Restart `mesa start`
to apply the saved settings. With a chat model configured, run
`mesa ask "your question"` for a cited answer or `mesa summarize <document-id>`
for a single-document summary. Applications can call `POST /v1/chat/completions`
with a MESA API key and model `mesa`.

The SDK also exports OpenAI-format `search`, `read_text` and `list_documents`
tools for applications that handle their own model calls.
[Model configuration](docs/configuration.md) ·
[Answering and tools](docs/api-reference.md#llm-answers-and-summaries)

## Connect MCP clients

Run `mesa mcp config codex` or select a supported client to print its
configuration. MCP supports agent memory insert and recall, plus model-backed
`mesa_ask` and `mesa_summarize`.
[MCP guide](README_MCP.md)

Canonical V4 fact extraction is owned by `FactExtractionService` and can be
enabled separately with `MESA_EXTRACTION_ENABLED=true` and a configured chat
model.

## Docker

Run MESA on your own server with one command (non-root container, persistent volume, rate limits enabled by default, bootstrap API key printed once on first boot):

```bash
docker compose -f docker-compose.v4.yml up --build -d
```

Read the one-time bootstrap key from first-start logs (`docker compose -f docker-compose.v4.yml logs mesa-v4`) or `/var/lib/mesa/credentials.json` in the persistent volume:

```bash
docker compose -f docker-compose.v4.yml exec mesa-v4 cat /var/lib/mesa/credentials.json
docker compose -f docker-compose.v4.yml exec -T mesa-v4 mesa add - --source file://document.txt < document.txt
docker compose -f docker-compose.v4.yml exec mesa-v4 mesa search "your query"
```

No variables are required; models and external providers default off. See [Install on your own server](docs/self-hosted-docker.md) for hardware minimums, optional embedding/LLM environment settings, TLS reverse proxy setup, backups, and upgrades. If you set `MESA_API_KEY` and `MESA_PRINCIPAL_ID` for existing HTTP clients, the server accepts that key too, and the `mesa` commands inside the container use it first; add `-e MESA_API_KEY=` after `exec` to use the local credentials instead. Build with `--build-arg MESA_EXTRAS=ml` to add local sentence-transformers. Ollama defaults to `http://host.docker.internal:11434` (the Docker host).

## Google Colab

Run MESA with GPU-accelerated Ollama in Colab:
[Colab Quickstart](https://github.com/Yasou13/MESA/blob/main/examples/colab_quickstart.ipynb)

## Development

```bash
uv sync --locked --python 3.11
```

See [testing](https://github.com/Yasou13/MESA/blob/main/docs/testing.md) for local tests and test markers.

## Documentation

- [Getting Started Guide](docs/getting-started.md)
- [Install on Your Own Server (Docker)](docs/self-hosted-docker.md)
- [Configuration Reference](docs/configuration.md)
- [API Reference](docs/api-reference.md)
- [MCP Integration Guide](README_MCP.md)
- [Architecture](ARCHITECTURE.md)
- [Documentation Index](docs/README.md)

## License

MESA is licensed under the [Apache License, Version 2.0](https://github.com/Yasou13/MESA/blob/main/LICENSE). See [NOTICE](https://github.com/Yasou13/MESA/blob/main/NOTICE) for copyright information.
