Skip to main content
Glama
lin037

MCP Diagnostics

by lin037

getDiagnostics

Retrieve diagnostic information (errors, warnings, hints) from all workspace files to enable intelligent code analysis and suggestions.

Instructions

获取当前工作区所有文件的诊断信息(错误/警告/提示)。返回完整的诊断列表,包含所有文件的详细错误信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'getDiagnostics' tool. Fetches all diagnostics from VSCodeDiagnosticsClient and returns formatted JSON response.
    private async handleGetDiagnostics() {
      try {
        const diagnostics = await this.diagnosticsClient.getDiagnostics();
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(diagnostics, null, 2),
            },
          ],
        };
      } catch (error) {
        throw new McpError(
          ErrorCode.InternalError,
          `[handleGetDiagnostics] ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Core helper method in VSCodeDiagnosticsClient that performs HTTP fetch to retrieve all diagnostics from the local VS Code extension server.
    async getDiagnostics(): Promise<FileDiagnostic[]> {
      try {
        // 使用 fetch API 请求本地服务器
        const response = await fetch(this.diagnosticsUrl);
        
        // 检查响应是否成功
        if (!response.ok) {
          // 如果HTTP状态码表示错误,则抛出错误
          throw new Error(`HTTP error! status: ${response.status}`);
        }
        
        // 解析 JSON 数据
        const data = await response.json();
        return data as FileDiagnostic[];
    
      } catch (error: any) {
        // 捕获并记录错误,例如服务器未运行或网络问题
        // 捕获并记录错误,然后重新抛出一个更明确的错误
        const errorMessage = `获取诊断失败: ${error.message}. 请确保配套的 "Diagnostics Server" VS Code 扩展已安装、已启用,并且 VS Code 正在运行中。`;
        console.error(errorMessage);
        throw new Error(errorMessage);
      }
    }
  • src/index.ts:46-54 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for 'getDiagnostics'.
    {
      name: 'getDiagnostics',
      description: '获取当前工作区所有文件的诊断信息(错误/警告/提示)。返回完整的诊断列表,包含所有文件的详细错误信息。',
      inputSchema: {
        type: 'object',
        properties: {},
        additionalProperties: false,
      },
    },
  • Input schema for the 'getDiagnostics' tool (no parameters required).
    inputSchema: {
      type: 'object',
      properties: {},
      additionalProperties: false,
    },
  • Dispatch handler in CallToolRequestSchema switch statement routing to the specific getDiagnostics handler.
    case 'getDiagnostics':
      return await this.handleGetDiagnostics();
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 of behavioral disclosure. It states the tool returns '完整的诊断列表,包含所有文件的详细错误信息' (complete diagnostic list with detailed error information for all files), which describes the output scope but lacks critical behavioral details. It doesn't mention whether this is a read-only operation, potential performance impacts, rate limits, or authentication requirements. For a tool with zero annotation coverage, this is insufficient.

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

Conciseness4/5

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

The description is concise and well-structured in two sentences. The first sentence states the purpose, and the second clarifies the output scope. There's no wasted text, and it's front-loaded with the core functionality. It could be slightly more efficient by combining ideas, but it's already very tight.

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

Completeness2/5

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

Given the complexity (diagnostics across all files), lack of annotations, and no output schema, the description is incomplete. It mentions the output includes a 'complete diagnostic list' but doesn't specify the format, structure, or what 'detailed error information' entails. For a tool with no structured output documentation and behavioral gaps, more context is needed to be fully helpful.

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%. With no parameters to document, the description appropriately doesn't discuss any. It focuses on the tool's purpose and output, which is sufficient. A baseline of 4 is appropriate for zero-parameter tools when the description is otherwise adequate.

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 information for all files in the current workspace). It specifies the resource (all files in workspace) and the type of information (diagnostics including errors/warnings/hints). However, it doesn't explicitly differentiate from its siblings (getDiagnosticsForFile, getDiagnosticsForPath, getDiagnosticsSummary), which would be needed for a score of 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus its siblings. It mentions '所有文件' (all files), which implies a comprehensive scope, but doesn't explicitly contrast with the more targeted sibling tools (for specific files, paths, or summaries). No usage context, exclusions, or alternatives are provided.

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