An MCP server (and command-line tool) to provide a dynamic map of chat-related files from the repository with their function prototypes and related files in order of relevance. Based on the "Repo Map" functionality in Aider.chat
Add to Claude Desktop config.json
{
"mcpServers": {
"pdavis68-repomapper": {
"command": "node",
"args": [
"~/.mcp/RepoMapper/index.js"
]
}
}
} Get the source and run locally
git clone https://github.com/pdavis68/RepoMapper.git ~/.mcp/RepoMapper
cd ~/.mcp/RepoMapper RepoMap is a powerful tool designed to help, primarily LLMs, understand and navigate complex codebases. It functions both as a command-line application for on-demand analysis and as an MCP (Model Context Protocol) server, providing continuous repository mapping capabilities to other applications. By generating a “map” of the software repository, RepoMap highlights important files, code definitions, and their relationships. It leverages Tree-sitter for accurate code parsing and the PageRank algorithm to rank code elements by importance, ensuring that the most relevant information is always prioritized.
RepoMap is 100% based on Aider’s Repo map functionality, but I don’t believe it shares any code with it. Allow me to explain.
My original effort was to take the RepoMap class from Aider, remove all the aider-specific dependencies, and then make it into a command-line tool. Python isn’t my native language and I really struggled to get it to work.
So a few hours ago, I had a different idea. I took the RepoMap and some of its related code from aider and I fed it to an LLM (Either Claude or Gemini 2.5 Pro, can’t remember) and had it create specifications for this, basically, from aider’s implementation. So it generated a very detailed specification for this application (minus the MCP bits) and then I fed that to, well, Aider with Claude 3.7, and it built the command-line version of this.
I then used a combination of Aider w/Claude 3.7, Cline w/Gemini 2.5 Pro Preview & Gemini 2.5 Flash Preview, and Phind.com, and Gemini.com and Claude.com and ChatGPT.com and after a few hours, I finally got the MCP server sorted out. Again, keeping in mind, Python isn’t really my native tongue.
> python repomap.py . --chat-files repomap_class.py
Chat files: ['/mnt/programming/RepoMapper/repomap_class.py']
repomap_class.py:
(Rank value: 10.8111)
36: CACHE_VERSION = 1
39: TAGS_CACHE_DIR = os.path.join(os.getcwd(), f".repomap.tags.cache.v{CACHE_VERSION}")
40: SQLITE_ERRORS = (sqlite3.OperationalError, sqlite3.DatabaseError)
43: Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
46: class RepoMap:
49: def __init__(
93: def load_tags_cache(self):
102: def save_tags_cache(self):
459: def get_ranked_tags_map_uncached(
483: def try_tags(num_tags: int) -> Tuple[Optional[str], int]:
512: def get_repo_map(
utils.py:
(Rank value: 0.2297)
18: Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
21: def count_tokens(text: str, model_name: str = "gpt-4") -> int:
35: def read_text(filename: str, encoding: str = "utf-8", silent: bool = False) -> Optional[str]:
importance.py:
(Rank value: 0.1149)
8: IMPORTANT_FILENAMES = {
27: IMPORTANT_DIR_PATTERNS = {
34: def is_important(rel_file_path: str) -> bool:
56: def filter_important_files(file_paths: List[str]) -> List[str]:
...
...
...
pip install -r requirements.txt
# Map current directory
python repomap.py .
# Map specific directory with custom token limit
python repomap.py src/ --map-tokens 2048
# Map specific files
python repomap.py file1.py file2.py
# Specify chat files (higher priority) vs other files
python repomap.py --chat-files main.py --other-files src/
# Specify mentioned files and identifiers
python repomap.py --mentioned-files config.py --mentioned-idents "main_function"
# Enable verbose output
python repomap.py . --verbose
# Force refresh of caches
python repomap.py . --force-refresh
# Specify model for token counting
python repomap.py . --model gpt-3.5-turbo
# Set maximum context window
python repomap.py . --max-context-window 8192
# Exclude files with Page Rank 0
python repomap.py . --exclude-unranked
The tool prioritizes files in the following order:
--chat-files: These files are given the highest priority, as they’re assumed to be the files you’re currently working on.--mentioned-files: These files are given a high priority, as they’re explicitly mentioned in the current context.--other-files: These files are given the lowest priority and are used to provide additional context.# Enable verbose output
python repomap.py . --verbose
# Force refresh of caches
python repomap.py . --force-refresh
# Specify model for token counting
python repomap.py . --model gpt-3.5-turbo
# Set maximum context window
python repomap.py . --max-context-window 8192
# Exclude files with Page Rank 0
python repomap.py . --exclude-unranked
# Mention specific files or identifiers for higher priority
python repomap.py . --mentioned-files config.py --mentioned-idents "main_function"
The tool generates a structured view of your codebase showing:
tiktoken: Token counting for various LLM modelsnetworkx: Graph algorithms (PageRank)diskcache: Persistent cachinggrep-ast: Tree-sitter integration for code parsingtree-sitter: Code parsing frameworkpygments: Syntax highlighting and lexical analysisThe tool uses persistent caching to speed up subsequent runs:
.repomap.tags.cache.v1/--force-refreshCurrently supports languages with Tree-sitter grammars:
This implementation is based on the RepoMap design from the Aider project.
RepoMap can also be run as an MCP (Model Context Protocol) server, allowing other applications to access its repository mapping capabilities.
cline_mcp_settings.json):{
"mcpServers": {
"RepoMapper": {
"disabled": false,
"timeout": 60,
"type": "stdio",
"command": "/usr/bin/python3",
"args": [
"/absolute/path/to/repomap_server.py"
]
}
}
}
"/absolute/path/to/repomap_server.py" with the actual path to your repomap_server.py file.repomap_server.py script:python repomap_server.py
repo_map tool provided by the server to generate repository maps. They must specify the project_root parameter as an absolute path to the project they want to map.7/13/2025 - Removed the project.json dependency. Fixed the MCP server to be a little easier for the LLM to work with in terms of filenames.
A fully-featured coding agent that relies on symbolic code operations by using language servers.
An MCP server that indexes local code into a graph database to provide context to AI assistants with a graphical code visualizations for humans.
Coding agent with basic read, write and command line tools.
Desktop GUI automation using accessibility APIs. Control Windows, macOS, and Linux applications without vision models or screenshots. Supports workflow recording, structured data extraction, and browser DOM inspection.
A framework for creating multi-agent systems using MCP for coordinated AI collaboration, featuring task management, shared context, and RAG capabilities.
A MCP Server that allows AI such as Claude to read from the directory structure in a VS Code workspace, see problems picked up by linter(s) and the language server, read code files, and make edits.