About Code Line Counter MCP
Code Line Counter MCP is an MCP server in the AI category: 这是一个MCP(Model Context Protocol)工具,用于统计AI生成的代码行数。该工具可以帮助您跟踪和分析每次AI生成的代码的规模。.
Install
git clone https://github.com/fashionzzZ/code-line-counter-mcpThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Code Line Counter MCP
Powered by Claude · Grounded in docs
Security checks
- ✓README presentThe repository ships documentation.
5 checks have not been run yet.
README
Code Line Counter MCP Tool
这是一个MCP(Model Context Protocol)工具,用于统计AI生成的代码行数。该工具可以帮助您跟踪和分析每次AI生成的代码的规模。
功能
- count_code_lines: 统计给定代码的行数信息,包括总行数、代码行数、注释行数和空行数
- get_statistics: 获取代码行数的统计信息,支持按时间范围筛选
安装
npm install
使用
npm start
集成到MCP客户端
要将此工具集成到MCP客户端中,您需要执行以下步骤:
1. 启动MCP服务器
首先,确保MCP服务器正在运行:
npm start
服务器将监听标准输入/输出,等待MCP客户端的连接。
2. 在MCP客户端中配置工具
在您的MCP客户端配置中,添加对此工具服务器的引用。具体的配置方式取决于您使用的MCP客户端实现。
对于基于JSON的配置,通常需要添加类似以下的配置:
{
"tools": [
{
"name": "code-line-counter",
"type": "process",
"command": "node",
"args": ["src/index.js"],
"cwd": "/path/to/code-line-counter-mcp"
}
]
}
3. 使用工具
一旦集成完成,您可以在AI助手会话中使用以下工具:
- count_code_lines - 当AI生成代码时,自动调用此工具统计代码行数
- get_statistics - 查询历史统计信息
客户端会自动处理工具的调用和结果返回。
工具说明
count_code_lines
统计代码行数的工具。
参数:
fileType(string, 必需): 代码文件类型,例如:javascript, python, java等code(string, 必需): 需要统计的代码内容
返回:
- 代码行数统计结果,包括总行数、代码行数、注释行数和空行数
get_statistics
获取代码行数统计信息。
参数:
startTime(string, 可选): 开始时间,ISO格式 (例如: "2023-01-01T00:00:00Z")endTime(string, 可选): 结束时间,ISO格式 (例如: "2023-12-31T23:59:59Z")
返回:
- 代码行数统计信息,包括总文件数、总行数、总代码行数、总注释行数、总空行数,以及按文件类型的分组统计
数据持久化
工具会自动将统计结果保存到 data/code_line_data.json 文件中,确保重启后数据不会丢失。
支持的文件类型
目前支持以下文件类型的注释识别:
- JavaScript
- Python
- Java
- C++
- C
- Go
- Rust
- Swift
- Kotlin
- TypeScript
对于不支持的文件类型,仍将统计总行数、空行数,但注释行数将为0。
示例
调用 count_code_lines 工具:
{
"fileType": "javascript",
"code": "function hello() {\n // 这是一个注释\n console.log('Hello World');\n\n return true;\n}"
}
调用 get_statistics 工具:
{
"startTime": "2023-01-01T00:00:00Z",
"endTime": "2023-12-31T23:59:59Z"
}
README copy captured when this server was indexed; it may lag the repository. The original is authoritative.