Skip to main content
Glama
README.md
<div align="center">

# ๐Ÿง  memory_graph_mcp

**An MCP server that gives your AI agent a persistent knowledge graph of your project.**

[![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![MCP](https://img.shields.io/badge/Model_Context_Protocol-stdio-8A2BE2)](https://modelcontextprotocol.io)
[![Tests](https://img.shields.io/badge/tests-31%2F31-brightgreen)](#-development)
[![License](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
[![Node](https://img.shields.io/badge/node-%E2%89%A518-339933?logo=nodedotjs&logoColor=white)](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

A3.7/5.0

Scored across 5 tools

Disambiguation5/5

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.

Naming Consistency4/5

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.

Tool Count5/5

Five tools is a tight, well-scoped set that covers the server's apparent purpose without redundancy or bloat. Each tool earns its place.

Completeness4/5

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.

Maintenance

ActivityMaintained
ResponsivenessNo issues