io.github.daedalus/mcp-pyright
MCP server that exposes Pyright language server functionality
Versions
0.1.0latestTools 7
check_types Check types in a Python file or string of code. Performs type checking using Pyright and returns diagnostics. Args: code: Python code as string (mutually exclusive with file_path). file_path: Path to Python file (mutually exclusive with code). python_path: Optional path to Python interpreter. type_checker_mode: Type checking mode - "basic", "strict", or "overload" (default: "basic"). Returns: Dictionary containing diagnostics, file analyzed, and type checking time. Raises: ValueError: If neither code nor file_path is provided. FileNotFoundError: If file_path doesn't exist. RuntimeError: If pyright is not installed. Example: >>> check_types(code="x: int = 'hello'") {'file': '/tmp/...', 'diagnostics': [{'severity': 'error', 'message': '...'}], 'typeCheckingTime': 0.1}
get_hover Get hover information at a specific position. Returns type information and documentation for the symbol at the given position. Args: code: Python code as string. position: Character position (0-indexed) in the code. python_path: Optional path to Python interpreter. Returns: Dictionary with contents (markdown), range, and kind. Example: >>> get_hover("x: int = 1", 0) {'contents': '```python\nint\n```', 'range': {...}, 'kind': 'python'}
get_completions Get code completions at a specific position. Returns available completions at the given cursor position. Args: code: Python code as string. position: Character position (0-indexed) in the code. python_path: Optional path to Python interpreter. Returns: Dictionary with completion items (label, detail, documentation, insertText). Example: >>> get_completions("prin", 4) {'items': [{'label': 'print', 'detail': 'def print(...)', ...}]}
get_definition Get definition location at a specific position. Returns the location of the definition for the symbol at the given position. Args: code: Python code as string. position: Character position (0-indexed) in the code. python_path: Optional path to Python interpreter. Returns: Dictionary with definition location (file path, range). Example: >>> get_definition("def foo(): pass\nfoo()", 15) {'file': '/tmp/...', 'range': {'start': {'line': 0, 'character': 0}, ...}}
find_references Find all references to a symbol at a specific position. Returns all reference locations for the symbol at the given position. Args: code: Python code as string. position: Character position (0-indexed) in the code. python_path: Optional path to Python interpreter. Returns: Dictionary with reference locations. Example: >>> find_references("x = 1\nx", 5) {'references': [{'file': '/tmp/...', 'range': {...}}, ...]}
get_document_symbols Get all symbols in a Python document. Returns document symbols including functions, classes, variables, etc. Args: code: Python code as string. python_path: Optional path to Python interpreter. Returns: Dictionary with symbol information (name, kind, range, containerName). Example: >>> get_document_symbols("class Foo: pass\ndef bar(): pass") {'symbols': [{'name': 'Foo', 'kind': 'class', ...}, {'name': 'bar', 'kind': 'function', ...}]}
format_code Format Python code. Formats the given Python code using pyright's formatter. Args: code: Python code as string. python_path: Optional path to Python interpreter. Returns: Dictionary with formatted code. Example: >>> format_code("x=1\ny=2") {'formattedCode': 'x = 1\ny = 2\n'}
Permissions 2
filesystem low shell high