Repo Therapist
Repo Therapist 🛋️
让你的代码库在压力下自我解释
此 MCP 服务器完全使用 Cursor 构建
Repo Therapist 是一个 MCP(模型上下文协议)服务器,可将任何代码仓库转化为可查询、可解释的知识库。通过 Cursor 询问有关代码库的问题,并获得结构化、深刻的答案。
它能做什么
你可以向 Cursor 询问诸如:
“为什么这个服务要这样构建?”
“如果我删除了这个,会破坏什么?”
“这个仓库的哪些部分让你感到担忧?”
在后台,Repo Therapist 会:
读取你的仓库结构和文件
分析 git 历史和提交模式
将代码与变更频率相关联
识别复杂性热点和风险
Related MCP server: Code Understanding MCP Server
可用工具
工具 | 描述 |
| 分析仓库 - 请先运行此项 |
| 获取仓库的静态快照(事实依据) |
| 获取 git 历史分析(时间维度) |
| 解释特定文件为何如此 |
| 询问有关已分析仓库的任何问题 |
| 获取高层级概述 |
| 生成风险评估报告 |
事实依据:快照
当你运行 analyze_repo 时,Repo Therapist 会创建一个静态快照 - 这是关于你仓库的权威事实来源。此快照包括:
{
"files": [...], // Every file with path, language, line count
"languages": {...}, // Language breakdown with percentages
"entryPoints": [...], // Detected entry points with confidence levels
"configs": {...}, // Parsed package.json, tsconfig, Dockerfile, CI configs
"directories": [...] // Directory structure with inferred purposes
}为什么这很重要: 大语言模型(LLM)必须引用此快照数据,而不是进行猜测。当你问“这个仓库使用什么语言?”时,答案来自快照,而不是 LLM 的假设。
使用 get_snapshot 获取特定部分:
get_snapshot(section: "files")- 带有元数据的所有文件get_snapshot(section: "languages")- 语言统计信息get_snapshot(section: "entryPoints")- 检测到的入口点get_snapshot(section: "configs")- 解析后的配置文件get_snapshot(section: "directories")- 目录结构get_snapshot()- 所有内容的摘要
Git 历史学家:时间维度
Git 历史学家分析提交历史,以解释代码为什么是现在这个样子。这就是它变得强大的地方。
{
"fileChurn": { "auth.ts": { "totalCommits": 47, "churnScore": 85 } },
"authors": { "auth.ts": ["alice", "bob", "charlie"] },
"fragileFiles": [{ "path": "auth.ts", "reasons": ["high-churn", "many-authors"] }],
"hotPaths": [...],
"stableCore": [...]
}这让你能够回答:
“为什么这很奇怪?” → “因为它在 6 个月内被重写了 12 次。”
“谁拥有这个文件?” → “有争议 - 4 个人修改过它,没有人的修改占比超过 30%。”
“我应该小心什么?” → “这 5 个文件很脆弱且容易出错。”
使用 get_history 获取特定方面:
get_history(section: "churn")- 文件变更频率和波动性get_history(section: "authors")- 贡献者统计信息get_history(section: "fragile")- 可能导致问题的文件get_history(section: "hotPaths")- 热点路径与稳定核心get_history(section: "timeline")- 关键事件和提交模式get_history(section: "ownership")- 谁拥有什么get_history()- 所有内容的摘要
使用 why_is_this_weird 进行特定文件分析:
Use why_is_this_weird on "src/auth/login.ts"返回带有引用的详细解释:
# Why is "src/auth/login.ts" the way it is?
## Change History
- Total commits: 47
- Authors: 5 (alice, bob, charlie, dave, eve)
- Churn score: 85 ⚠️ HIGH
## 🔍 Why It's Unusual
**Heavily modified:** This file has been changed 47 times...
**Many hands:** 5 different people have modified this file...设置
1. 安装依赖
cd repo-therapist
npm install2. 构建项目
npm run build3. 添加到 Cursor
打开 Cursor 设置 → MCP → 添加新的 MCP 服务器:
{
"mcpServers": {
"repo-therapist": {
"command": "node",
"args": ["/FULL/PATH/TO/repo-therapist/dist/index.js"]
}
}
}重要: 将 /FULL/PATH/TO/ 替换为你 repo-therapist 文件夹的实际绝对路径。
示例:
{
"mcpServers": {
"repo-therapist": {
"command": "node",
"args": ["/Users/saar/Projects/private/repo-therapist/dist/index.js"]
}
}
}4. 重启 Cursor
添加 MCP 配置后,重启 Cursor 以使更改生效。
常见问题
我需要单独运行 repo-therapist 吗?
不需要。 Cursor 会自动为你启动并管理 MCP 服务器。当你将配置添加到 Cursor 的 MCP 设置中时,Cursor 将:
在需要时启动
node dist/index.js进程使其在后台运行
通过 stdio(标准输入/输出)与它通信
你只需要构建一次 (npm run build),添加配置,然后重启 Cursor。就是这样。
我在哪里提问?
在正常的 Cursor 聊天中 (Cmd+L 或聊天面板)。区别在于你如何提问:
没有 MCP: “这个仓库是做什么的?” → Cursor 使用其内置工具
使用 Repo Therapist: “在
/path/to/repo上使用analyze_repo” → Cursor 调用 MCP 工具
你明确告诉 Cursor 使用 repo-therapist 工具。Cursor 将它们视为它可以使用的额外功能。
它与普通 Cursor 聊天有什么区别?
普通 Cursor 聊天 | 使用 Repo Therapist |
按需读取文件 | 预先分析整个仓库结构 |
没有 git 历史意识 | 分析提交模式和变更频率 |
基于读取的内容回答 | 基于结构化分析回答 |
没有风险检测 | 识别复杂性热点 |
通用的代码理解 | 领域特定的见解(“什么让你感到担忧?”) |
关键区别: Repo Therapist 会预先进行结构化分析并将其存储起来,因此像“哪些文件变更最频繁?”或“有哪些风险?”这样的问题可以从预先计算的数据中得到回答,而不是让 Cursor 每次都去计算。
可以这样理解:Cursor 很聪明但很被动。Repo Therapist 为它提供了一份关于你代码库的“简报文档”,它可以参考这份文档。
使用方法
配置完成后,你可以在 Cursor 聊天中使用 Repo Therapist:
第 1 步:分析仓库
首先,分析你想要探索的仓库:
Use analyze_repo to analyze /path/to/some/repo第 2 步:提问
现在你可以提问了:
Use ask_repo to answer: "What does this repo do?"Use ask_repo to answer: "Which parts of this repo scare you?"Use ask_repo to answer: "What will break if I remove the auth module?"第 3 步:获取报告
获取摘要:
Use repo_summary to show me an overview获取风险评估:
Use risk_report to identify potential issues示例问题
“这个仓库是做什么的?”
“代码是如何构建的?”
“使用了什么技术栈?”
“向我展示依赖项”
“哪些文件最大?”
“哪些文件变更最频繁?”
“贡献者是谁?”
“最近的提交是什么?”
“哪些部分让你感到担忧?”
“如果我更改 X,会破坏什么?”
开发
在开发模式下运行
npm run dev构建生产版本
npm run build运行测试
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage report测试指南
注意: 实现新功能时请务必添加单元测试。
测试位于 tests/ 中并使用 Vitest。测试结构与源代码镜像:
tests/
├── fixtures/ # Test utilities and mock repos
│ └── setup.ts # Helper functions for creating test repos
├── scanner/ # Scanner module tests
├── historian/ # Historian module tests
├── tools/ # Tool tests
└── cache.test.ts # Cache tests添加新功能时:
在相应的
tests/子目录中创建测试对于 git 相关测试,使用
fixtures/setup.ts中的createTestRepo()在
afterAll中使用cleanupTestRepo()清理测试仓库在提交前运行
npm test以验证所有测试通过
项目结构
repo-therapist/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── cache.ts # In-memory repo cache
│ ├── types.ts # TypeScript interfaces
│ ├── scanner/ # Static snapshot engine (Step 2)
│ │ ├── index.ts # Scanner exports
│ │ ├── types.ts # Snapshot type definitions
│ │ └── scan-repo.ts # Repository scanner
│ ├── historian/ # Git history analyzer (Step 3)
│ │ ├── index.ts # Historian exports
│ │ ├── types.ts # History type definitions
│ │ └── analyze-history.ts # Git history analysis
│ └── tools/
│ ├── analyze-repo.ts # Repository analyzer (orchestrates all)
│ ├── get-snapshot.ts # Snapshot retrieval (ground truth)
│ ├── get-history.ts # History retrieval (time dimension)
│ ├── ask-repo.ts # Question answering
│ ├── repo-summary.ts # Summary generator
│ └── risk-report.ts # Risk assessment
├── tests/ # Unit tests
│ ├── fixtures/ # Test utilities
│ ├── scanner/ # Scanner tests
│ ├── historian/ # Historian tests
│ └── tools/ # Tool tests
├── package.json
├── tsconfig.json
├── vitest.config.ts # Test configuration
└── README.md技术栈
TypeScript - 类型安全的代码库
@modelcontextprotocol/sdk - MCP 服务器实现
simple-git - Git 历史分析
ts-morph - TypeScript/JavaScript AST 解析(计划中)
glob - 文件模式匹配
路线图
[ ] 基于 AST 的代码分析 (ts-morph)
[ ] 将分析结果持久化到 JSON/SQLite
[ ] 依赖关系图可视化
[ ] 安全漏洞检测
[ ] 测试覆盖率分析
[ ] 自定义问题处理器
许可证
MIT
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseNot gradedqualityFmaintenanceAn MCP server that transforms codebases into intelligent, queryable knowledge bases, enabling AI assistants to perform semantic search, explore architecture, and analyze code relationships.166
- AlicenseCqualityDmaintenanceAn MCP server that analyzes local or remote GitHub repositories, providing intelligent code context and structure to AI coding assistants.1013MIT
- AlicenseAqualityCmaintenanceAn MCP server that extracts complete knowledge from any codebase — architecture, patterns, dependencies, API surface. Combines static analysis with AI-powered deep interpretation.8MIT
- AlicenseNot gradedqualityCmaintenanceA production-grade MCP server for local git repositories that provides tools for code search, git history analysis, complexity metrics, test discovery, and dependency management.MIT
Related MCP Connectors
A MCP server built for developers enabling Git based project management with project and personal…
An MCP server that gives your AI access to the source code and docs of all public github repos
Scan any public GitHub MCP-server repo for security issues. 37 MCP-specific L1 rules, 8 languages.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/salman-arefin74/repo-therapist'
If you have feedback or need assistance with the MCP directory API, please join our Discord server