上下文全部
简体中文 |英语
A. 模型上下文协议(MCP) 扫描和管理代码库中TODO/FIXME/HAK/XXX注释的服务器。
它的作用
Context Todos可帮助您在整个项目中跟踪和管理代码注释。它扫描源文件以查找常见的注释标签,并提供工具通过MCP协议查询、监视和分析它们。
特性
- 扫描文件:从单个文件中提取TODO注释
- 扫描目录:递归扫描目录中所有支持的文件
- 列表扩展:查看所有支持的文件扩展名
- 观看模式:实时监控文件更改(最大/实验室模式)
- TODO数据库:所有TODO项目的持久存储(最大/实验室模式)
- 统计:按标签和文件获取TODO统计信息(实验室模式)
支持的TODO标签
| 标签 | 用法 |
|---|---|
TODO | 需完成的一般任务 |
FIXME | 需要修复的代码 |
HACK | 临时解决方法 |
XXX | 警告或有问题的代码 |
TODO评论大会
我们建议对TODO注释使用结构化格式,以提高可读性并实现更好的分类:
TODO: Brief description
TODO(category): Brief description with category这 (category) 部分是 可选的 但是 推荐 为了更好的组织。这两种格式都有效,将被检测到。
推荐分类
| 类别 | 目的 |
|---|---|
bug | 需要修复的Bug |
performance | 性能改进 |
security | 安全相关问题 |
ux | 用户体验改善 |
refactor | 代码重构需求 |
docs | 文档更新 |
test | 缺失或改进的测试 |
feat | 要实现的新功能 |
build | 构建/CI相关问题 |
按语言举例
JavaScript/Types/Node.js
// Simple format
// TODO: Add error handling for network timeouts
// With category
/*
* TODO(performance): Replace synchronous readdirSync with async fs.promises.readdir
* to avoid blocking the event loop when scanning large projects.
* See: https://nodejs.org/api/fs.html#fs_fspromises_readdir_path_options
*/python
# Simple format
# TODO: Add type hints to this function
# With category
# TODO(security): Sanitize user input before database query
# Consider using parameterized queries instead of string formatting.锈
// Simple format
// TODO: Implement Clone trait for this struct
// With category
/*
* TODO(security): Add input validation to prevent buffer overflow
* attacks in the packet parser.
*/Java
// Simple format
// TODO: Extract magic numbers to constants
// With category
/*
* TODO(performance): Cache the computed results to avoid
* recalculating on every request.
* Consider using Caffeine or Guava cache.
*/C
// Simple format
// TODO: Add unit tests for edge cases
// With category
/*
* TODO(performance): Replace raw pointers with smart pointers
* to prevent memory leaks and improve ownership semantics.
*/支持的文件扩展名
| 类别 | 扩展 |
|---|---|
| JavaScript/TypeScript | .ts, .tsx, .js, .jsx, .mjs, .cjs |
python .py | |
| 红宝石 | .rb |
Java .java | |
| 去吧 | .go |
| 生锈 | .rs |
| C/C++ | .c, .cpp, .h, .hpp |
C .cs | |
| PHP | .php |
| Swift | .swift |
| Kotlin/Scala | .kt, .scala |
| 壳牌 | .sh, .bash |
| 前端 | .css, .scss, .less, .html, .vue, .svelte |
| 配置 | .yaml, .yml, .toml, .ini, .cfg |
| 数据库 | .sql, .lua |
| 其他 | .r, .m, .mm, .pl, .pm, .ex, .exs, .erl, .hs, .elm, .clj, .cljs, .tf, .hcl, .dockerfile |
如何使用
快速入门(npx)
# Run directly with npx (Stable Standard)
npx @eeymoo/context-todos mcp
# Stable Max (with watching)
npx @eeymoo/context-todos mcp --max
# Labs Standard
npx @eeymoo/context-todos mcp --labs
# Labs Max (all features including experimental)
npx @eeymoo/context-todos mcp --labs --max安装
# Install globally
npm install -g @eeymoo/context-todos
# Or with pnpm
pnpm add -g @eeymoo/context-todos
# Then run
context-todos mcp配置MCP客户端
添加到您的MCP客户端配置中(例如,Claude Desktop、Cursor等):
{
"mcpServers": {
"context-todos": {
"command": "npx",
"args": ["-y", "@eeymoo/context-todos", "mcp"]
}
}
}或者使用最大/实验室模式:
{
"mcpServers": {
"context-todos": {
"command": "npx",
"args": ["-y", "@eeymoo/context-todos", "mcp", "--max"]
}
}
}发展
# Clone the repository
git clone https://github.com/eeymoo/context-todos.git
cd context-todos
# Install dependencies
pnpm install
# Build
pnpm build
# Run in development
pnpm dev服务器模式
该产品有两类功能:
- 稳定:具有生产就绪功能
Standard和Max变体 - 实验室:实验功能,也有
Standard和Max变体
| 类别 | 模式 | 命令行界面 | 描述 | 工具 |
|---|---|---|---|---|
| 稳定 | 标准 | (默认) | 基本扫描工具 | scan-file, scan-directory, list-supported-extensions |
| 稳定 | 最大 | --max | 标准+文件监视和数据库 | 全部标准+ watch, unwatch, list-todos |
| 实验室 | 标准 | --labs | 实验标准模式 | 与稳定标准相同 |
| 实验室 | Max | --labs --max | 所有功能,包括实验 | 全部最大+ get-todo-stats |
# Stable Standard (default)
npx @eeymoo/context-todos mcp
# Stable Max (with watching)
npx @eeymoo/context-todos mcp --max
# Labs Standard
npx @eeymoo/context-todos mcp --labs
# Labs Max (all features)
npx @eeymoo/context-todos mcp --labs --max输出格式
使用 --format 更改输出格式的选项:
# Default format (toon) - compact single-line format
npx @eeymoo/context-todos mcp --format toon
# JSON format - structured JSON output
npx @eeymoo/context-todos mcp --format json
# Pretty format - human-readable with indentation
npx @eeymoo/context-todos mcp --format pretty| 格式 | 描述 |
|---|---|
toon | 压缩单行格式(默认) |
json | 用于编程的完整JSON结构 |
pretty | 带缩进的多行格式 |
文件筛选
使用 --filter 要排除与特定模式匹配的文件:
# Exclude test files
npx @eeymoo/context-todos mcp --filter "*.test.ts,*.spec.ts"
# Exclude test directories and config files
npx @eeymoo/context-todos mcp --filter "__tests__/**,*.config.ts"
# Combine with gitignore (enabled by default)
npx @eeymoo/context-todos mcp --use-gitignore --filter "*.test.ts"| 选项 | 描述 |
|---|---|
| `--filter | |
| ` | 要排除的逗号分隔的glob模式 |
--use-gitignore | 使用.gitignore过滤文件(默认值:true) |
| `--gitignore-path | |
| ` | 自定义gitignore文件路径 |
MCP工具
scan-file
扫描单个文件以查找TODO注释。
{
"name": "scan-file",
"arguments": {
"path": "/path/to/file.ts"
}
}scan-directory
递归扫描目录中的TODO注释。
{
"name": "scan-directory",
"arguments": {
"path": "/path/to/project",
"extensions": [".ts", ".js"]
}
}list-supported-extensions
列出所有支持的文件扩展名。
{
"name": "list-supported-extensions",
"arguments": {}
}watch (最大值/实验室--最大值)
开始查看目录中的文件更改。
{
"name": "watch",
"arguments": {
"path": "/path/to/project",
"extensions": [".ts", ".js"]
}
}unwatch (最大值/实验室--最大值)
别看了。
{
"name": "unwatch",
"arguments": {}
}list-todos (最大值/实验室--最大值)
列出数据库中所有跟踪的TODO。
{
"name": "list-todos",
"arguments": {
"tag": "TODO",
"file": "src/index.ts"
}
}get-todo-stats (仅限实验室)
获取按标签和文件分组的TODO统计信息。
{
"name": "get-todo-stats",
"arguments": {}
}脚本
pnpm dev # Run in development mode
pnpm build # Build for production
pnpm test # Run tests
pnpm test:watch # Run tests with watch mode
pnpm inspector # Run with MCP inspector (for debugging)需求
- Node.js>=18.0.0
- pnpm(推荐)
许可证
ISC
