Skip to main content
Glama
lolpack

MCP Pyrefly Autotype Server

by lolpack

type_check_file

Perform type checking on a Python file using Pyrefly's type inference engine to ensure code correctness and compliance with type annotations.

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

  • Main execution logic for the type_check_file tool. Validates input, runs pyrefly check via helper, formats and returns 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', '')}" )]
  • Tool registration in list_tools() including name, description, and input schema definition.
    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"], }, ),
  • Core helper function that runs the subprocess call to 'uv run pyrefly check' on the file and parses the result.
    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) }

Other Tools

Related 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