r/npm • u/TamojitD • 14h ago
Self Promotion Built a lightweight Node.js (ESM) MCP server & CLI that maps repo import topology and git hotspots so AI coding agents stop reading 20+ files blindly

I built project-context-map-mcp (MIT, Node.js >=20, pure ESM with u/modelcontextprotocol/sdk as the only runtime dependency).
Why I built it
When using AI coding agents (Claude Code, Cursor, VS Code Copilot) on medium/large Node.js repos, they usually start by walking directories and reading 15–25 files just to trace imports and recent changes—burning tokens and context before editing anything.
I wanted a lightweight, zero-config indexer that turns a repo into a structured map (.project.md, .project-map.json, .project-map.md) so the agent queries topology first and only reads the relevant files.
How it works under the hood
- File & Module Indexing: Walks the repo (skipping
node_modules,dist,build,.git, etc.), infers modules/roles/tags, and detects stack/entrypoints (package.json, frameworks). - Import Topology Graph: Extracts ES
import/export ... from, dynamicimport(), CommonJSrequire(), and Python imports intodependenciesandusedByadjacency lists + a Mermaid diagram in.project.md. - Git Hotspot Signal: Uses
git logviaexecFileSyncto track recently modified files and commit reasons, boosting them in task-relevance ranking. - MCP Server (
StdioServerTransport): Exposes 10 tools (get_project_summary,query_topology,find_relevant_files,read_files_sparse,get_module_context,explain_file_role,get_recent_git_changes,write_and_log,refresh_project_map,read_project_context). - Safety & Testing: Enforces lexical +
realpathSyncsymlink-traversal checks onread_files_sparseandwrite_and_log, validates tool args, and tests the MCP handlers end-to-end withInMemoryTransportin Jest (--experimental-vm-modules).
Try it with npx
Run a one-off map refresh in any Node repo:
bashnpx -y project-context-map-mcp refresh --project-root .
Or add it to your MCP client config:
{
"mcpServers": {
"project-context-map": {
"command": "npx",
"args": ["-y", "project-context-map-mcp", "serve", "--project-root", "."]
}
}
}
- GitHub: https://github.com/tamojit-123/project-context-map-mcp
- npm: https://www.npmjs.com/package/project-context-map-mcp
Feedback from Node/TS folks is very welcome—especially around supporting tsconfig.json path aliases (@/...) or monorepo workspaces (pnpm-workspace.yaml / npm workspaces) in the topology resolver!