n2n-memory
n2n-memory is a project-local knowledge-graph memory and task-context MCP server for AI coding agents.
Build a per-project knowledge graph by adding entities, observations, and relations (
n2n_add_entities,n2n_add_observations,n2n_create_relations).Read and explore memory via full graph reads, lightweight summaries, search, and opening specific nodes (
n2n_read_graph,n2n_get_graph_summary,n2n_search,n2n_open_nodes).Maintain active task context/status for handoffs and commits with
n2n_update_context.Delete entities, observations, or relations and export the graph to Markdown (
n2n_delete_*,n2n_export_markdown).Store durable memory in
<project>/.mcp/memory.jsonand active context in<project>/.mcp/context.json, isolated per repository and Git-friendly.Require an absolute
projectPathand a confirmation handshake (confirmNewProjectRoot) to initialize memory only in valid project roots.
Click on "Deploy 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-memory Add 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: kg-mcp
π‘ 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 Apache-2.0 License.
Built by N2NS Lab, the open-source lab of datafrog.io for practical AI developer tools.
Available Tools
12 toolsn2n_add_entitiesD
Inputs: projectPath (required), entities (required), confirmNewProjectRoot.
n2n_add_observationsD
Inputs: projectPath (required), observations (required), confirmNewProjectRoot.
n2n_create_relationsD
Inputs: projectPath (required), relations (required), confirmNewProjectRoot.
n2n_delete_entitiesD
Inputs: projectPath (required), entityNames (required), confirmNewProjectRoot.
n2n_delete_observationsD
Inputs: projectPath (required), deletions (required), confirmNewProjectRoot.
n2n_delete_relationsD
Inputs: projectPath (required), relations (required), confirmNewProjectRoot.
n2n_export_markdownD
Inputs: projectPath (required), confirmNewProjectRoot, outputPath.
n2n_get_graph_summaryD
Inputs: projectPath (required), confirmNewProjectRoot, limit, offset.
n2n_open_nodesD
Inputs: projectPath (required), names (required), confirmNewProjectRoot.
n2n_read_graphD
Inputs: projectPath (required), confirmNewProjectRoot, summaryMode, limit, +1 more.
n2n_searchD
Inputs: projectPath (required), query (required), confirmNewProjectRoot, limit, +3 more.
n2n_update_contextD
Inputs: projectPath (required), confirmNewProjectRoot, activeTask, status, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 12 tools
Each tool targets a distinct operation (add, delete, create, read, search, update) on specific resources (entities, observations, relations, graph). No overlap in purpose despite missing descriptions.
All tools follow the consistent pattern 'n2n_<verb>_<noun>' using snake_case. The verb choices are clear and the noun targets are explicit.
12 tools cover the typical operations for a memory/knowledge graph server without being excessive or sparse. The scope feels well-balanced.
The set covers add, delete, and read operations for entities and observations, plus relations and graph exports. Missing update operations for some resources, but the core workflows are present.
Maintenance
Related MCP Connectors
Project memory for coding agents: requirements, decisions, code graph and delivery telemetry.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Project memory, documentation and controlled secret access for AI coding agents.
Shared project memory that keeps teammates and AI agents aligned across sessions.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides persistent local memory for AI coding sessions, enabling agents to save and retrieve project context across different tools and sessions.16MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to store, query, and update persistent project knowledge as a local, Git-friendly knowledge graph, providing structured memory across sessions.9Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI agents to maintain a persistent knowledge graph of a project, providing dependency context, impact analysis, side-effect discovery, and session recording for more informed coding decisions.5MIT
- AlicenseNot gradedqualityBmaintenanceProvides persistent cognitive memory for AI coding agents, enabling them to recall architecture decisions, coding preferences, and project facts across sessions.66MIT