TypeScriptADK-TS

MCP Memory

Memory and note-taking capabilities for persistent agent knowledge using Anthropic's memory MCP server

  • Name: MCP Memory
  • Package: @modelcontextprotocol/server-memory
  • Provider: Anthropic

Overview

MCP Memory is a third-party Model Context Protocol server from Anthropic that provides persistent memory and note-taking capabilities for AI agents. It enables agents to store, retrieve, and manage information across conversations, creating a knowledge base that persists beyond individual sessions.

Persistent Knowledge

The memory MCP server allows agents to remember information from previous interactions, making them more contextually aware and helpful over time.

Usage with ADK TypeScript

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 memory and note-taking",
  transport: {
    mode: "stdio",
    command: "npx",
    args: ["-y", "@modelcontextprotocol/server-memory"],
    env: {
      PATH: process.env.PATH || "",
    },
  },
});

const tools = await toolset.getTools();

If you want to use this MCP with Claude Desktop, add this to your Claude Desktop configuration file:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    }
  }
}

Environment Variables

No environment variables are required for the memory MCP server.

Configuration Options

All MCP servers support these configuration options:

OptionTypeDescription
envobjectEnvironment variables (see table above)
debugbooleanEnable debug logging
descriptionstringCustom description
retryOptions.maxRetriesnumberMax retry attempts (default: 2)
retryOptions.initialDelaynumberInitial retry delay in ms (default: 200)
samplingHandlerSamplingHandlerHandler for MCP sampling requests

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

Complete Example

import { McpMemory, LlmAgent } from "@iqai/adk";

async function main() {
  // Initialize memory toolset
  const memoryToolset = McpMemory({
    debug: true,
  });

  try {
    // Get available tools
    const tools = await memoryToolset.getTools();

    // Create agent with memory capabilities
    const agent = new LlmAgent({
      name: "knowledge_assistant",
      model: "gemini-2.5-flash",
      description: "An agent with persistent memory capabilities",
      instruction: `You have access to a persistent memory system.
        Store important information that users share with you.
        Retrieve relevant memories to provide contextual responses.
        Always check your memory before answering questions.`,
      tools,
    });

    // Use the agent
    const response1 = await agent.ask(
      "Remember that my favorite color is blue",
    );
    console.log(response1);

    // Later conversation - agent can recall
    const response2 = await agent.ask("What is my favorite color?");
    console.log(response2);
  } finally {
    // Always cleanup
    await memoryToolset.close();
  }
}

main();

Use Cases

  • Personalized Assistants: Remember user preferences and context
  • Knowledge Management: Build a persistent knowledge base
  • Conversation History: Track important details across sessions
  • Task Tracking: Remember ongoing tasks and their status
  • Learning Agents: Accumulate knowledge over time

Best Practices

  • Structured Storage: Use clear keys and organization for memories
  • Regular Cleanup: Periodically review and remove outdated memories
  • Privacy Consideration: Be mindful of sensitive information storage
  • Search Optimization: Use descriptive keys for easier retrieval
  • Error Handling: Handle cases where memories don't exist gracefully

Combining with Other MCPs

Memory works great when combined with other MCP servers:

import { McpMemory, McpFilesystem, LlmAgent } from "@iqai/adk";

// Combine memory with filesystem for persistent file knowledge
const memoryToolset = McpMemory();
const filesystemToolset = McpFilesystem({
  env: { ALLOWED_DIRECTORIES: "/workspace" },
});

const [memoryTools, fileTools] = await Promise.all([
  memoryToolset.getTools(),
  filesystemToolset.getTools(),
]);

const agent = new LlmAgent({
  name: "smart_file_manager",
  model: "gemini-2.5-flash",
  description: "File manager with memory of previous operations",
  tools: [...memoryTools, ...fileTools],
});

// Cleanup
await Promise.all([memoryToolset.close(), filesystemToolset.close()]);

Troubleshooting

IssueSolution
Memory not persistingCheck if server is properly initialized
Search returns no resultsVerify search query and memory key names
Connection timeoutEnsure npm/npx is installed and in PATH
Duplicate memoriesUse unique keys or update existing entries