Skip to main content

Overview

Claude Managed Agents is Anthropic’s hosted platform for running autonomous AI agents. Mengram connects via MCP to give your agents persistent memory across sessions — facts, events, and self-improving workflows.

Setup

1. Get a Mengram API key

Sign up at mengram.io — free tier includes 40 adds and 200 searches per month.

2. Add Mengram to your agent definition

{
  "name": "my-agent",
  "model": "claude-sonnet-4-6",
  "instructions": "You are a helpful assistant with persistent memory.",
  "mcp_servers": [
    {
      "type": "url",
      "name": "mengram",
      "url": "https://mengram.io/mcp"
    }
  ],
  "tools": [
    {
      "type": "agent_toolset_20260401",
      "default_config": {
        "enabled": true,
        "permission_policy": {"type": "always_allow"}
      }
    },
    {
      "type": "mcp_toolset",
      "mcp_server_name": "mengram",
      "default_config": {
        "enabled": true,
        "permission_policy": {"type": "always_allow"}
      }
    }
  ]
}
Set permission_policy to always_allow for the MCP toolset. The default (always_ask) requires manual tool confirmation via the API — without it, every memory tool call will time out.

3. Store your API key in a vault

Managed Agents use vaults for secrets. Create a vault, add your Mengram API key as a static_bearer credential, then pass the vault when creating a session:
import anthropic

client = anthropic.Anthropic()

# Create a vault for this user
vault = client.beta.vaults.create(display_name="My User")

# Add Mengram API key as a credential
client.beta.vaults.credentials.create(
    vault_id=vault.id,
    display_name="Mengram Memory",
    auth={
        "type": "static_bearer",
        "mcp_server_url": "https://mengram.io/mcp",
        "token": "om-your-mengram-api-key",
    },
)

# Create an environment (container config for the session)
env = client.beta.environments.create(display_name="Default")

# Create a session — Anthropic injects the token automatically
session = client.beta.sessions.create(
    agent=agent.id,
    vault_ids=[vault.id],
    environment_id=env.id,
)

Available tools

Once connected, your agent gets 29 memory tools:

Core Memory

ToolDescription
rememberSave conversation to memory — auto-extracts facts, events, procedures
remember_textSave plain text to memory
recallSemantic search through past memories
searchAdvanced structured search with relevance scores
search_allUnified search across all 3 memory types
timelineSearch memory by time range
list_memoriesList all stored entities

Procedural Learning

ToolDescription
list_proceduresRetrieve learned workflows with success/failure tracking
procedure_feedbackReport outcomes — procedures evolve on failure
procedure_historyView how a procedure evolved over time

Context & Profile

ToolDescription
context_forGet relevant context pack for a specific task
checkpointSave a session checkpoint with key decisions
generate_rules_fileGenerate project rules from memory

Knowledge Graph

ToolDescription
get_graphGet all entities and relationships
get_entityGet details of a specific entity
merge_entitiesMerge duplicate entities
dedupAuto-find and merge duplicates

Insights

ToolDescription
reflectTrigger AI reflection on memories
get_reflectionsGet AI-generated insights and patterns
run_agentsRun memory agents (curator, connector, digest)
For the complete list of all 29 tools with parameters, see MCP Server.

Example: Support agent

import anthropic

client = anthropic.Anthropic()

# Create the agent with Mengram MCP
agent = client.beta.agents.create(
    name="support-agent",
    model="claude-sonnet-4-6",
    instructions="""You are a customer support agent with persistent memory.

At the start of each conversation:
1. Use recall() to search for the customer's past interactions
2. Use context_for() to get relevant procedures

After resolving issues:
1. Use remember() to save the conversation
2. Use procedure_feedback() to report success/failure""",
    mcp_servers=[
        {
            "type": "url",
            "name": "mengram",
            "url": "https://mengram.io/mcp"
        }
    ],
    tools=[
        {
            "type": "agent_toolset_20260401",
            "default_config": {
                "enabled": True,
                "permission_policy": {"type": "always_allow"}
            }
        },
        {
            "type": "mcp_toolset",
            "mcp_server_name": "mengram",
            "default_config": {
                "enabled": True,
                "permission_policy": {"type": "always_allow"}
            }
        }
    ]
)

# Store Mengram API key in a vault
vault = client.beta.vaults.create(display_name="Customer")
client.beta.vaults.credentials.create(
    vault_id=vault.id,
    display_name="Mengram Memory",
    auth={
        "type": "static_bearer",
        "mcp_server_url": "https://mengram.io/mcp",
        "token": "om-your-mengram-api-key",
    },
)

# Create environment and session
env = client.beta.environments.create(display_name="Support")
session = client.beta.sessions.create(
    agent=agent.id,
    vault_ids=[vault.id],
    environment_id=env.id,
)

# Send a message — agent recalls past context automatically
client.beta.sessions.events.send(
    session_id=session.id,
    events=[{
        "type": "user.message",
        "content": [{"type": "text", "text": "I'm having trouble with my deployment again"}]
    }]
)

# Stream the response
with client.beta.sessions.events.stream(session_id=session.id) as stream:
    for event in stream:
        if event.type == "agent.message":
            for block in event.content:
                if hasattr(block, "text"):
                    print(block.text)
        if event.type == "agent.turn_complete":
            break

Mengram vs Memory Stores

Managed Agents include built-in Memory Stores (research preview). Here’s how they compare:
FeatureMengramMemory Stores
Memory types3 (semantic + episodic + procedural)1 (text documents)
Auto-extractionYes — pass conversations, get structured knowledgeNo — manual text only
Procedural learningYes — workflows evolve from failuresNo
Cognitive ProfileYes — one-call system prompt generationNo
Knowledge graphYesNo
Semantic searchYesYes
Multi-user isolationYes (user_id parameter)Per-agent only
Works beyond AnthropicYes (any LLM, any framework)Managed Agents only
StatusProductionResearch preview

Self-hosted

If you’re self-hosting Mengram, point the MCP URL to your instance:
{
  "type": "url",
  "name": "mengram",
  "url": "http://your-host:8420/mcp"
}
See Self-hosting guide for setup instructions.

Next steps