MCP Memory
Give your agent persistent memory across sessions using a local knowledge graph.
- Package:
@modelcontextprotocol/server-memory - Provider: Anthropic / MCP
Overview
The Memory MCP server gives your agent a persistent knowledge graph stored locally. It can create entities, define relationships between them, and recall stored facts in future sessions — enabling stateful agents that remember users, context, and prior interactions across conversations.
Getting Started
Install the package:
pnpm add @modelcontextprotocol/server-memoryUse the server in your agent:
import { McpMemory } from "@iqai/adk";
const toolset = McpMemory();
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "Memory MCP Client",
description: "Client for persistent agent memory via knowledge graph",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@modelcontextprotocol/server-memory"],
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
}Environment Variables
No environment variables are required. The knowledge graph is stored locally in the server's working directory.
Available Tools
create_entitiesentities:array
create_entitiesDescription
Create multiple new entities in the knowledge graph
create_relationsrelations:array
create_relationsDescription
Create multiple new relations between entities in the knowledge graph. Relations should be in active voice
add_observationsobservations:array
add_observationsDescription
Add new observations to existing entities in the knowledge graph
delete_entitiesentityNames:array
delete_entitiesDescription
Delete multiple entities and their associated relations from the knowledge graph
delete_observationsdeletions:array
delete_observationsDescription
Delete specific observations from entities in the knowledge graph
delete_relationsrelations:array
delete_relationsDescription
Delete multiple relations from the knowledge graph
read_graphNo parameters
read_graphNo parameters
Description
Read the entire knowledge graph
search_nodesquery:string
search_nodesDescription
Search for nodes in the knowledge graph based on a query
open_nodesnames:array
open_nodesDescription
Open specific nodes in the knowledge graph by their names
Integration Example
import { AgentBuilder, McpMemory } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpMemory toolset
const toolset = McpMemory();
// Get available McpMemory tools
const memoryTools = await toolset.getTools();
// Create agent with McpMemory tools
const { runner } = await AgentBuilder.create("memory_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"A personal assistant that remembers your preferences and past interactions",
)
.withTools(...memoryTools)
.build();
// First session — store a fact
await runner.ask(
"Remember that my name is Alex and I prefer concise answers",
);
// Later session — recall it
const response = await runner.ask("What do you know about me?");
console.log(response);
}
main().catch(console.error);