Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

MemCell Logo

memcell

Official Python SDK for MemCell.
Persistent, adaptive memory substrate for AI agents, workflows, and LLM pipelines.

PyPI version License: Apache-2.0 Python >= 3.10 Documentation

pip install memcell
# or: uv add memcell
import asyncio
from memcell import AsyncMemCell

async def main():
    async with AsyncMemCell(api_key="mc_live_...") as memory:
        # 1. Recall relevant memories before an agent acts:
        recall = await memory.recall(
            namespace="acme/support",
            query="refund verification and escalation thresholds",
        )
        print(recall.prompt_context)
        # [directive] Require explicit customer confirmation before applying refunds over $500 (confidence: 0.94)

asyncio.run(main())

Core Primitives

1. recall — Query Memory Before Acting

Query verified directives, facts, preferences, and observations using natural language.

recall = await memory.recall(
    namespace="acme/support",
    query="refund verification and escalation thresholds",
)

# prompt_context is formatted and ready to drop directly into agent prompts:
print(recall.prompt_context)

2. remember — Save Memories

Save a verified directive, fact, preference, or observation so future agents inherit it immediately:

await memory.remember(
    namespace="acme/support",
    title="Require explicit customer confirmation before applying refunds over $500",
    type="directive",
)

3. report — Close the Feedback Loop

Memory adapts when told what happened. When an agent succeeds or fails after applying memory, report the outcome:

await memory.report(
    namespace="acme/support",
    memory_id="mem_019a4b2c",
    outcome="worked",  # "worked" | "failed" | "avoided"
    reason="Customer verified and refund issued within guidelines",
)

Closed-Loop Execution (wrap_execution)

With wrap_execution, you can wrap any agent action or tool invocation in a self-healing, closed-loop memory:

import os
from memcell import AsyncMemCell

async def handle_refund(ticket_id: str, amount: int):
    async with AsyncMemCell(api_key=os.environ["MEMCELL_API_KEY"]) as memory:
        support = memory.scope("acme/support")

        # Wrap execution in a continuous learning loop:
        result = await support.wrap_execution(
            action="process_refund",
            query="refund verification requirements",
            fn=lambda ctx: process_refund(ticket_id, amount),
        )
        # Automatically reports "worked" on success (or "failed" on error) and updates confidence scores.
        return result.result

Resource Namespaces

The SDK provides direct, typed access to all MemCell platform resources across both synchronous (MemCell) and asynchronous (AsyncMemCell) clients:

Memories (memory.memories)

  • list(namespace, ...): Paginated query with filtering by type, status, scope, q, sort.
  • get(namespace, id): Retrieve an individual memory.
  • create(namespace, title, type="directive", ...): Create a memory (guard, directive, fact, preference, observation).
  • update(namespace, id, ...): Update memory content, status, confidence, or metadata.
  • delete(namespace, id): Delete a memory.
  • star(namespace, id, starred=True): Star or unstar a memory.
  • history(namespace, id): Retrieve complete version and mutation history.
  • adopt(namespace, id, target_workspace_ids): Adopt a memory into other workspaces.
  • promote(namespace, id, to_scope="workspace"): Promote a provisional memory to active.

Workspaces (memory.workspaces)

  • list(...): List caller's accessible workspaces.
  • list_for_owner(owner, ...): List workspaces belonging to an owner.
  • get(namespace): Retrieve workspace details.
  • create(name, ...): Create a new workspace.
  • update(namespace, ...): Update workspace properties.
  • delete(namespace): Delete a workspace.
  • transfer(namespace, target_owner): Transfer workspace ownership.

Agents (memory.agents)

  • list(namespace, ...): List agents registered in a workspace.
  • get(namespace, agent_id): Retrieve agent details.
  • create(namespace, name, ...): Register an agent.
  • update(namespace, agent_id, ...): Update agent configuration.
  • delete(namespace, agent_id): Deregister an agent.
  • create_key(namespace, agent_id, ...): Generate a scoped agent API key.
  • revoke_key(namespace, agent_id, key_id): Revoke an agent key.

