MCP Diagnostics is a specialized server designed for Trae IDE that enables AI agents to access real-time diagnostic information (errors, warnings, and hints) from your project, allowing for smarter code analysis and suggestions.
To access VS Code diagnostic information, first install the companion extension:
Ctrl+Shift+P
or Cmd+Shift+P
)trae-diagnostics-server-0.0.1.vsix
file in the diagnostics-extension
directoryOnce installed, the extension will automatically run a local server in the background to provide diagnostic data.
# Clone the project
git clone https://github.com/lin037/mcp-diagnostics-trae.git
cd mcp-diagnostics
# Install dependencies
npm install
# Build the project
npm run build
{
"mcpServers": {
"diagnostics": {
"command": "npx",
"args": ["-y", "/path/to/mcp-diagnostics"],
"description": "Trae IDE Diagnostic Information Tool"
}
}
}
Note: Replace /path/to/mcp-diagnostics
with the actual path where you cloned the project.
For example, if you cloned the project to E:/MCPWork/trae-diagnostics/mcp
:
{
"mcpServers": {
"diagnostics": {
"command": "npx",
"args": [
"-y",
"E:/MCPWork/trae-diagnostics/mcp"
]
}
}
}
getDiagnostics()
Retrieves diagnostic information for all files in the current workspace.
Input: No parameters
{}
Output: Array of diagnostic information
[
{
"uri": "file:///workspace/src/index.ts",
"diagnostics": [
{
"range": {
"start": { "line": 12, "character": 5 },
"end": { "line": 12, "character": 10 }
},
"severity": 1,
"source": "typescript",
"message": "Type 'string' cannot be assigned to type 'number'."
}
]
}
]
getDiagnosticsForPath(filePath)
⭐ RecommendedGets diagnostic information based on file path, with flexible path matching.
Input:
{
"filePath": "src/index.ts"
}
Supported path formats:
src/index.ts
index.ts
test/TestJava.java
Output: Array of diagnostic information for matching files
Examples:
"filePath": "src/index.ts"
"filePath": "TestJava.java"
"filePath": "test/test-errors.ts"
getDiagnosticsForFile(fileUri)
Gets diagnostic information for a specific file (requires full URI).
Input:
{
"fileUri": "file:///workspace/src/index.ts"
}
Note: Must use the complete URI format starting with file:///workspace/
.
getDiagnosticsSummary()
Gets statistical information about diagnostics.
Input: No parameters
{}
Output: Summary statistics
{
"totalFiles": 4,
"errors": 4,
"warnings": 4
}
User: "Please check the diagnostic summary for the current project"
The AI will automatically call the getDiagnosticsSummary
tool.
User: "Please list all errors and warnings in the current project"
The AI will call the getDiagnostics
tool.
User: "Please check the issues in src/index.ts file"
The AI will call the getDiagnosticsForPath
tool with the parameter {"filePath": "src/index.ts"}
.
1
- Error ❌2
- Warning ⚠️3
- Information ℹ️4
- Hint 💡Solution:
Possible causes:
Solution:
Solution:
getDiagnosticsForPath
tool (recommended)file:///workspace/file-path
getDiagnostics
first to see available file URIsCheck:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "diagnostics" '{"command":"npx","args":["-y","mcp-diagnostics"],"description":"Trae IDE \u8bca\u65ad\u4fe1\u606f\u8bfb\u53d6\u5de5\u5177"}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"diagnostics": {
"command": "npx",
"args": [
"-y",
"mcp-diagnostics"
],
"description": "Trae IDE \u8bca\u65ad\u4fe1\u606f\u8bfb\u53d6\u5de5\u5177"
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"diagnostics": {
"command": "npx",
"args": [
"-y",
"mcp-diagnostics"
],
"description": "Trae IDE \u8bca\u65ad\u4fe1\u606f\u8bfb\u53d6\u5de5\u5177"
}
}
}
3. Restart Claude Desktop for the changes to take effect