Skip to main content
Glama
lin037
by lin037

getDiagnosticsSummary

Generate a summary of code quality metrics including file counts, errors, and warnings to assess project diagnostics.

Instructions

获取诊断统计摘要,快速了解项目整体代码质量。返回文件总数、错误数量、警告数量的统计信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The primary handler function for the 'getDiagnosticsSummary' MCP tool. It fetches all diagnostics from the VSCodeDiagnosticsClient, counts errors and warnings by iterating over the diagnostics, constructs a summary object, and returns it as JSON-formatted text content.
    private async handleGetDiagnosticsSummary() { try { const diagnostics = await this.diagnosticsClient.getDiagnostics(); let errorCount = 0; let warningCount = 0; diagnostics.forEach((fileDiagnosticTuple) => { // fileDiagnosticTuple is a tuple [uri: any, diagnostics: Diagnostic[]] if (Array.isArray(fileDiagnosticTuple) && fileDiagnosticTuple.length === 2) { const diagnosticList = fileDiagnosticTuple[1]; if (Array.isArray(diagnosticList)) { diagnosticList.forEach((d) => { if (d && typeof d.severity === 'number') { // severity: 0=Error, 1=Warning in VS Code if (d.severity === 0) { errorCount++; } else if (d.severity === 1) { warningCount++; } } }); } } }); const summary = { fileCount: diagnostics.length, errorCount, warningCount, }; return { content: [ { type: 'text', text: JSON.stringify(summary, null, 2), }, ], }; } catch (error) { throw new McpError( ErrorCode.InternalError, `[handleGetDiagnosticsSummary] ${error instanceof Error ? error.message : String(error)}` ); } }
  • src/index.ts:85-93 (registration)
    The tool registration entry in the ListToolsRequestSchema handler, defining the name, description, and empty inputSchema for 'getDiagnosticsSummary'.
    { name: 'getDiagnosticsSummary', description: '获取诊断统计摘要,快速了解项目整体代码质量。返回文件总数、错误数量、警告数量的统计信息。', inputSchema: { type: 'object', properties: {}, additionalProperties: false, }, },
  • The input schema for the 'getDiagnosticsSummary' tool, which accepts no parameters.
    inputSchema: { type: 'object', properties: {}, additionalProperties: false, },
  • A helper method in VSCodeDiagnosticsClient that computes the diagnostics summary (though not directly used by the MCP tool handler). It uses standard VS Code severity codes (1=Error, 2=Warning).
    async getDiagnosticsSummary(): Promise<DiagnosticSummary> { const allDiagnostics = await this.getDiagnostics(); const totalFiles = allDiagnostics.length; const allDiagnosticItems = allDiagnostics.flatMap(f => f.diagnostics); const errors = allDiagnosticItems.filter(d => d.severity === 1).length; const warnings = allDiagnosticItems.filter(d => d.severity === 2).length; return { totalFiles, errors, warnings }; }
  • Type definition for the DiagnosticSummary returned by the helper method.
    export interface DiagnosticSummary { totalFiles: number; errors: number; warnings: number; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lin037/mcp-diagnostics-trae'

If you have feedback or need assistance with the MCP directory API, please join our Discord server