# Memory MCP Server (`constant_quadruped/memory-mcp-server`) Actor

Persistent memory for AI agents via knowledge graph. Store entities, relations, and observations that persist across sessions. MCP-compatible.

- **URL**: https://apify.com/constant\_quadruped/memory-mcp-server.md
- **Developed by:** [CQ](https://apify.com/constant_quadruped) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 4 total users, 0 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Memory MCP Server - Knowledge Graph

Persistent memory and knowledge graph for AI agents. Store entities, relations, and observations that persist across sessions.

### Features

- **Entities** - Store named nodes with types and observations
- **Relations** - Connect entities with directional relationships
- **Observations** - Attach discrete facts to entities
- **Search** - Find entities by name, type, or observation content
- **Persistence** - Memory persists in Apify Key-Value Store
- **Multi-tenant** - Separate memory spaces using `memoryKey`

### Tools

| Tool | Description |
|------|-------------|
| `memory.create_entities` | Create new entities in the graph |
| `memory.create_relations` | Create relations between entities |
| `memory.add_observations` | Add facts to existing entities |
| `memory.delete_entities` | Remove entities (cascades relations) |
| `memory.delete_observations` | Remove specific observations |
| `memory.delete_relations` | Remove specific relations |
| `memory.read_graph` | Get complete graph with all data |
| `memory.search_nodes` | Search entities by query |
| `memory.open_nodes` | Get specific entities by name |

### Data Model

#### Entity
```json
{
  "name": "John Doe",
  "entityType": "person",
  "observations": [
    "Works at Acme Corp",
    "Lives in New York",
    "Prefers email communication"
  ]
}
````

#### Relation

```json
{
  "from": "John Doe",
  "to": "Acme Corp",
  "relationType": "works_at"
}
```

### Examples

#### Create Entities

```json
{
  "tool": "memory.create_entities",
  "memoryKey": "my-project",
  "entities": "[{\"name\": \"Alice\", \"entityType\": \"person\", \"observations\": [\"Team lead\", \"Prefers Slack\"]}]"
}
```

#### Create Relations

```json
{
  "tool": "memory.create_relations",
  "memoryKey": "my-project",
  "relations": "[{\"from\": \"Alice\", \"to\": \"Engineering Team\", \"relationType\": \"leads\"}]"
}
```

#### Add Observations

```json
{
  "tool": "memory.add_observations",
  "memoryKey": "my-project",
  "entityName": "Alice",
  "observations": "[\"Recently promoted\", \"Working on Q4 roadmap\"]"
}
```

#### Search Nodes

```json
{
  "tool": "memory.search_nodes",
  "memoryKey": "my-project",
  "searchQuery": "engineering"
}
```

#### Read Full Graph

```json
{
  "tool": "memory.read_graph",
  "memoryKey": "my-project"
}
```

### Use Cases

- **Personal Assistant Memory** - Remember user preferences, contacts, projects
- **CRM Knowledge Base** - Store customer information and relationships
- **Project Context** - Track team members, decisions, and dependencies
- **Research Notes** - Connect concepts, papers, and findings
- **Conversation History** - Persist important facts across chat sessions

### Memory Keys

Use `memoryKey` to create separate memory spaces:

- `user-123` - Per-user memory
- `project-alpha` - Per-project memory
- `session-xyz` - Per-session memory

Memory persists in Apify Key-Value Store under key `memory_{memoryKey}`.

### MCP Integration

Works with Claude Desktop, VS Code, and any MCP-compatible agent.

**Claude Desktop** (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "memory": {
      "url": "https://mcp.apify.com?actors=YOUR_USERNAME/memory-mcp-server"
    }
  }
}
```

### System Prompt Example

Add to your AI agent's system prompt:

```
You have access to a persistent memory system. At the start of each conversation:
1. Use memory.read_graph to recall what you know about the user
2. As you learn new information, use memory.create_entities and memory.add_observations to save it
3. Use memory.create_relations to connect related concepts

Important information to remember:
- User's name, preferences, and goals
- Projects they're working on
- People and organizations they mention
- Decisions and agreements made
```

### Pricing

Apify compute costs only. No external API required.

### Limits

| Limit | Value |
|-------|-------|
| Max entities | 10,000 |
| Max observations per entity | 1,000 |
| Max observation length | 10,000 chars |
| Memory file size | 10 MB |

### Support

For issues or feature requests, open a ticket on the Issues tab.

# Actor input Schema

## `tool` (type: `string`):

The memory tool to execute

## `memoryKey` (type: `string`):

Unique key to identify this memory store (e.g., user ID, project name). Default: 'default'.

## `entities` (type: `string`):

Array of entities to create. Each entity: {name, entityType, observations\[]}

## `relations` (type: `string`):

Array of relations. Each relation: {from, to, relationType}

## `entityName` (type: `string`):

Name of the entity (for single-entity operations)

## `observations` (type: `string`):

Array of observations to add (strings)

## `entityNames` (type: `string`):

Array of entity names (for batch operations or open\_nodes)

## `searchQuery` (type: `string`):

Search term for searching nodes (searches names, types, and observations)

## `loadExisting` (type: `boolean`):

Load existing memory from Apify Key-Value Store using memoryKey

## `saveMemory` (type: `boolean`):

Save memory to Apify Key-Value Store after operation

## Actor input object example

```json
{
  "tool": "memory.read_graph",
  "memoryKey": "default",
  "entities": "[{\"name\": \"John\", \"entityType\": \"person\", \"observations\": [\"Works at Acme Corp\", \"Lives in NYC\"]}]",
  "relations": "[{\"from\": \"John\", \"to\": \"Acme Corp\", \"relationType\": \"works_at\"}]",
  "observations": "[\"New observation 1\", \"New observation 2\"]",
  "entityNames": "[\"John\", \"Acme Corp\"]",
  "loadExisting": true,
  "saveMemory": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Tool execution results

## `keyValueStore` (type: `string`):

Persistent knowledge graph storage

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "tool": "memory.read_graph",
    "memoryKey": "default",
    "entities": "[{\"name\": \"John\", \"entityType\": \"person\", \"observations\": [\"Works at Acme Corp\", \"Lives in NYC\"]}]",
    "relations": "[{\"from\": \"John\", \"to\": \"Acme Corp\", \"relationType\": \"works_at\"}]",
    "observations": "[\"New observation 1\", \"New observation 2\"]",
    "entityNames": "[\"John\", \"Acme Corp\"]"
};

// Run the Actor and wait for it to finish
const run = await client.actor("constant_quadruped/memory-mcp-server").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "tool": "memory.read_graph",
    "memoryKey": "default",
    "entities": "[{\"name\": \"John\", \"entityType\": \"person\", \"observations\": [\"Works at Acme Corp\", \"Lives in NYC\"]}]",
    "relations": "[{\"from\": \"John\", \"to\": \"Acme Corp\", \"relationType\": \"works_at\"}]",
    "observations": "[\"New observation 1\", \"New observation 2\"]",
    "entityNames": "[\"John\", \"Acme Corp\"]",
}

# Run the Actor and wait for it to finish
run = client.actor("constant_quadruped/memory-mcp-server").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "tool": "memory.read_graph",
  "memoryKey": "default",
  "entities": "[{\\"name\\": \\"John\\", \\"entityType\\": \\"person\\", \\"observations\\": [\\"Works at Acme Corp\\", \\"Lives in NYC\\"]}]",
  "relations": "[{\\"from\\": \\"John\\", \\"to\\": \\"Acme Corp\\", \\"relationType\\": \\"works_at\\"}]",
  "observations": "[\\"New observation 1\\", \\"New observation 2\\"]",
  "entityNames": "[\\"John\\", \\"Acme Corp\\"]"
}' |
apify call constant_quadruped/memory-mcp-server --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=constant_quadruped/memory-mcp-server",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Memory MCP Server",
        "description": "Persistent memory for AI agents via knowledge graph. Store entities, relations, and observations that persist across sessions. MCP-compatible.",
        "version": "2.0",
        "x-build-id": "bzHKzzw1WKQJkAtYt"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/constant_quadruped~memory-mcp-server/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-constant_quadruped-memory-mcp-server",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/constant_quadruped~memory-mcp-server/runs": {
            "post": {
                "operationId": "runs-sync-constant_quadruped-memory-mcp-server",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/constant_quadruped~memory-mcp-server/run-sync": {
            "post": {
                "operationId": "run-sync-constant_quadruped-memory-mcp-server",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "tool": {
                        "title": "Tool",
                        "enum": [
                            "memory.create_entities",
                            "memory.create_relations",
                            "memory.add_observations",
                            "memory.delete_entities",
                            "memory.delete_observations",
                            "memory.delete_relations",
                            "memory.read_graph",
                            "memory.search_nodes",
                            "memory.open_nodes"
                        ],
                        "type": "string",
                        "description": "The memory tool to execute"
                    },
                    "memoryKey": {
                        "title": "Memory Key",
                        "type": "string",
                        "description": "Unique key to identify this memory store (e.g., user ID, project name). Default: 'default'."
                    },
                    "entities": {
                        "title": "Entities",
                        "type": "string",
                        "description": "Array of entities to create. Each entity: {name, entityType, observations[]}"
                    },
                    "relations": {
                        "title": "Relations",
                        "type": "string",
                        "description": "Array of relations. Each relation: {from, to, relationType}"
                    },
                    "entityName": {
                        "title": "Entity Name",
                        "type": "string",
                        "description": "Name of the entity (for single-entity operations)"
                    },
                    "observations": {
                        "title": "Observations",
                        "type": "string",
                        "description": "Array of observations to add (strings)"
                    },
                    "entityNames": {
                        "title": "Entity Names",
                        "type": "string",
                        "description": "Array of entity names (for batch operations or open_nodes)"
                    },
                    "searchQuery": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Search term for searching nodes (searches names, types, and observations)"
                    },
                    "loadExisting": {
                        "title": "Load Existing Memory",
                        "type": "boolean",
                        "description": "Load existing memory from Apify Key-Value Store using memoryKey",
                        "default": true
                    },
                    "saveMemory": {
                        "title": "Save Memory",
                        "type": "boolean",
                        "description": "Save memory to Apify Key-Value Store after operation",
                        "default": true
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
