Repository avatar
Version Control
v0.1.11
active

project-context-map-mcp

io.github.tamojit-123/project-context-map-mcp

Index repo import topology and git hotspots into project memory for low-token MCP coding.

Documentation

Project Context Map MCP

Give your coding agent a map before it starts wandering

Turn any repository into structured project memory for Claude Code, Cursor, VS Code, and other MCP clients—so agents query dependency topology and git hotspots first, then read only the files that matter.

npm version Node 20+ CI Checks License: MIT

Glama MCP score

Project Context Map MCP server on MCPRush Project Context Map MCP server on Glama

Quick Start · Why This Exists · MCP Tools · CLI · Prompts · Contributing


Project Context Map MCP Demo

Why This Exists

AI coding tools often start every session in a medium or large repository by walking directories and opening 15–30 unrelated files—spending tokens before they even understand how modules connect.

project-context-map-mcp flips the workflow from scan everything -> guess -> open random files to:

index first -> query topology -> read sparse files -> edit with context

Without Project Context MapWith Project Context Map
Scans directories & opens 15–30 unrelated filesCalls get_project_summary + query_topology first
Re-discovers architecture every new sessionReads .project.md & .project-map.json immediately
Misses downstream callers and import chainsInspects dependencies and usedBy edges before editing
High prompt token usage on large codebasesCalls read_files_sparse on only 2–5 matched files

Quick Start

Requirements: Node.js 20+ and an MCP-compatible client (Claude Code, Cursor, Claude Desktop, VS Code).

1. Add to your MCP client (Zero-install via npx)

Add this to .mcp.json (or your client's MCP settings) — no global install or API key required:

{
  "mcpServers": {
    "project-context-map": {
      "command": "npx",
      "args": ["-y", "project-context-map-mcp", "serve", "--project-root", "."]
    }
  }
}

2. Generate project memory & Claude Code skill (Optional)

# Index the repo into .project.md, .project-map.json, and .project-map.md
npx -y project-context-map-mcp refresh --project-root .

# Write .mcp.json + .claude/skills/project-context-map/SKILL.md
npx -y project-context-map-mcp configure-claude --project-root .
Alternative installation options (Global / Local / Manual Config)

Global install

npm install -g project-context-map-mcp

Local project install

npm install project-context-map-mcp

Print MCP config JSON without writing files

npx -y project-context-map-mcp print-mcp-config --project-root .

How It Works

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]

Generated Artifacts

FilePurpose
.project.mdMain human & agent project memory: summary, key modules, query index, topology highlights, Mermaid dependency graph, and ## Change Log
.project-map.jsonMachine-readable index (project_summary, tech_stack, modules, files, topology, entrypoints, dependencies, recent_changes, hotspots)
.project-map.mdLightweight markdown summary of modules, entrypoints, recent commits, and hotspots

Topology & Git Hotspots

  • Import & dependency graph: Extracts ES import/export ... from, dynamic import(), CommonJS require(...), and Python imports into dependencies and reverse usedBy edges.
  • Git history & hotspots: Reads recent commits via git log to surface frequently changed files and boost them when ranking tasks.
  • Auto-refresh git hooks: Keep the map current automatically with:
    npx -y project-context-map-mcp install-hooks --project-root .
    
    Installs post-commit, post-merge, and post-push hooks (worktree-safe).

MCP Tools

Core Workflow Tools

ToolPurpose
read_project_contextReturns .project.md content for the repository
query_topologyMatches a natural-language query against the index and returns paths + dependencies / usedBy topology
read_files_sparseReads file content only for indexed, in-root paths (rejects outside/symlink escapes)
write_and_logWrites in-root file changes and appends an entry to .project.md's Change Log

Additional Discovery & Maintenance Tools

ToolPurpose
get_project_summaryReturns project summary, tech stack, entrypoints, top modules, and hotspots
refresh_project_mapRegenerates .project-map.json, .project-map.md, and .project.md
get_module_contextReturns files, recent commits, and likely impact area for a module
find_relevant_filesRanks relevant files for a task with confidence score and avoidReading modules
get_recent_git_changesSummarizes git commits and file hotspots over the last N days (default 5)
explain_file_roleExplains a file's inferred role, module, and recent commits
Detailed return payloads for core tools
  • read_project_context → { path, content }
  • query_topology → { query, matchedPaths, confidence, matches, topology: [{ path, module, dependencies, usedBy }] }
  • read_files_sparse → { files: [{ path, content } | { path, error }] }
  • write_and_log → { path, bytesWritten, log: { path, entry } }

CLI Commands

CommandDescription
project-context-map-mcp serve --project-root .Starts the MCP server over stdio
project-context-map-mcp refresh --project-root .Regenerates .project.md, .project-map.json, and .project-map.md
project-context-map-mcp install-hooks --project-root .Installs post-commit, post-merge, and post-push git hooks
project-context-map-mcp configure-claude --project-root .Writes .mcp.json and .claude/skills/project-context-map/SKILL.md
project-context-map-mcp print-mcp-config --project-root .Prints the MCP config JSON without modifying files
project-context-map-mcp helpDisplays CLI usage

Example Prompts & Best Fit

Tested starter prompts for Claude Code, Cursor, and VS Code Copilot Chat 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."

Works best on: Node.js applications, React / Next.js projects, mixed frontend/backend repos, Python services, and active internal tools where coding agents are used daily.


Limitations

  • Topology extraction focuses on JS, TS, CommonJS, and basic Python import patterns.
  • Visual graph output is Mermaid markdown (.project.md), not a standalone web UI.
  • Natural-language ranking depends on file paths, inferred tags/roles, summaries, and recent git activity.

Development & Contributing

git clone https://github.com/tamojit-123/project-context-map-mcp.git
cd project-context-map-mcp
npm ci
npm run check

See CONTRIBUTING.md for pull request guidelines.

License

MIT

NPM
project-context-map-mcp
Install Command
npm install project-context-map-mcp