Skip to content

Include diagnostic location and code in code_checker MCP output #664

@Viktor-Gostyaikin

Description

@Viktor-Gostyaikin

The current code_checker tool in mcp-server-vscode retrieves diagnostics via vscode.languages.getDiagnostics(), but the returned MCP payload drops important diagnostic metadata.

Current output includes only:

{
  severity: DiagnosticSeverity[diag.severity],
  message: diag.message,
  source: diag.source || '',
}

This makes it hard for external MCP clients and coding agents to act on diagnostics, because they cannot identify the exact file range, diagnostic code, or target documentation link.

VS Code diagnostics already contain this data. For example, the Problems panel exposes fields like:

{
  "resource": "/path/to/file.bsl",
  "code": {
    "value": "UnreachableCode",
    "target": {
      "path": "/bsl-language-server/diagnostics/UnreachableCode",
      "scheme": "https",
      "authority": "1c-syntax.github.io"
    }
  },
  "severity": 8,
  "message": "Fix the algorithm because this code will never be executed",
  "source": "bsl-language-server",
  "startLineNumber": 54,
  "startColumn": 3,
  "endLineNumber": 54,
  "endColumn": 85
}

Request

Please extend code_checker output to include diagnostic range and code metadata.

Suggested shape:

.map((diag) => ({
  severity: DiagnosticSeverity[diag.severity],
  message: diag.message,
  source: diag.source || '',
  code: diag.code,
  range: {
    startLineNumber: diag.range.start.line + 1,
    startColumn: diag.range.start.character + 1,
    endLineNumber: diag.range.end.line + 1,
    endColumn: diag.range.end.character + 1,
  },
  tags: diag.tags,
  relatedInformation: diag.relatedInformation,
}))

Using 1-based line and column numbers would align the MCP output with VS Code Problems JSON and make it easier for agents to report and fix diagnostics precisely.

Why This Matters

Without coordinates, an MCP client can only report diagnostic text. In larger files, repeated diagnostics from the same source become ambiguous. Returning range and code would allow agents to:

  • navigate directly to the affected location;
  • group diagnostics by rule code;
  • link to diagnostic documentation;
  • apply targeted fixes safely;
  • produce actionable summaries with file and line references.

Acceptance Criteria

  • code_checker returns range for each diagnostic.
  • range includes start/end line and column.
  • code is preserved when provided by VS Code.
  • Existing fields severity, message, and source remain backward-compatible.
  • If possible, the output also includes tags and relatedInformation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions