Skip to main content
Glama
lin037

MCP Diagnostics

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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool returns statistical information (file count, error count, warning count), which is useful behavioral context. However, it doesn't mention other traits like whether it's read-only, requires specific permissions, has rate limits, or how it handles large projects. For a tool with zero annotation coverage, this leaves significant gaps in behavioral understanding.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise and well-structured in a single sentence: it states the action, purpose, and return values clearly. There's no wasted text, and it's front-loaded with the key information. Every part of the sentence earns its place by contributing essential details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (simple, no parameters) and lack of annotations and output schema, the description is moderately complete. It explains the purpose and output content (file total, error count, warning count), which is adequate for a basic summary tool. However, it doesn't cover behavioral aspects like performance or limitations, and without an output schema, the return format remains unspecified. This makes it minimally viable but with gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100% (since there are no parameters to describe). The description doesn't need to add parameter semantics, but it does clarify the scope ('项目整体代码质量' - overall project code quality) and output content. With no parameters, the baseline is 4, and the description adds value by explaining what the tool does without parameter-related confusion.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '获取诊断统计摘要,快速了解项目整体代码质量' (Get diagnostic statistics summary, quickly understand overall code quality of the project). It specifies the verb '获取' (get) and resource '诊断统计摘要' (diagnostic statistics summary), and mentions what information it returns. However, it doesn't explicitly differentiate from sibling tools like getDiagnostics, getDiagnosticsForFile, and getDiagnosticsForPath, which appear to provide more granular diagnostics.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by stating it provides a '快速了解项目整体代码质量' (quick understanding of overall project code quality), suggesting it's for high-level summaries rather than detailed analysis. However, it doesn't explicitly state when to use this tool versus the sibling tools (e.g., getDiagnosticsForFile for file-specific details) or provide any exclusions or alternatives. The guidance is implied but not detailed.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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