Collaborators (memory.collaborators)

  • list(namespace, ...): List workspace collaborators and pending invitations.
  • invite(namespace, identifier, role="read"): Invite a user or email to collaborate.
  • update_role(namespace, user_id, role): Update a collaborator's role.
  • remove(namespace, user_id): Remove a collaborator.
  • revoke_invitation(namespace, invitation_id): Revoke an invitation.

Organizations (memory.organizations)

  • list(...), get(org_slug), create(slug, name, ...), update(org_slug, ...), delete(org_slug)
  • list_members(org_slug, ...), update_member_role(org_slug, user_id, role), remove_member(org_slug, user_id)
  • list_invitations(org_slug), invite_member(org_slug, email, role, ...), revoke_invitation(org_slug, invitation_id)

Usage & Quotas (memory.usage)

  • get(owner, timeframe="30d"): Retrieve memory type breakdown and API quotas.

Account (memory.account)

  • get(), update_profile(...)
  • tokens.list(), tokens.create(name, ...), tokens.revoke(token_id)

Scoped Handle (memory.scope(namespace))

Provides convenient namespace-bound access:

  • scoped.memories.*, scoped.agents.*, scoped.collaborators.*, scoped.scopes.list()

Synchronous Client (MemCell)

If you are working in synchronous scripts, Celery tasks, or standard Python workers, use the synchronous MemCell client with identical ergonomics:

from memcell import MemCell

memory = MemCell(api_key="mc_live_...")

recall = memory.recall(
    namespace="acme/support",
    query="refund verification and escalation thresholds",
)
for memory_item in recall.memories:
    print(f"[{memory_item.type}] {memory_item.title} (confidence: {memory_item.confidence})")

Configuration & Resilience

Machine-to-Machine (M2M) OAuth 2.0

For enterprise and backend microservices, authenticate using client credentials. Tokens are automatically exchanged and refreshed 60 seconds before expiration:

from memcell import AsyncMemCell

memory = AsyncMemCell(
    client_id=os.environ["MEMCELL_CLIENT_ID"],
    client_secret=os.environ["MEMCELL_CLIENT_SECRET"],
    scope="memory:read:acme/* memory:write:acme/backend",
)

Built-in 429 Resilience

MemCell automatically handles HTTP 429 rate limits with randomized jittered exponential backoff respecting the server's Retry-After header:

memory = AsyncMemCell(
    api_key="mc_live_...",
    max_retries=3,  # default: 3
    on_rate_limit_warning=lambda warning, response: print(
        f"Approaching rate limit: {warning.limit}"
    ),
)

Apache License 2.0 · © 2026 Memcell, Inc.

Metadata

Release files for memcell 1.4.0

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for memcell 1.4.0
File Size Uploaded Provenance
memcell-1.4.0.tar.gz 73.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for memcell 1.4.0
File Interpreter ABI Platform
memcell-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 118.4 kB

Release files / memcell-1.4.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL memcell-1.4.0.tar.gz
Size 73.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29876ccf2c3ba86fd14fea5a7da5ccca0dfcfa3f467ee5cbaec1d38892aa82bf
BLAKE2b-256 checksum
How to use checksums
03607aefa581b0a4f008109ed1b3a9b9b5c0a316c89abdc6321f68bd61acaecf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / memcell-1.4.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL memcell-1.4.0-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce82d9f019febb4b981ed00839c40adb2d06b9c0d0c34b833684d46cf816d14d
BLAKE2b-256 checksum
How to use checksums
5bb25a83c206dd8bbd35f0f37ee30bae61cdd060509282586feede2b2fa1ed1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for memcell 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Change of provenance

The repository that created this release differs from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Repository

  • Removed 0.1.5 GitHub: memcell-ai/sdk
  • Added 1.4.0 GitHub: memcell-ai/devkit
Select from 2 files

Attestation for memcell-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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