错误调试MCP服务器

一个生产就绪的模型上下文协议(MCP)服务器,通过智能错误调试、实时检测和自动解决功能,增强AI驱动的IDE,支持多种编程语言。

  • by firozanam
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 firozanam/error-debugging-mcp-server

使用说明

🐛➡️✨ 调试MCP服务器时出错

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

⚙️ 配置

📁 配置文件

服务器使用三种类型的配置文件:

  1. error-debugging-config.json -主服务器配置(项目根)
  2. .error-debugging.json -工作区特定设置(工作区根)
  3. .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"
      }
    }
  }
}

✅ 集成验证

配置后:

  1. 重新启动IDE 应用设置
  2. 检查MCP连接 在IDE日志中
  3. 样本错误测试 使用提供的测试文件
  4. 验证工具是否可用: 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进行测试

📈 性能基准

  • 响应时间:错误检测平均值<100ms
  • 内存效率:71.4MB运行时使用率(优化)
  • 启动时间:2.15秒(快速初始化)
  • 并发会话:最多支持5个同时进行的调试会话
  • 错误处理:每秒1000+个错误

� 故障排除

� 常见问题及解决方案

“启动MCP服务器失败”

# Check Node.js version (requires 22.14.0+)
node --version

# Verify server path is correct
ls -la /path/to/error-debugging-mcp-server/dist/index.js

# Test server manually
node /path/to/error-debugging-mcp-server/dist/index.js

“找不到TypeScript编译器”

# Install TypeScript locally (recommended)
npm install typescript

# Or install globally
npm install -g typescript

# Verify installation
npx tsc --version

“连接已关闭”错误

  • 确保IDE配置中的服务器路径是绝对的
  • 检查Node.js是否在您的系统PATH中
  • 配置更改后重新启动IDE
  • 验证MCP扩展是否已安装并启用

🔍 调试命令

# Test MCP protocol compliance
node test-mcp-protocol.js

# Test error detection functionality
node simple-mcp-test.js

# Check server health
curl -X POST http://localhost:3000/health

# View detailed logs
DEBUG=mcp:* node dist/index.js

📚 文档和资源

� 可用文档

🎯 快速参考文件

  • test-project/test-errors.ts -有故意错误的示例文件
  • test-mcp-protocol.js -MCP协议合规性测试
  • simple-mcp-test.js -错误检测功能测试
  • start-mcp-server.sh -可靠的启动脚本

� 快速入门摘要

1.️⃣ 安装和构建

git clone <repository-url>
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. 分叉 存储库
  2. 创建 特征分支: git checkout -b feature/amazing-feature
  3. 添加测试 新功能(保持>60%的覆盖率)
  4. 确保 所有测试均通过: npm test
  5. 跟随 TypeScript严格模式和ESLint规则
  6. 提交 信息清晰: git commit -m 'Add amazing feature'
  7. 推 到您的分行: git push origin feature/amazing-feature
  8. 打开 一个带有详细描述的拉取请求

🎯 贡献领域

  • 语言支持:添加新的编程语言检测器
  • IDE集成:扩展对更多IDE的支持
  • 误差分析:改进基于人工智能的错误分析
  • 演出:优化检测算法
  • 文档:改进指南和示例

📄 许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。

🌟 致谢

🙏 特别感谢

  • 模型上下文协议团队 -用于创建优秀的MCP规范
  • TypeScript团队 -用于健壮的类型系统和编译器API
  • VS代码团队 -对于全面的诊断API
  • 开源社区 -对于那些令人惊叹的工具和库

🔧 构建于

🔗 链接和资源

📚 文档

🛠️ 相关项目


🐛➡️✨ 通过AI驱动的错误检测改变您的调试体验!

由以下材料制成❤️ 适用于希望更智能调试的开发人员

🙏 致谢

  • 模型上下文协议团队为优秀的规范
  • 用于健壮类型系统的TypeScript团队
  • 所有帮助改进此项目的贡献者