TypeScriptADK-TS

MCP Memory

Give your agent persistent memory across sessions using a local knowledge graph.

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-memory

Use 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_entities
entities:array

Description

Create multiple new entities in the knowledge graph

create_relations
relations:array

Description

Create multiple new relations between entities in the knowledge graph. Relations should be in active voice

add_observations
observations:array

Description

Add new observations to existing entities in the knowledge graph

delete_entities
entityNames:array

Description

Delete multiple entities and their associated relations from the knowledge graph

delete_observations
deletions:array

Description

Delete specific observations from entities in the knowledge graph

delete_relations
relations:array

Description

Delete multiple relations from the knowledge graph

read_graph

No parameters

Description

Read the entire knowledge graph

search_nodes
query:string

Description

Search for nodes in the knowledge graph based on a query

open_nodes
names:array

Description

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);

Further Resources