code-line-counter-mcp
这是一个MCP(Model Context Protocol)工具,用于统计AI生成的代码行数。该工具可以帮助您跟踪和分析每次AI生成的代码的规模。
Documentation
Code Line Counter MCP Tool
这是一个MCP(Model Context Protocol)工具,用于统计AI生成的代码行数。该工具可以帮助您跟踪和分析每次AI生成的代码的规模。
功能
1. count_code_lines: 统计给定代码的行数信息,包括总行数、代码行数、注释行数和空行数
2. 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助手会话中使用以下工具:
1. count_code_lines - 当AI生成代码时,自动调用此工具统计代码行数
2. 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"
}Frequently asked questions
What is code-line-counter-mcp?
code-line-counter-mcp is 这是一个MCP(Model Context Protocol)工具,用于统计AI生成的代码行数。该工具可以帮助您跟踪和分析每次AI生成的代码的规模。
How do I install code-line-counter-mcp?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is code-line-counter-mcp open source?
Yes — it is hosted on GitHub at https://github.com/fashionzzz/code-line-counter-mcp and has 1 stars.
Related MCP tools
🔥 Official Firecrawl MCP Server - Adds powerful web scraping and search to Cursor, Claude and any other LLM clients. JavaScript-based implementation.
A model context protocol server to work with JetBrains IDEs: IntelliJ, PyCharm, WebStorm, etc. Also, works with Android Studio
A server that integrates Linear's project management system with the Model Context Protocol (MCP) to allow LLMs to interact with Linear.
The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.
CTTF: MCP integration between Cursor and Figma, allowing Cursor Agentic AI to communicate with Figma for reading designs and modifying them programmatically.
This is MCP server for Claude that gives it terminal control, file system search and diff file editing capabilities JavaScript-based implementation.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP