lintpulse-mcp
v1.1.0
Published
MCP-based AI code generation guard service with syntax validation, duplicate detection, and multi-agent coordination
Maintainers
Readme
LintPulseMCP
基于 MCP 协议的 AI 代码生成防护工具 — 语法校验、重复检测、多 Agent 协调。
功能特性
- 语法校验 — 单次遍历状态机,检测括号/引号匹配、多行字符串、未闭合符号,支持 7 种语言
- 重复检测 — 项目级符号提取(名称+类型去重)、Levenshtein 相似度(长名截断优化)、10K 文件扫描上限
- 多 Agent 协调 — 符号所有权声明、冲突检测、
complete_agent完成标记、互斥锁 + 状态持久化 - 模式检测 — 检测
as any、console.log、TODO、unwrap()等反模式 - 行尾管理 — LF/CRLF 检测、转换、项目级规范化(自动跳过二进制文件)
- MCP Resources — 暴露项目状态、符号表、Agent 列表为可订阅资源
- 并发安全 — Promise-chain 互斥锁、全局写队列(失败自动恢复)、跨实例状态同步
快速开始
环境要求
- Node.js >= 18.0.0
- npm >= 9.0.0
安装
npm install -g lintpulse-mcp配置 MCP
在编辑器 MCP 配置中添加(以 Codex CLI 为例,.codex/mcp.json):
{
"mcpServers": {
"code-guard": {
"command": "npx",
"args": ["lintpulse-mcp"]
}
}
}MCP 工具列表
| 工具名 | 功能 | 优先级 |
|--------|------|--------|
| validate_syntax | 检查括号/引号匹配 | P0 |
| check_duplicates | 检查符号是否重复 | P0 |
| scan_project_symbols | 扫描项目所有符号 | P0 |
| analyze_code | 语法 + 模式 + 重复综合分析 | P0 |
| detect_line_endings | 检测行尾类型(LF/CRLF/mixed) | P0 |
| convert_line_endings | 转换单文件行尾格式 | P0 |
| normalize_line_endings | 批量规范化项目行尾 | P0 |
| register_agent | 注册 Agent 实例 | P1 |
| claim_symbol | 声明符号所有权 | P1 |
| release_symbol | 释放符号所有权 | P1 |
| check_before_write | 写入前冲突检查 | P1 |
| get_project_state | 获取项目状态 | P1 |
| cleanup_agent | 清理 Agent 资源 | P1 |
| complete_agent | 标记 Agent 完成,符号转为已实现 | P1 |
| batch_validate | 批量验证多个文件语法 | P1 |
| smart_check | 智能选择检查项 | P2 |
| quick_analyze | 快速分析返回简化结果 | P2 |
MCP Resources
| URI | 名称 | 描述 |
|-----|------|------|
| lintpulse://project/{path}/state | 项目状态 | Agent 数量、符号数量、活跃 Agent 概览 |
| lintpulse://project/{path}/symbols | 符号表 | 项目完整符号列表及位置 |
| lintpulse://project/{path}/agents | Agent 列表 | 所有 Agent 的任务、状态、声明符号 |
支持语言: TypeScript, JavaScript, Python, Rust, Go, Java, C++, C#, Ruby, PHP, Swift, Kotlin
关键词过滤: 每种语言内置 40~60 个关键字黑名单,避免 Java/C++ 函数模式将 if、for、return 等误识别为函数名。扫描时自动跳过 dist/build/target/__pycache__/.git 等构建目录。
项目结构
src/
├── index.ts # 入口文件
├── server.ts # MCP Server(11 个工具 + Zod 校验 + LRU 缓存)
├── types.ts # 类型定义 + 符号提取正则
├── validators/
│ ├── syntax.ts # 语法校验器(栈 + 状态机 + O(log n) 行列定位)
│ ├── duplicate.ts # 重复检测器(符号提取 + Levenshtein + 项目扫描)
│ └── patterns.ts # 模式检测器(as any / console.log / TODO 等)
├── coordination/
│ ├── agent-manager.ts # Agent 管理(互斥锁 + 状态缓存刷新)
│ └── state-store.ts # JSON 状态持久化(原子写入 + 备份轮转 + 全局写队列)
└── utils/
├── errors.ts # CodeGuardError 错误类
├── logger.ts # 分级日志(debug/info/warn/error)
└── code-position.ts # 行列计算工具(预计算 + 二分查找)
tests/
├── unit/ # 单元测试(8 个文件)
├── integration/ # MCP 集成测试
└── stress/ # 高并发压力测试
开发
git clone https://github.com/DarkInno/LintPulse-MCP.git
cd LintPulse-MCP
npm install # 安装依赖
npm run build # 编译 TypeScript
npm test # 运行 105 个测试
npm run typecheck # TypeScript 类型检查
npm run lint # ESLint 检查
npm run format # Prettier 格式化可用命令
| 命令 | 说明 |
|------|------|
| npm run build | 编译 src/ → dist/ |
| npm run typecheck | tsc --noEmit 类型检查 |
| npm test | Vitest 运行所有单元测试 |
| npm run test:watch | Vitest 监视模式 |
| npm run test:coverage | 运行测试并生成覆盖率报告 |
| npm run lint | ESLint 检查 src/ 和 tests/ |
| npm run lint:fix | ESLint 自动修复 |
| npm run format | Prettier 格式化 |
| npm start | 启动 MCP Server(node dist/index.js) |
性能指标
| 指标 | 目标 | |------|------| | 语法校验响应 | < 100ms(1000 行) | | 项目扫描时间 | < 5s(1000 文件) | | 内存占用 | < 200MB | | 并发 Agent | 10+ |
