Skip to content

Connect Your Agent

Add persistent memory to your AI agent in under 2 minutes. MemLayer works with any MCP-compatible client via stdio transport.

Make sure memlayer is running:

Terminal window
bb local-server # local mode (recommended, port 8090)
# or: bb server # development mode (port 8080)

Pick your client and add memlayer as an MCP server:

One command (recommended):

Terminal window
claude mcp add memlayer -- bb mcp

Or create .mcp.json in your project root:

{
"mcpServers": {
"memlayer": {
"command": "bb",
"args": ["mcp"],
"cwd": "/path/to/memlayer"
}
}
}

Reload your Claude Code session to pick up the config.

Ask your agent:

“Remember that I prefer dark mode in all my editors”

If memlayer is connected, the agent will call the memlayer_retain tool and confirm the memory was stored.

Then test recall:

“What are my editor preferences?”

The agent calls memlayer_recall and returns your stored memory.

Once connected, your agent has access to five tools:

ToolWhat it does
memlayer_retainStore memories from conversation content
memlayer_recallSemantic search across stored memories
memlayer_reflectConsolidate scattered memories into concepts
memlayer_forgetRemove a memory from active queries
memlayer_batch_retainStore multiple memories in a single call

See MCP Tools Reference for full parameter details.

When your agent connects via MCP, two things happen:

  1. Tool discovery: The agent receives tool definitions (names, parameters, descriptions) through the MCP tools/list method. This tells the agent what tools are available.

  2. Behavioral instructions via SKILL.md: memlayer serves a SKILL.md file that your agent loads as a system prompt. This is the key part — it teaches the agent when and how to use memory effectively. The instructions include:

    • When to recall: Always check memory before answering questions about the user’s preferences, past decisions, or project context. Do this silently — don’t announce it.
    • When to retain: Watch for high-signal moments like explicit preferences (“I prefer Tailwind”), corrections, decisions, and project context. Retain immediately and unobtrusively.
    • How to write good memories: Third person, specific, self-contained, one fact per memory.
    • Budget awareness: Be conservative — fewer high-quality memories beat many low-value ones.
    • End of conversation: Review for any unretained facts worth saving and propose them to the user.

    Without SKILL.md, the agent would have the tools but wouldn’t know the best practices for using them. The skill file is what makes memory feel natural rather than mechanical.

    You can read the full instructions at resources/public/SKILL.md in the repository.

Any client that supports stdio transport can connect to memlayer:

SettingValue
Commandbb
Args["mcp"]
Working directoryPath to your memlayer installation
Transportstdio