Skip to main content
Glama

get_diagnostics

Identify type errors and warnings in Python code files to improve code quality and prevent runtime issues.

Instructions

Get type errors and warnings for a file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler for 'get_diagnostics' which calls the underlying LSP client.
    @mcp.tool()
    async def get_diagnostics(file_path: str) -> str:
        """Get type errors and warnings for a file."""
        client = _get_client()
    
        path = Path(file_path).resolve()
        if not path.exists():
            return _error(f"File not found: {file_path}")
    
        try:
            await client.open_document(path)
    
            import asyncio
            await asyncio.sleep(0.5)
    
            diagnostics = client.get_diagnostics(path)
    
            if not diagnostics:
                return _ok({"file": path.name, "count": 0, "diagnostics": []})
    
            diag_list = []
            for diag in diagnostics:
                severity = SEVERITY_MAP.get(diag.severity or 1, "error")
                diag_list.append({
                    "line": diag.range.start.line + 1,
                    "column": diag.range.start.character + 1,
                    "severity": severity,
  • The underlying LSP client method that retrieves cached diagnostics for a given file path.
    def get_diagnostics(self, file_path: str | Path) -> list[Diagnostic]:
        """Get cached diagnostics for a file."""
        file_path = Path(file_path).resolve()
        uri = file_path.as_uri()
        return self._diagnostics.get(uri, [])
Behavior2/5

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

No annotations are provided, so the description carries full disclosure burden. While 'Get' implies read-only behavior, the description fails to mention project context requirements (critical given 'start_project'/'stop_project' siblings), whether the file must be saved, or if this triggers a compilation/check.

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?

Single sentence front-loaded with the verb 'Get'. No redundant words; 'type errors and warnings' efficiently specifies the diagnostic scope. Appropriate length for the tool's simplicity.

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?

Sufficient for a single-parameter read operation with an output schema present (so return values need not be described). However, lacks critical contextual information about project lifecycle dependencies given the sibling tool ecosystem.

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

Parameters3/5

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

Schema coverage is 0% with no property descriptions. The description mentions 'for a file' which loosely maps to the 'file_path' parameter, providing minimal semantic context, but does not specify path format requirements (absolute vs relative), file existence requirements, or supported file types.

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 states a clear action ('Get') and specific artifacts ('type errors and warnings') for a defined resource ('a file'). However, it does not distinguish from siblings like 'analyze_file' or 'get_type_info' that may have overlapping functionality.

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?

No guidance provided on when to prefer this over 'analyze_file', 'get_code_actions', or 'get_type_info'. No mention of prerequisites like requiring 'start_project' to be called first given the presence of project lifecycle siblings.

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/qinsehm1128/mcp-ty'

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