memory_graph_mcp
<div align="center">
# ๐ง memory_graph_mcp
**An MCP server that gives your AI agent a persistent knowledge graph of your project.**
[](https://www.typescriptlang.org/)
[](https://modelcontextprotocol.io)
[](#-development)
[](LICENSE)
[](https://nodejs.org)
*AST dependencies ยท DB-schema links ยท debugging sessions ยท side effects*
</div>
---
## ๐ก Why
When a feature is requested, the agent receives a **dependency subgraph**, not a list of similar files โ protecting adjacent modules from breaking changes.
```
graph_query_context("src/api/users.ts")
โโโโโโโโโโโโโโโโโโโ imports โโโโโโโโโโโโโโโโโโโ
โ src/db/users.ts โ โโโโโโโโโโโโโโโ โ src/api/users.ts โ
โโโโโโโโโโฌโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ writes_table
โผ
[table: users] โโโ also touched by 2 other files
```
Instead of *"here are 5 files matching `users`"* the agent learns: *changing this file affects two other modules, writes to the `users` table, and a past debug session recorded a missing `await` bug here.*
## ๐ Tools
| Tool | Purpose |
|---|---|
| `graph_query_context` | file/symbol โ dependency subgraph + adjacent modules + related sessions |
| `graph_impact_analysis` | planned change โ affected nodes, tables, and risk level |
| `graph_get_side_effects` | implicit module effects: table reads/writes, calls |
| `graph_record_session` | record a discussion/debug session with decisions and bugs, linked to files |
| `graph_stats` | index state: nodes, edges, files, last update time |
## ๐ฆ Installation
> Requires Node.js โฅ 18
```bash
git clone git@github.com:FuryCow/memory_graph_mcp.git
cd memory_graph_mcp
npm install
npm run build
```
## ๐ Connecting
The server communicates over stdio. Set the **root of the project you want to index** as the working directory (`cwd`) in your MCP client config โ the index is built from `process.cwd()` and stored in `.memory-graph/graph.db`.
### Claude Desktop / Cursor
The configuration is identical for both clients; only the config file location differs:
- **Claude Desktop:** `claude_desktop_config.json` (menu โ Settings โ Developer โ Edit Config)
- **Cursor:** `~/.cursor/mcp.json`
```json
{
"mcpServers": {
"memory-graph": {
"command": "node",
"args": ["/absolute/path/to/memory_graph_mcp/dist/src/index.js"],
"cwd": "/absolute/path/to/your/project"
}
}
}
```
> ๐ก On Windows, escape paths (`C:\\path\\to\\...`) or use forward slashes (`C:/path/to/...`).
## ๐บ Graph model
| | |
|---|---|
| **Nodes** | `File`, `Symbol`, `Table` โ journal: `Session`, `Decision`, `Bug` |
| **Edges** | `imports`, `calls`, `contains`, `reads_table`, `writes_table` |
The indexer ([tree-sitter](https://tree-sitter.github.io/)) extracts imports, function definitions and calls, and database access from SQL strings (`SELECT/INSERT/UPDATE/DELETE`) and ORM patterns (Prisma, drizzle). A watcher ([chokidar](https://github.com/paulmillr/chokidar)) incrementally re-indexes the graph on file changes โ typically **under a second**.
## ๐งฐ Stack
| Layer | Technology |
|---|---|
| Server | `@modelcontextprotocol/sdk` (stdio) |
| Parsing | `tree-sitter` (TypeScript / TSX / JavaScript) |
| Storage | `better-sqlite3` (WAL) in `.memory-graph/graph.db` |
| Watching | `chokidar` (mtime-based incremental re-index) |
## ๐ Development
```bash
npm run build # tsc
npm test # node --test dist/test/*.test.js
npm run lint # tsc --noEmit
```
## ๐ License
[MIT](LICENSE)
TDQS
Scored across 5 tools
Each tool targets a distinct operation: recording a session, querying context, analyzing impact, inspecting side effects, and viewing stats. There is no meaningful overlap, so an agent can reliably pick the right tool.
All tools share the graph_ prefix and most follow a verb_noun pattern, but graph_impact_analysis and graph_stats are noun-style names and only graph_get_side_effects uses 'get_'. The overall pattern is still predictable and readable.
Five tools is a tight, well-scoped set that covers the server's apparent purpose without redundancy or bloat. Each tool earns its place.
The set covers the core workflows: recording new knowledge, querying relationships, assessing change impact, inspecting side effects, and checking index health. Minor gaps like updating or deleting sessions are absent but not critical to the primary graph-based workflow.