MCP Diagnostics Extension🏆 A production-ready VS Code extension that exposes diagnostic problems (errors, warnings, etc.) in real-time via the Model Context Protocol (MCP) for seamless consumption by AI agents and MCP-enabled tools. 🎯 EXCEPTIONAL ACHIEVEMENTS🏆 World-Class Quality Standards
🚀 Performance Excellence
🔧 Advanced Technical Implementation
✨ Latest Features (v1.4.0)
🚀 NEW: v1.4.0 - Auto-Server Injection & Advanced Diagnostics
🚀 What is this?The MCP Diagnostics Extension bridges VS Code's powerful diagnostic system with the Model Context Protocol, enabling AI agents to access your code problems in real-time. Whether you're debugging TypeScript errors, ESLint warnings, or custom linter issues, this extension makes all diagnostic information instantly available to your AI tools. Why was this built?
What problem does it solve?Before this extension, AI agents couldn't see your VS Code problems panel, making it difficult for them to:
Key Features Learned & Implemented
📦 InstallationFrom VS Code Marketplace (Recommended)
The extension will automatically activate and register itself as an MCP server. From VSIX File
From Source (Development)
🚀 Quick Start1. Installation & ActivationAfter installing from the marketplace, the extension automatically:
2. Verify It's WorkingLook for the status bar item: 3. Connect Your MCP ClientAdd to your MCP client configuration:
4. Start Using MCP ToolsYour AI agent can now access three powerful tools:
🚀 AUTO-DEPLOYMENT & ONE-CLICK SETUP (Sprint 4 Feature)⚡ Automatic MCP Server RegistrationThe extension now features one-click automatic setup that eliminates all manual configuration! This breakthrough feature automatically:
🎯 How Auto-Deployment Works
📋 Auto-Configuration Injection Process
🏗️ Auto-Deployment Architecture
⚙️ Configuration File Priorities
🎛️ One-Click Setup Commands
|
Platform | Install Path | Executable | Spawn Options |
---|---|---|---|
Windows | %USERPROFILE%\.mcp-diagnostics\ |
❌ Not required | shell: true (required) |
macOS | ~/.mcp-diagnostics/ |
✅ chmod +x |
shell: false |
Linux | ~/.mcp-diagnostics/ |
✅ chmod +x |
shell: false |
🛡️ Security & Reliability Features
Atomic Operations
// All file operations are atomic to prevent corruption
1. Write to temporary file (.tmp)
2. Validate written content
3. Atomic rename to final location
4. Clean up temporary files
Backup Strategy
// Automatic backup creation before any changes
- Original config → config.backup
- Malformed config → config.malformed.backup
- Restore on validation failure
Version Management
// Smart version detection and upgrade handling
- Compare semantic versions (1.2.3 format)
- Skip deployment if same/older version
- Automatic upgrade for newer versions
🚨 Error Handling & Recovery
The auto-deployment system includes comprehensive error handling:
Error Type | Recovery Strategy |
---|---|
Permission Denied | Show manual setup with elevated privileges guide |
Disk Space | Alert user and provide cleanup recommendations |
Network Issues | Use bundled assets with offline deployment |
Config Corruption | Create backup and initialize fresh configuration |
Version Conflicts | Smart merge with user preference preservation |
📈 Performance Metrics
Sprint 4 auto-deployment meets strict performance requirements:
- ⚡ Deployment Time: <2 seconds for complete setup
- ⚡ Configuration Injection: <500ms including validation
- ⚡ Memory Usage: <10MB additional during deployment
- ⚡ File Operations: Atomic with <100ms overhead
- ⚡ Cross-Platform: Universal compatibility with intelligent spawn detection
🛠️ Usage Guide
Available Commands
Access via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
MCP Diagnostics: Show Status
- Opens detailed status webview with:- Server connection status
- Problem statistics by severity and source
- File-by-file breakdown
- Workspace folder information
- Performance metrics
MCP Diagnostics: Restart Server
- Restarts the MCP server with progress indicationMCP Diagnostics: Show Setup Guide
- Opens comprehensive setup guide for MCP client configuration
MCP Tools Reference
🔍 getProblems
- Universal Problem Query
Get all diagnostic problems with powerful filtering options:
{
"name": "getProblems",
"arguments": {
"filePath": "/path/to/file.ts", // Optional: filter by specific file
"severity": "Error", // Optional: Error, Warning, Information, Hint
"workspaceFolder": "my-project", // Optional: filter by workspace
"source": "typescript", // Optional: filter by diagnostic source
"limit": 100, // Optional: limit results (default: 1000)
"offset": 0 // Optional: pagination offset
}
}
Example Response:
{
"content": [
{
"type": "text",
"text": "[{\"filePath\":\"/workspace/src/app.ts\",\"severity\":\"Error\",\"message\":\"Cannot find name 'foo'\",\"range\":{\"start\":{\"line\":10,\"character\":5},\"end\":{\"line\":10,\"character\":8}},\"source\":\"typescript\",\"workspaceFolder\":\"/workspace\",\"code\":\"2304\"}]"
}
]
}
📄 getProblemsForFile
- File-Specific Diagnostics
Get all problems for a specific file:
{
"name": "getProblemsForFile",
"arguments": {
"filePath": "/absolute/path/to/file.ts"
}
}
📊 getWorkspaceSummary
- Workspace Statistics
Get comprehensive workspace diagnostic statistics:
{
"name": "getWorkspaceSummary",
"arguments": {
"groupBy": "severity" // Optional: severity, source, workspaceFolder
}
}
Example Response:
{
"content": [
{
"type": "text",
"text": "{\"totalProblems\":15,\"byFile\":{\"app.ts\":3,\"utils.ts\":2},\"bySeverity\":{\"Error\":5,\"Warning\":10},\"bySource\":{\"typescript\":8,\"eslint\":7},\"byWorkspace\":{\"main\":15},\"timestamp\":\"2024-01-15T10:30:00.000Z\"}"
}
]
}
MCP Resources
Dynamic resources providing structured access to diagnostic data:
diagnostics://summary
- Overall workspace problems summarydiagnostics://file/{encodedFilePath}
- Problems for specific filediagnostics://workspace/{encodedWorkspaceName}
- Problems for specific workspace
Real-time Notifications
The server automatically sends problemsChanged
notifications when diagnostics change:
{
"method": "notifications/message",
"params": {
"level": "info",
"data": {
"type": "problemsChanged",
"uri": "/path/to/file.ts",
"problemCount": 3,
"problems": [...],
"timestamp": "2024-01-15T10:30:00.000Z"
}
}
}
⚙️ Configuration
Customize the extension via VS Code settings (Ctrl+,
/ Cmd+,
):
{
"mcpDiagnostics.server.port": 6070,
"mcpDiagnostics.debounceMs": 300,
"mcpDiagnostics.enableDebugLogging": false,
"mcpDiagnostics.enablePerformanceLogging": false,
"mcpDiagnostics.maxProblemsPerFile": 1000,
"mcpDiagnostics.debug.logLevel": "info",
"mcpDiagnostics.showAutoRegistrationNotification": true
}
Configuration Options
Setting | Type | Default | Description |
---|---|---|---|
server.port |
number | 6070 | MCP server port (1024-65535) |
debounceMs |
number | 300 | Debounce interval for diagnostic events (50-5000ms) |
enableDebugLogging |
boolean | false | Enable detailed debug logging |
enablePerformanceLogging |
boolean | false | Enable performance metrics logging |
maxProblemsPerFile |
number | 1000 | Maximum problems to track per file (1-10000) |
debug.logLevel |
string | "info" | Logging level (error, warn, info, debug) |
showAutoRegistrationNotification |
boolean | true | Show MCP server registration notifications |
🧪 Testing & Development
🏆 Exceptional Test Coverage Achievement
The extension has achieved world-class testing standards:
- ✅ 810 Tests Passing - Comprehensive test suite with 0 failures (1 skipped)
- ✅ 97.99% Statement Coverage - Exceeding industry standards
- ✅ 34 Test Suites - Organized, maintainable test structure across all components
- ✅ Cross-Platform Testing - Validated on Windows, macOS, and Linux environments
- ✅ Comprehensive E2E Testing - Full extension workflow validation
Real vs Mock Server
The extension provides two operational modes:
🔴 Real VS Code Extension (Production Mode)
- Purpose: Production use with actual VS Code diagnostics
- Data Source: Live VS Code Problems panel
- Activation: Automatic when extension is installed
- Use Case: Real development workflows with AI agents
🔧 Development Tools
- Package Validation:
scripts/validate-package.sh
- Automated package integrity checks - Asset Conversion:
scripts/convert-assets.js
- Visual asset optimization utilities
Test Workspace
The extension includes test-workspace/
with intentional errors:
example.ts
: TypeScript errors (type mismatches, undefined variables, invalid assignments)utils.js
: ESLint warnings (unused variables, style issues, best practice violations)
To test the extension:
- Launch Extension Development Host (Press F5 in VS Code)
- Open test workspace or any workspace with diagnostic issues
- View Problems panel (Ctrl+Shift+M) to see real diagnostics
- Use MCP tools to query the diagnostic data
- Check status bar for live error/warning counts
Development Setup
# Install dependencies
npm install
# Run tests (810 tests)
npm test
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
# Compile TypeScript
npm run compile
# Package extension
npm run package
# Run CI checks
npm run ci:check
🔧 MCP Client Configuration
The extension provides a universal MCP server that works with all major MCP-enabled environments. The server runs as a standalone Node.js process and provides real-time diagnostic data from your workspace.
🎯 Universal Configuration Pattern
All MCP clients use the same basic configuration pattern with environment-specific variations:
{
"mcpServers": {
// or "servers" for some clients
"vscode-diagnostics": {
"command": "node",
"args": ["scripts/mcp-server.js"],
"cwd": "/path/to/mcp-diagnostics-extension",
"env": {
"NODE_ENV": "production",
"MCP_DEBUG": "false"
}
}
}
}
📁 Configuration File Locations
Environment | Configuration File | Format |
---|---|---|
Cursor IDE | .cursor/mcp.json |
mcpServers |
VS Code | .vscode/mcp.json |
servers (with type: "stdio" ) |
Windsurf | .windsurf/mcp.json |
servers |
Claude Desktop | claude_desktop_config.json |
mcpServers |
MCP Client Configuration Examples
Cursor IDE
// .cursor/mcp.json or cursor-mcp-config.json
{
"mcpServers": {
"vscode-diagnostics": {
"command": "node",
"args": ["scripts/mcp-server.js"],
"cwd": "/path/to/mcp-diagnostics-extension",
"env": {
"NODE_ENV": "production",
"MCP_DEBUG": "false"
}
}
}
}
VS Code with MCP Extension
// .vscode/mcp.json
{
"servers": {
"vscode-diagnostics": {
"type": "stdio",
"command": "node",
"args": ["scripts/mcp-server.js"],
"cwd": "/path/to/mcp-diagnostics-extension",
"env": {
"NODE_ENV": "production",
"MCP_DEBUG": "false"
}
}
}
}
Windsurf IDE
// .windsurf/mcp.json
{
"servers": {
"vscode-diagnostics": {
"command": "node",
"args": ["scripts/mcp-server.js"],
"cwd": "/path/to/mcp-diagnostics-extension",
"env": {
"NODE_ENV": "production",
"MCP_DEBUG": "false"
}
}
}
}
Claude Desktop
// claude_desktop_config.json
{
"mcpServers": {
"vscode-diagnostics": {
"command": "node",
"args": ["scripts/mcp-server.js"],
"cwd": "/path/to/mcp-diagnostics-extension",
"env": {
"NODE_ENV": "production",
"MCP_DEBUG": "false"
}
}
}
}
Custom MCP Client
import { Client } from '@modelcontextprotocol/client';
const client = new Client({
name: 'my-client',
version: '1.0.0',
});
// Connect to extension
await client.connect({
command: 'node',
args: ['scripts/mcp-server.js'],
cwd: '/path/to/mcp-diagnostics-extension',
env: {
NODE_ENV: 'production',
MCP_DEBUG: 'false',
},
});
// Use tools
const problems = await client.callTool({
name: 'getProblems',
arguments: { severity: 'Error' },
});
🚀 MCP Server Features
The scripts/mcp-server.js
provides:
- 🔍 Real-time Diagnostics: Live TypeScript and ESLint analysis
- 📊 VS Code Integration: Automatic import of VS Code Problems panel data
- ⚡ Performance Optimized: Cached results with smart refresh logic
- 🛡️ Error Recovery: Graceful fallback when VS Code data unavailable
- 🔧 Configurable: Environment variables for debugging and behavior control
🌍 Environment Variables
Variable | Default | Description |
---|---|---|
NODE_ENV |
development |
Set to production for optimized performance |
MCP_DEBUG |
false |
Enable detailed debug logging |
REFRESH_INTERVAL |
30000 |
Cache refresh interval in milliseconds |
MAX_PROBLEMS |
10000 |
Maximum number of problems to cache |
🔄 Data Sources
The MCP server intelligently combines multiple data sources:
- VS Code Export (Primary): Real-time data from the extension
- TypeScript Compiler (Fallback): Direct
tsc
analysis - ESLint (Fallback): Direct ESLint analysis
- Cached Results (Performance): Smart caching with automatic refresh
## 📚 Documentation
### Additional Resources
- **[MCP Server Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/MCP_SERVER_GUIDE.md)** - Comprehensive setup and configuration guide
- **[Quick Setup Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/QUICK_SETUP.md)** - Fast-track installation instructions
- **[Troubleshooting Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/TROUBLESHOOTING.md)** - Common issues and solutions
- **[Contributing Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/.github/CONTRIBUTING.md)** - Development and contribution guidelines
- **[Changelog](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/CHANGELOG.md)** - Version history and release notes
- **[Security Policy](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/.github/SECURITY.md)** - Security reporting and policies
### API Documentation
Comprehensive TypeScript documentation is available for all public APIs:
- **[DiagnosticsWatcher API](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/src/core/diagnostics/)** - Core diagnostic monitoring
- **[MCP Tools API](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/src/infrastructure/mcp/)** - MCP server implementation
- **[Extension Commands API](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/src/commands/)** - VS Code command integration
## 🤝 Contributing
We welcome contributions! Please see our [Contributing Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/.github/CONTRIBUTING.md) for details.
### Quick Contribution Steps
1. **Fork the repository**
2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
3. **Make changes** following our coding standards
4. **Run tests**: `npm test` (all 810 tests must pass)
5. **Lint code**: `npm run lint`
6. **Commit changes**: `npm run commit` (uses conventional commits)
7. **Push to branch**: `git push origin feature/amazing-feature`
8. **Open a Pull Request**
### Development Requirements
- Node.js 22.x or higher
- VS Code 1.96.0 or higher
- TypeScript 5.8.3 or higher
## 🐛 Troubleshooting
### Common Issues
#### Extension Not Activating
1. Check VS Code version compatibility (requires 1.96.0+)
2. Look for activation errors in Developer Tools Console
3. Try reloading VS Code window (Ctrl+Shift+P → "Reload Window")
#### MCP Connection Issues
1. Verify MCP client configuration paths
2. Check that the extension is active (status bar shows MCP status)
3. Restart the MCP server: Command Palette → "MCP Diagnostics: Restart Server"
#### No Diagnostics Showing
1. Ensure you have files with actual errors/warnings open
2. Check VS Code Problems panel (Ctrl+Shift+M) - MCP data comes from here
3. Verify diagnostic providers (TypeScript, ESLint) are working
For more detailed troubleshooting, see our [Troubleshooting Guide](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/TROUBLESHOOTING.md).
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](https://github.com/newbpydev/mcp-diagnostics-extension/blob/HEAD/LICENSE) file for details.
## 🙏 Acknowledgments
- **VS Code Team** - For the excellent extension API and diagnostic system
- **Model Context Protocol** - For the innovative protocol enabling AI agent integration
- **TypeScript Team** - For the robust type system and development experience
- **Jest Community** - For the comprehensive testing framework
- **Open Source Community** - For the tools and libraries that make this project possible
---
**🚀 Ready to supercharge your AI-assisted development workflow? Install the MCP Diagnostics Extension today and give your AI agents complete visibility into your codebase health!**