Metadata-Version: 2.4
Name: memgraph-sdk
Version: 0.3.0
Summary: Official Python SDK for Memgraph - the memory graph for AI agents
Project-URL: Homepage, https://memgraph.ai
Project-URL: Documentation, https://memgraph.ai/docs
Project-URL: Repository, https://github.com/shubhamdev0/memgraph-sdk
Project-URL: Bug Tracker, https://github.com/shubhamdev0/memgraph-sdk/issues
Project-URL: Changelog, https://github.com/shubhamdev0/memgraph-sdk/blob/main/CHANGELOG.md
Author-email: Memgraph Team <sdk@memgraph.ai>
License: MIT License
        
        Copyright (c) 2026 Memgraph
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,ai,context,llm,memgraph,memory,rag
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.25.0
Requires-Dist: typing-extensions>=4.0.0
Provides-Extra: all
Requires-Dist: httpx>=0.24.0; extra == 'all'
Requires-Dist: rich>=13.0.0; extra == 'all'
Provides-Extra: async
Requires-Dist: httpx>=0.24.0; extra == 'async'
Provides-Extra: cli
Requires-Dist: rich>=13.0.0; extra == 'cli'
Provides-Extra: dev
Requires-Dist: httpx>=0.24.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# Memgraph SDK

The official Python SDK for **[Memgraph](https://memgraph.ai)** -- the memory graph for AI agents.

[![PyPI version](https://badge.fury.io/py/memgraph-sdk.svg)](https://pypi.org/project/memgraph-sdk/)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
pip install memgraph-sdk
```

For async support:

```bash
pip install "memgraph-sdk[async]"
```

## Quick Start

```python
from memgraph_sdk import MemgraphClient

client = MemgraphClient(
    api_key="mg_your_api_key",
    tenant_id="your-tenant-id",
)

# Store a memory
client.add(
    text="User prefers dark mode and uses PyTorch.",
    user_id="user_123",
)

# Search for relevant context
result = client.search(
    query="What does this user prefer?",
    user_id="user_123",
)
print(result)
```

## Async Client

```python
from memgraph_sdk import AsyncMemgraphClient

async with AsyncMemgraphClient(
    api_key="mg_your_api_key",
    tenant_id="your-tenant-id",
) as client:
    await client.add("User prefers dark mode", user_id="user_123")
    result = await client.search("user preferences", user_id="user_123")
```

## Memory Intelligence API

```python
# Memory health metrics
health = client.health(user_id="user_123")

# Detect contradictions
contradictions = client.contradictions(user_id="user_123")

# Evaluate retrieval quality
evaluation = client.evaluate(query="test query", user_id="user_123")

# Cognitive Integrity Score (0-100)
score = client.mcis(user_id="user_123")

# Run benchmarks
result = client.benchmark(scenario="contradiction_storm")
scenarios = client.benchmark_scenarios()
```

## CLI

```bash
# Initialize Memgraph in your project
memgraph init

# Store a memory
memgraph remember "We decided to use PostgreSQL" -c decision

# Search memories
memgraph recall "database choice"

# Check connection
memgraph status
```

## Configuration

The client reads the API URL from the `MEMGRAPH_API_URL` environment variable, defaulting to `http://localhost:8001/v1`. You can also pass it explicitly:

```python
client = MemgraphClient(
    api_key="mg_your_key",
    tenant_id="your-tenant-id",
    base_url="https://api.memgraph.ai/v1",
)
```

## Examples

See the [examples/](examples/) directory for complete integration examples:

- [Quick Start](examples/quick_start.py) -- Basic add and search
- [Agent Integration](examples/agent_integration.py) -- OpenAI-powered agent with memory
- [MCP Server](examples/integrations/mcp_server.py) -- Model Context Protocol server for Claude/Cursor
- [LangChain](examples/integrations/langchain_integration.py) -- LangChain integration
- [OpenAI](examples/integrations/openai_integration.py) -- OpenAI integration
- [Benchmarks](examples/integrations/benchmark.py) -- Performance benchmarking

## License

MIT License. See [LICENSE](LICENSE) for details.
