🐛➡️✨ 调试MCP服务器时出错
 ](https://nodejs.org/)    
A. 生产就绪模型上下文协议(MCP)服务器 它通过智能错误调试、实时检测和跨多种编程语言的自动解析功能,将人工智能驱动的IDE进行了转换。
🎉 生产就绪并经过全面测试
- ✅ 419项测试通过 全面覆盖
- ✅ 真实世界集成测试 具有多个IDE
- ✅ 稳健的错误处理 优雅的退化
- ✅ 性能优化 (71MB内存,2.1秒启动)
- ✅ 符合MCP协议 完全支持JSON-RPC
🚀 特性和功能
🎯 核心错误检测
- 🔍 多语言支持:TypeScript、JavaScript、Python、Go、Rust、PHP
- ⚡ 实时监控:跨构建、lint、运行时和控制台的实时检测
- 🧠 AI增强分析:智能错误分类和解决方案建议
- 🔗 IDE集成:原生支持VS代码、游标、Windsurf和增强代码
- 📡 MCP协议:完全符合2024-11-05模型上下文协议
🛠️ 错误检测源
| 来源 | 描述 | 状态 |
|---|---|---|
| 构建错误 | Types/JavaScript编译错误 | ✅ 活动 |
| 林特尔错误 | ESLint、TSLint、特定语言的linting | ✅ 活动 |
| 运行期错误 | 实时应用程序错误监控 | ✅ 活动 |
| 控制台错误 | 浏览器和Node.js控制台检测 | ✅ 活动 |
| 测试错误 | 单元测试失败和断言错误 | ✅ 活动 |
| IDE诊断 | 编辑器诊断API集成 | 🔄 计划中 |
| 静态分析 | 代码质量和安全分析 | 🔄 计划中 |
🎛️ 高性能
- 🔬 情境感知分析:项目结构和依赖关系理解
- 📈 性能分析:内存使用和瓶颈检测
- 🎯 调试会话管理:具有完整生命周期的多语言调试
- 📊 实时监控:系统指标、自定义分析和警报
- 🔧 开发环境:全面的工作流集成
- 🛡️ 证券分析:漏洞检测和代码安全扫描
📦 安装和设置
📋 先决条件
- Node.js:22.14.0+(经过测试和优化)
- TypeScript:5.3.0+(可选,如果缺少,则优雅回退)
- MCP兼容IDE:VS代码、光标、风帆或增强代码
⚡ 快速开始
# Clone the repository
git clone https://github.com/your-org/error-debugging-mcp-server.git
# Change directory to the project directory
cd error-debugging-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
# Start the server
npm start
# Or use the startup script for better reliability
./start-mcp-server.sh🧪 开发与测试
# Install dependencies
npm install
# Run comprehensive test suite (419 tests)
npm test
# Run tests with coverage report (62.35% coverage)
npm run test:coverage
# Start development server with hot reload
npm run dev
# Lint and format code
npm run lint
npm run format
# Test MCP protocol compliance
node test-mcp-protocol.js
# Test error detection functionality
node simple-mcp-test.js✅ 验证
# Verify installation
npm run build && npm start
# Test with sample errors
cd test-project && npx tsc --noEmit
# Check server health
curl -X POST http://localhost:3000/health⚙️ 配置
📁 配置文件
服务器使用三种类型的配置文件:
error-debugging-config.json-主服务器配置(项目根).error-debugging.json-工作区特定设置(工作区根).error-debugging-preferences.json-用户首选项(主目录)
备注:如果不存在配置文件,服务器会自动创建 error-debugging-config.json 首次启动时使用默认设置。🔧 主要配置
创建 error-debugging-config.json 在项目根目录中:
{
"server": {
"name": "error-debugging-mcp-server",
"version": "1.0.0",
"logLevel": "info",
"maxConnections": 10,
"timeout": 30000
},
"detection": {
"enabled": true,
"realTime": true,
"sources": {
"console": true,
"runtime": true,
"build": true,
"test": true,
"linter": true,
"staticAnalysis": true,
"ide": true
},
"filters": {
"excludeFiles": ["node_modules/**", "dist/**", "build/**"],
"excludePatterns": ["*.min.js", "*.map"]
},
"polling": {
"interval": 1000,
"maxRetries": 3
}
},
"analysis": {
"enabled": true,
"aiEnhanced": true,
"confidenceThreshold": 0.7,
"enablePatternMatching": true,
"enableSimilaritySearch": true
},
"debugging": {
"enabled": true,
"maxConcurrentSessions": 5,
"enableHotReload": true,
"breakpoints": {
"maxPerSession": 50,
"enableConditional": true
}
},
"performance": {
"enabled": true,
"monitoring": {
"enabled": true,
"interval": 5000
}
}
}备注:如果不存在配置文件,服务器将自动创建 error-debugging-config.json 首次启动时使用默认设置。工作空间配置
对于特定于项目的设置,请创建 .error-debugging.json 在您的工作区根目录中:
{
"projectName": "my-project",
"rootPath": "/path/to/project",
"excludePatterns": ["node_modules/**", "dist/**", "*.min.js"],
"includePatterns": ["src/**", "lib/**"],
"languageSettings": {
"typescript": {
"strictMode": true,
"compilerOptions": {
"target": "ES2020"
}
},
"javascript": {
"eslintConfig": ".eslintrc.js"
}
}
}用户选项
对于个人设置,请创建 .error-debugging-preferences.json 在您的主目录中:
{
"theme": "dark",
"notifications": {
"enabled": true,
"sound": false,
"desktop": true
},
"editor": {
"fontSize": 14,
"fontFamily": "Monaco",
"tabSize": 2
},
"debugging": {
"autoBreakOnError": true,
"showStackTrace": true,
"verboseLogging": false
}
}🔗 IDE集成
🎯 测试和工作配置
用这个 生产测试 无缝集成配置:
{
"servers": {
"error-debugging": {
"command": "node",
"args": ["/path/to/error-debugging-mcp-server/dist/index.js"],
"env": {
"NODE_ENV": "development"
}
}
}
}🖥️ IDE特定设置
🔵 VS代码
添加到您的 settings.json:
{
"mcp.servers": {
"error-debugging": {
"command": "node",
"args": ["/path/to/error-debugging-mcp-server/dist/index.js"],
"env": {
"NODE_ENV": "development"
}
}
},
"mcp.enableLogging": true,
"mcp.logLevel": "debug"
}🟡 光标IDE
创建 ~/.cursor/mcp-settings.json:
{
"servers": {
"error-debugging": {
"command": "node",
"args": ["/path/to/error-debugging-mcp-server/dist/index.js"],
"description": "Advanced error detection and debugging"
}
}
}🟢 Windsurf IDE
添加到Windsurf的MCP配置中:
{
"mcpServers": {
"error-debugging": {
"command": "node",
"args": ["/path/to/error-debugging-mcp-server/dist/index.js"],
"env": {
"DEBUG": "mcp:*"
}
}
}
}🔴 增强代码
添加到Augment工作区配置:
{
"mcp": {
"servers": {
"error-debugging": {
"command": "node",
"args": ["/path/to/error-debugging-mcp-server/dist/index.js"],
"description": "Advanced error detection and debugging"
}
}
}
}✅ 集成验证
配置后:
- 重新启动IDE 应用设置
- 检查MCP连接 在IDE日志中
- 样本错误测试 使用提供的测试文件
- 验证工具是否可用:
detect-errors,analyze-error
🔧 用法和工具
🎯 可用的MCP工具
服务器提供了两个强大的错误分析工具:
🔍 detect-errors
通过智能过滤检测各种来源的错误:
{
"name": "detect-errors",
"description": "Detect errors from various sources (console, runtime, build, test)",
"parameters": {
"source": "console|runtime|build|test|all",
"language": "typescript|javascript|python|go|rust|php",
"files": ["specific/files/to/analyze"],
"includeWarnings": true,
"realTime": true
}
}🧠 analyze-error
利用人工智能增强的洞察力对特定错误进行深入分析:
{
"name": "analyze-error",
"description": "Perform deep analysis of a specific error",
"parameters": {
"errorId": "unique-error-identifier",
"includeContext": true,
"includeSuggestions": true,
"includeHistory": true
}
}📊 错误检测示例
服务器会自动检测并分类各种错误类型:
// 1. Type Safety Errors
const invalidCode: string = 123; // TS7006: Type mismatch
// 2. Null Safety Issues
function processUser(user: User | null) {
console.log(user.name); // TS18047: Possible null reference
}
// 3. Security Vulnerabilities
function executeCode(code: string) {
return eval(code); // SEC001: Security risk
}
// 4. Code Quality Issues
const unusedVariable = "test"; // TS6133: Unused variable🎮 交互式使用
在IDE的AI聊天中,您可以使用以下命令:
🔍 "Detect errors in the current file"
🧠 "Analyze the TypeScript error on line 42"
🔧 "Suggest fixes for null reference errors"
📊 "Show error statistics for this project"🧪 测试和质量保证
📊 测试套件概述
- 419通过测试 ✅ (0次失败)
- 62.35%的代码覆盖率 📈 (全面覆盖)
- 22个测试文件 📁 (涵盖所有主要部件)
- 现实世界一体化 🌍 (用实际IDE测试)
🔬 测试类别
| 类别 | 测试 | 覆盖范围 | 状态 |
|---|---|---|---|
| 有用 | 142项测试 | 71.77% | ✅ 太好了 |
| 调试组件 | 107次测试 | 92.75% | ✅ 杰出 |
| 探测器 | 87项测试 | 59.43% | ✅ 很好 |
| 集成 | 43次测试 | 100% | ✅ 太好了! |
| 服务器组件 | 40次测试 | 47.76% | ✅ 充足 |
🚀 运行测试
# Run complete test suite (419 tests)
npm test
# Run with detailed coverage report
npm run test:coverage
# Run tests in watch mode for development
npm run test:watch
# Run specific test categories
npm test -- --testPathPattern=utils
npm test -- --testPathPattern=detectors
npm test -- --testPathPattern=integrations
# Test MCP protocol compliance
node test-mcp-protocol.js
# Test error detection functionality
node simple-mcp-test.js🎯 质量指标
✅ 生产准备就绪
- 生成状态:所有构建都一致通过
- 集成流程:使用真实IDE验证完整的工作流程
- 演出:71.4MB内存使用率,2.1秒启动时间
- 错误恢复:优雅地处理缺失的依赖关系
- MCP合规性:完全支持JSON-RPC协议
🔍 已验证的能力
- ✅ 多语言错误检测:TypeScript、JavaScript、Python、Go、Rust、PHP
- ✅ 实时监控:所有来源的实时错误检测
- ✅ AI增强分析:智能分类和修复建议
- ✅ 调试会话管理:具有断点和检查的完整生命周期
- ✅ 性能监控:系统指标和分析
- ✅ IDE集成:使用VS Code、Cursor、Windsurf、Augment进行测试
📈 性能基准
- 响应时间:错误检测平均值\
cd error-debugging-mcp-server npm install && npm run build
### 2.️⃣ **配置IDE**
添加到IDE的MCP配置中:
{ "servers": { "error-debugging": { "command": "node", "args": ["/path/to/error-debugging-mcp-server/dist/index.js"] } } }
### 3.️⃣ **测试集成**
Test server functionality
node test-mcp-protocol.js
Test error detection
cd test-project && npx tsc --noEmit
### 4.️⃣ **开始调试**
- 打开一个有错误的TypeScript文件
- 使用IDE的AI聊天:“检测此文件中的错误”
- 获取基于AI的分析和修复建议
## 🤝 贡献
我们欢迎捐款!以下是如何开始:
### 🔧 **开发设置**
Fork and clone the repository
git clone https://github.com/your-username/error-debugging-mcp-server.git cd error-debugging-mcp-server
Install dependencies
npm install
Run tests to ensure everything works
npm test
Start development server
npm run dev
### 📝 **贡献指南**
1. **分叉** 存储库
1. **创建** 特征分支: `git checkout -b feature/amazing-feature`
1. **添加测试** 新功能(保持>60%的覆盖率)
1. **确保** 所有测试均通过: `npm test`
1. **跟随** TypeScript严格模式和ESLint规则
1. **提交** 信息清晰: `git commit -m 'Add amazing feature'`
1. **推** 到您的分行: `git push origin feature/amazing-feature`
1. **打开** 一个带有详细描述的拉取请求
### 🎯 **贡献领域**
- **语言支持**:添加新的编程语言检测器
- **IDE集成**:扩展对更多IDE的支持
- **误差分析**:改进基于人工智能的错误分析
- **演出**:优化检测算法
- **文档**:改进指南和示例
## 📄 许可证
此项目根据MIT许可证获得许可-请参阅 [许可证](LICENSE) 文件以获取详细信息。
## 🌟 致谢
### 🙏 **特别感谢**
- **模型上下文协议团队** -用于创建优秀的MCP规范
- **TypeScript团队** -用于健壮的类型系统和编译器API
- **VS代码团队** -对于全面的诊断API
- **开源社区** -对于那些令人惊叹的工具和库
### 🔧 **构建于**
- **[模型上下文协议](https://modelcontextprotocol.io/)** -AI-IDE通信标准
- **[TypeScript](https://www.typescriptlang.org/)** -类型安全的JavaScript开发
- **** -JavaScript运行时环境
- **[速度](https://vitest.dev/)** -快速单元测试框架
- **[ESLint](https://eslint.org/)** -代码质量和风格执行
## 🔗 链接和资源
### 📚 **文档**
- **[模型上下文协议规范](https://spec.modelcontextprotocol.io/)**
- **[TypeScript编译器API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API)**
- **[VS代码扩展API](https://code.visualstudio.com/api)**
### 🛠️ **相关项目**
- **[MCP-SDK](https://github.com/modelcontextprotocol/typescript-sdk)** -TypeScript官方SDK
- **[克劳德桌面](https://claude.ai/desktop)** -支持MCP的AI助手
- **[光标IDE](https://cursor.sh/)** -AI驱动的代码编辑器
______________________________________________________________________
**🐛➡️✨ 通过AI驱动的错误检测改变您的调试体验!**
](https://github.com/your-org/error-debugging-mcp-server)
[](https://twitter.com/your-handle)
**由以下材料制成❤️ 适用于希望更智能调试的开发人员**
- [模型上下文协议](https://modelcontextprotocol.io/)
- [文档](docs/)
- [例子](examples/)
- [问题追踪](https://github.com/error-debugging-mcp-server/error-debugging-mcp-server/issues)
## 🙏 致谢
- 模型上下文协议团队为优秀的规范
- 用于健壮类型系统的TypeScript团队
- 所有帮助改进此项目的贡献者