Turn a repository into structured project memory for MCP clients like Claude Code, so they can query context, inspect only relevant files, and understand topology before touching code.
AI coding tools often begin the same way in a medium or large repo:
- they read too many files
- they spend tokens on unrelated areas
- they rebuild context from scratch every time
- they miss the real dependency chain behind a feature or bug
project-context-map-mcp fixes that by generating a lightweight project memory and exposing it through MCP tools.
Instead of:
scan everything -> guess -> open random files
you get:
index first -> query topology -> read sparse files -> edit with context
This package gives you:
- an MCP server for project-aware queries
- a CLI to generate and refresh repository memory
- a readable
.project.mdwith topology highlights and change log - a machine-readable
.project-map.json - a human-readable
.project-map.md - import/dependency relationships between files
- sparse file access limited to indexed paths
- MCP-assisted writes with automatic logging
- Claude Code setup helpers and skill generation
| Part | Purpose |
|---|---|
.project.md |
Main readable project memory for humans and agents |
.project-map.json |
Structured index used by tools |
.project-map.md |
Lightweight markdown summary |
read_project_context |
Returns .project.md |
query_topology |
Finds relevant files from natural-language queries |
read_files_sparse |
Reads only indexed files |
write_and_log |
Writes changes and appends to .project.md Change Log |
Best if you want to use it across many repositories.
npm install -g project-context-map-mcpBest if you want it only inside one project.
npm install project-context-map-mcp- Node.js
20or newer - an MCP-compatible client such as Claude Code
Run this from the root of the repo you want to index:
project-context-map-mcp refresh --project-root .This creates:
.project.md.project-map.json.project-map.md
project-context-map-mcp configure-claude --project-root .This creates or updates:
.mcp.json.claude/skills/project-context-map/SKILL.md
If your client starts the server from .mcp.json, you usually do not need to run it manually.
If you want to run it yourself:
project-context-map-mcp serve --project-root .Typical flow:
- read the project context
- query topology with a natural-language task
- read only the matched files
- make changes
- refresh the map
Prompt examples:
- See PROMPTS.md for tested starter prompts for Claude Code, Cursor, and VS Code Copilot Chat.
- For best results, use prompts that name the feature area, module, or source files you want the agent to inspect.
If you want to wire the server manually, add this to your MCP config:
{
"mcpServers": {
"project-context-map": {
"command": "project-context-map-mcp",
"args": ["serve", "--project-root", "."],
"env": {}
}
}
}project-context-map-mcp print-mcp-config --project-root .project-context-map-mcp configure-claude --project-root .project-context-map-mcp serve --project-root .
project-context-map-mcp refresh --project-root .
project-context-map-mcp install-hooks --project-root .
project-context-map-mcp configure-claude --project-root .
project-context-map-mcp print-mcp-config --project-root .
project-context-map-mcp helpCommand details
| Command | What it does |
|---|---|
serve |
Starts the MCP server over stdio |
refresh |
Regenerates .project.md, .project-map.json, and .project-map.md |
install-hooks |
Installs git hooks to keep the map refreshed |
configure-claude |
Creates repo-local Claude Code skill and .mcp.json |
print-mcp-config |
Prints the MCP config JSON without writing files |
help |
Shows command help |
These are the main tools exposed by the server.
| Tool | Purpose |
|---|---|
read_project_context |
Returns .project.md content |
query_topology |
Takes a natural-language query and returns matched file paths from the query index |
read_files_sparse |
Reads file content only for indexed paths |
write_and_log |
Writes file changes and appends an entry to .project.md Change Log |
| Tool | Purpose |
|---|---|
get_project_summary |
Returns summary, stack, modules, hotspots |
refresh_project_map |
Regenerates the project memory artifacts |
get_module_context |
Returns a focused view of one module |
find_relevant_files |
Legacy ranking-oriented file query |
get_recent_git_changes |
Summarizes recent git activity |
explain_file_role |
Explains a file’s role and recent changes |
What each core tool returns
Returns:
.project.mdpath- full markdown content
Returns:
- matched file paths
- confidence score
- match reasons
- per-file dependencies
- per-file
usedByrelationships
Returns:
- file content for indexed files
- safe errors for files outside the repo or outside the known topology
Returns:
- path written
- bytes written
- appended change log entry
flowchart LR
A[Refresh project map] --> B[Read .project.md]
B --> C[Query topology]
C --> D[Read sparse files]
D --> E[Implement change]
E --> F[Write and log]
F --> G[Refresh project map]
User asks:
Fix the login bug where session expires after refresh
Recommended agent behavior:
- call
read_project_context - call
query_topologywith the task - call
read_files_sparsewith the matched file paths - inspect only those files first
- edit code
- call
write_and_logif using MCP-managed writes - call
refresh_project_map
The project map is not only a file list. It also extracts internal relationships such as:
- JavaScript and TypeScript imports
- CommonJS
require(...)usage - basic Python import detection
- reverse usage information with
used_by
That data is written into:
.project-map.json.project.md
.project.md includes a Mermaid graph so markdown viewers that support Mermaid can render a visual dependency map.
The main working document. It includes:
- project summary
- key modules
- query index preview
- topology highlights
- Mermaid dependency graph
- running change log
The structured source of truth. It includes fields such as:
project_summarytech_stackmodulesfilestopologyentrypointsdependenciesrecent_changeshotspots
A shorter human-readable summary.
After running:
project-context-map-mcp configure-claude --project-root .your repo will contain:
.mcp.json
.claude/skills/project-context-map/SKILL.md
The generated skill tells Claude Code to:
- consult project memory first
- avoid broad repo scans
- query relevant files before opening source
- refresh the project map after edits
If you want the map to stay fresh automatically:
project-context-map-mcp install-hooks --project-root .This installs:
post-commitpost-mergepost-push
Each hook refreshes the project memory after repository activity.
I just installed it. What should I do next?
- Go to your repo root.
- Run
project-context-map-mcp refresh --project-root . - Run
project-context-map-mcp configure-claude --project-root . - Open the repo in Claude Code.
- Approve the MCP server from
.mcp.json. - Ask the agent to use
read_project_contextandquery_topologyfirst.
I want to use my own MCP config instead of the generated one
Use:
project-context-map-mcp print-mcp-config --project-root .Then copy the JSON into your own MCP config file and adjust:
- server name
- command path
- working project root
I only want the package inside one repo
Install locally:
npm install project-context-map-mcpThen run through npx:
npx project-context-map-mcp refresh --project-root .
npx project-context-map-mcp configure-claude --project-root .How do I know it is working?
You should see:
.project.md.project-map.json.project-map.md.mcp.jsonafter Claude setup
You can also run:
project-context-map-mcp help
project-context-map-mcp refresh --project-root .Tested prompt templates now live in PROMPTS.md.
Quick examples:
Use the project context map first, then find the files involved in session refresh logic.Use query_topology to locate the files related to npm publishing, package configuration, and release safety checks.Use get_module_context for src and explain how the CLI and MCP server fit together.Find the files that control authentication and prefer source files over docs.
- Node.js applications
- React apps
- Next.js projects
- mixed frontend/backend repos
- Python services
- large internal tools where AI agents are used often
npm install
npm run check
node src/cli.js refresh --project-root .
node src/cli.js serve --project-root .- topology detection is strongest for JS, TS, and simple Python import patterns
- visual graph output is Mermaid markdown, not a full interactive web app
- natural-language ranking quality depends on file names, summaries, tags, and recent changes
MIT