Skip to main content
Glama
lolpack

MCP Pyrefly Autotype Server

by lolpack

type_check_file

Check Python file type errors with Pyrefly's inference engine to identify and fix annotation issues.

Instructions

Run type checking on a Python file using Pyrefly

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesPath to the Python file to type check

Implementation Reference

  • Handler implementation in handle_call_tool for 'type_check_file': validates file_path, calls run_pyrefly_check helper, formats and returns type check results as text content.
    elif name == "type_check_file":
        file_path = arguments.get("file_path")
        
        if not file_path:
            raise ValueError("Missing file_path argument")
        
        if not os.path.exists(file_path):
            raise ValueError(f"File not found: {file_path}")
        
        result = await run_pyrefly_check(file_path)
        
        if result["success"]:
            return [types.TextContent(
                type="text", 
                text=f"Type checking passed for {file_path}\n\nOutput:\n{result['output']}"
            )]
        else:
            return [types.TextContent(
                type="text", 
                text=f"Type checking found issues in {file_path}\n\nErrors:\n{result['output']}\n{result.get('errors', '')}"
            )]
  • Registration of the 'type_check_file' tool in the list_tools() handler, including its description and input schema requiring 'file_path'.
    types.Tool(
        name="type_check_file",
        description="Run type checking on a Python file using Pyrefly",
        inputSchema={
            "type": "object",
            "properties": {
                "file_path": {
                    "type": "string",
                    "description": "Path to the Python file to type check"
                }
            },
            "required": ["file_path"],
        },
    ),
  • Input schema definition for the 'type_check_file' tool: object with required 'file_path' string property.
    inputSchema={
        "type": "object",
        "properties": {
            "file_path": {
                "type": "string",
                "description": "Path to the Python file to type check"
            }
        },
        "required": ["file_path"],
    },
  • Helper function that executes the 'pyrefly check' subprocess command on a given file_path and returns a structured result dict with success status, output, and errors.
    async def run_pyrefly_check(file_path: str) -> Dict[str, Any]:
        """Run pyrefly type checking on a file."""
        try:
            result = subprocess.run(
                ["uv", "run", "pyrefly", "check", file_path],
                capture_output=True,
                text=True,
                timeout=30
            )
            
            return {
                "success": result.returncode == 0,
                "output": result.stdout,
                "errors": result.stderr,
                "returncode": result.returncode
            }
        except subprocess.TimeoutExpired:
            return {
                "success": False,
                "error": "Pyrefly check execution timed out"
            }
        except Exception as e:
            return {
                "success": False,
                "error": str(e)
            }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool runs type checking, implying a read-only analysis, but doesn't specify if it modifies files, requires specific permissions, has rate limits, or what the output format is. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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 a single, efficient sentence with zero waste. It front-loads the core action and resource, making it easy to scan. Every word earns its place, providing essential information without redundancy.

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 tool's complexity (type checking implies potential for detailed output) and lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., errors, warnings, success status) or behavioral traits like execution time or dependencies. For a tool with no structured output, more context is needed.

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 description coverage is 100%, so the input schema fully documents the 'file_path' parameter. The description adds no additional meaning beyond what the schema provides (e.g., no details on path format, supported file types, or examples). Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 action ('Run type checking') and target resource ('on a Python file'), specifying the tool 'Pyrefly'. It distinguishes from siblings like 'add_types_to_file' (which modifies) and 'analyze_python_file' (which may be broader), but doesn't explicitly contrast them. The purpose is specific but lacks explicit sibling differentiation.

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 is provided on when to use this tool versus alternatives like 'analyze_python_file' or 'get_project_context'. The description implies usage for type checking Python files, but offers no context on prerequisites, exclusions, or comparisons to siblings. It's a basic statement without usage instructions.

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/lolpack/mcp-pyrefly-autotype'

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