n2n-memory
n2n-memory is a project-local knowledge graph MCP server that lets AI coding agents store, retrieve, and manage durable project knowledge and task context — all isolated per repository in .mcp/ files.
Graph Writes
n2n_add_entities– Add named entities (e.g., classes, functions, modules) with types and observations.n2n_add_observations– Append new facts to existing entities.n2n_create_relations– Link entities with typed relationships (e.g., CALLS, EXTENDS, USES).
Graph Reads
n2n_read_graph– Read the full knowledge graph with optional pagination and summary mode.n2n_get_graph_summary– Retrieve a lightweight summary (entity names and types) to save tokens.n2n_search– Search across entities, types, and observations with optional fuzzy matching and relevance scoring.n2n_open_nodes– Fetch full details for specific named entities.
Context Management
n2n_update_context– Track active task state including status (IN_PROGRESS, COMPLETED, BLOCKED, PLANNING), next steps, last Git commit, and reasons — saved tocontext.jsonfor session handoffs.
Maintenance & Export
n2n_delete_entities/n2n_delete_observations/n2n_delete_relations– Remove entities, specific observations, or relations from the graph.n2n_export_markdown– Export the entire knowledge graph to a Markdown file (default:KNOWLEDGE_GRAPH.md) in the project root.
Project Isolation & Initialization
All tools require an absolute
projectPath, scoping memory per repository.New projects require a confirmation handshake (
confirmNewProjectRoot) before.mcp/storage is created, preventing accidental initialization outside valid project roots (identified by markers like.gitorpackage.json).
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@n2n-memoryAdd entity 'Login Flow' and connect it to 'Auth Module'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
n2n-memory
Project-local knowledge-graph memory MCP server from N2NS Lab for AI coding agents.
Context as code. Memory as asset.
n2n-memory is an open-source, local-first Model Context Protocol (MCP) memory server for AI coding assistants. It prevents cross-project memory pollution by storing durable project knowledge in .mcp/memory.json and active task context in .mcp/context.json inside each repository.
📚 Contents
Related MCP server: Neo4j Memory Server
💡 What is n2n-memory?
n2n-memory gives AI coding tools a project-local knowledge graph they can read and update through MCP. Memory and context are stored inside each repository under .mcp/, keeping them isolated, Git-friendly, and reviewable.
Restore project context at the start of an AI coding session.
Preserve architecture decisions, implementation notes, and known pitfalls.
Share durable project memory with teammates through Git.
Keep memory isolated per repository when working across many projects.
🚀 Quick start
1. Configure your MCP client
Claude Desktop
File Path: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"n2n-memory": {
"command": "npx",
"args": ["-y", "n2n-memory"]
}
}
}Cursor / VS Code
Add in the MCP settings panel:
Name:
n2n-memoryType:
commandCommand:
npx -y n2n-memory
Other MCP clients
The server uses stdio MCP and can be wired to any MCP client that supports local command execution.
If your client supports it, set
N2N_LOG_LEVEL=debugonly when troubleshooting local path resolution.
2. Usage guide
This service is path-driven. AI assistants should pay attention to:
Absolute Project Root: When calling any
n2n_*tool, provide the absolute path of the current project root or workspace top-level directory (projectPath).Initialization Handshake: The first call in a project that has no
.mcp/yet does not create anything. The server detects the project root and replies withstatus: "AWAITING_CONFIRMATION"and adetectedRoot. Call the same tool again withconfirmNewProjectRootset to that exactdetectedRootto initialize memory. Folders without a real project marker (.git,package.json, language build files, …) are rejected outright, so memory is never created in an arbitrary directory.Auto Storage: Durable memory is saved to
[ProjectPath]/.mcp/memory.json; active task context is saved to[ProjectPath]/.mcp/context.json.Collaboration: Commit
.mcp/memory.jsonwhen the knowledge graph should be shared with the team. Commitcontext.jsononly if your workflow wants active task state shared.
Storage layout inside each project:
<project-root>/
└── .mcp/
├── memory.json # durable knowledge graph — commit to share with the team
└── context.json # active task context — usually kept localRecommended .gitignore policy for teams that want to share durable memory:
.mcp/context.json
!.mcp/
!.mcp/memory.jsonIf your project memory may contain private implementation details, keep the whole .mcp/ directory ignored.
Available tools
Graph writes (
n2n_add_entities,n2n_add_observations,n2n_create_relations): add entities, observations, and relations to build the knowledge graph.Graph reads (
n2n_read_graph,n2n_get_graph_summary,n2n_search,n2n_open_nodes): read the full graph, get a lightweight summary, search, or open specific entities.Context (
n2n_update_context): update active task state before commits and handoffs.Maintenance (
n2n_delete_entities,n2n_delete_observations,n2n_delete_relations,n2n_export_markdown): delete entities, observations, or relations; export the graph to Markdown.
See Tools reference for parameter schemas and usage notes.
⚙️ Configuration
n2n-memory runs as a stdio MCP server with no CLI subcommands — start it with npx -y n2n-memory (or n2n-memory once installed). Storage location is derived from the projectPath you pass to each tool, not from configuration.
Variable | Description | Default |
| Set to | unset |
🔐 Security and governance notes
n2n_delete_entities,n2n_delete_observations, andn2n_delete_relationsare destructive and should be governed by review workflows.Keep
context.jsonuncommitted by default, and commit.mcp/memory.jsononly when team sharing is intentional.Existing but unreadable JSON files are treated as data integrity errors, not as empty memory.
Export paths must be relative and must stay inside the project root.
Relations that point to missing entities are rejected.
Generic README-only folders are not treated as project roots; use a real project marker such as
.git,package.json, or language-specific build files.Full local paths are hidden from server logs by default. Set
N2N_LOG_LEVEL=debugwhen diagnosing path issues.See SECURITY.md for vulnerability reporting.
📖 Related docs
Design: Why project-level isolation?
Tools reference: MCP tool parameter schemas and usage notes.
Development: How to build, test and extend.
Roadmap: Planned features and what's coming next.
Changelog: Version history and incident recovery.
Contributing: How to report issues and contribute.
Security: How to report vulnerabilities.
📄 License
This project is licensed under the MIT License.
Built by N2NS Lab, the open-source lab of datafrog.io for practical AI developer tools.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/n2ns/n2n-memory'
If you have feedback or need assistance with the MCP directory API, please join our Discord server