Skip to main content
Glama
README.md
# mcp-project-memory

A Model Context Protocol (MCP) server that gives Claude a **persistent memory of your project structure** — so it stops re-scanning your entire codebase at the start of every session.

## Why

On large projects, Claude typically spends 8,000–15,000 tokens per session just rediscovering the file structure, routes, and entry points. This server indexes your project once into a local `.claude/project_map.json` file, then answers structural questions instantly from that index.

## Tools

| Tool | What it does |
|---|---|
| `index_project` | Scans the project once → saves `.claude/project_map.json` |
| `search_context` | Find files by keyword or tag without globbing |
| `get_project_map` | Quick summary: routes, stats, framework, dependencies |
| `add_decision` | Record an architectural decision for future sessions |
| `get_decisions` | Read back the decision journal |

### Supported frameworks

Auto-detects Next.js (App Router), Nuxt, SvelteKit, Remix, React, Vue.

Classifies files as: `page`, `layout`, `route-api`, `action`, `component`, `type`, `constant`, `lib`, `migration`, `config`.

---

## Installation

### 1. Clone and build

```bash
git clone https://github.com/YOUR_USERNAME/mcp-project-memory.git
cd mcp-project-memory
npm install
npm run build
```

### 2. Register the server

**Claude Code (CLI):**
```bash
claude mcp add project-memory node /absolute/path/to/mcp-project-memory/dist/index.js
```

**Claude Desktop** — edit `claude_desktop_config.json`:

- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`

```json
{
  "mcpServers": {
    "project-memory": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-project-memory/dist/index.js"]
    }
  }
}
```

Restart Claude Desktop after editing.

---

## Usage

### Index your project (once per session or after major refactors)

```
index_project { "projectPath": "/path/to/your/project" }
```

Output:
```
✅ my-app indexed (Next.js 14.x)
📁 191 files | 🗺 45 routes | ⚡ 13 server actions

Pages (36):
  /dashboard     app/(dashboard)/page.tsx
  /settings      app/(dashboard)/settings/page.tsx
  ...

API Routes (6):
  [GET]     /api/users       app/api/users/route.ts
  [POST]    /api/auth/login  app/api/auth/login/route.ts
```

### Find files without scanning

```
search_context {
  "projectPath": "/path/to/project",
  "query": "signArret",
  "tag": "action"
}
```

### Get a session overview

```
get_project_map {
  "projectPath": "/path/to/project",
  "section": "routes"   // "summary" | "routes" | "dependencies" | "actions"
}
```

### Record an architectural decision

```
add_decision {
  "projectPath": "/path/to/project",
  "topic": "PDF generation library",
  "decision": "Use @react-pdf/renderer instead of Puppeteer",
  "rationale": "Puppeteer exceeds Vercel's 50MB function limit. react-pdf renders natively server-side with no headless browser needed.",
  "files": ["lib/pdf/arret.tsx", "app/api/arret/[id]/pdf/route.tsx"],
  "tags": ["pdf", "performance", "vercel"]
}
```

---

## What gets indexed

- All `.ts`, `.tsx`, `.js`, `.jsx`, `.sql` files under 100KB
- Skips: `node_modules`, `.git`, `.next`, `dist`, `build`, `.vercel`, `coverage`
- Extracts exported function/component names from TypeScript files
- Maps Next.js App Router file paths to URL routes (strips route groups)
- Detects HTTP methods from API route files

## Stored files

```
your-project/
└── .claude/
    ├── project_map.json   ← file index + route map
    └── decisions.json     ← architectural decision log
```

These files are local to each project. Add `.claude/` to your `.gitignore` if you don't want to commit them (or commit `decisions.json` to share architectural context with your team).

---

## Update after changes

```bash
cd mcp-project-memory
npm run rebuild
```

Then re-run `index_project` in your Claude session.

## License

MIT

TDQS

B3.4/5.0

Scored across 5 tools

Disambiguation4/5

The decision tools (get_decisions vs add_decision) are clearly distinct read/write pairs, and index_project is clearly a write/scan operation. The two read tools over the index (get_project_map for a summary, search_context for keyword/tag lookup) are close in purpose and could occasionally be confused at session start, though the descriptions differentiate them adequately.

Naming Consistency5/5

All five tools follow a consistent verb_noun snake_case pattern (get_decisions, add_decision, index_project, get_project_map, search_context). The convention is predictable and readable throughout.

Tool Count5/5

Five tools is well-scoped for a project-memory/indexing server: two for the decision journal, three for indexing and querying the project map. Each tool earns its place with no filler.

Completeness4/5

The decision journal supports append and read, which fits an append-only architectural log, but there is no update/delete or invalidation path for superseded decisions. The index side covers scan, summary, and search well; only a targeted re-index or stale-entry cleanup is missing, which agents can work around by re-running index_project.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues