Coverage for src/qdrant_loader_mcp_server/utils/version.py: 68%

22 statements  

« prev     ^ index     » next       coverage.py v7.10.3, created at 2025-08-13 09:20 +0000

1"""Version utilities for the MCP server.""" 

2 

3from pathlib import Path 

4 

5import tomli 

6 

7 

8def get_version() -> str: 

9 """Get version from pyproject.toml.""" 

10 try: 

11 # Try to find pyproject.toml in the package directory or parent directories 

12 current_dir = Path(__file__).parent 

13 for _ in range(5): # Look up to 5 levels up 

14 pyproject_path = current_dir / "pyproject.toml" 

15 if pyproject_path.exists(): 

16 with open(pyproject_path, "rb") as f: 

17 pyproject = tomli.load(f) 

18 return pyproject["project"]["version"] 

19 current_dir = current_dir.parent 

20 

21 # If not found, try the workspace root 

22 workspace_root = Path.cwd() 

23 for package_dir in ["packages/qdrant-loader-mcp-server", "."]: 

24 pyproject_path = workspace_root / package_dir / "pyproject.toml" 

25 if pyproject_path.exists(): 

26 with open(pyproject_path, "rb") as f: 

27 pyproject = tomli.load(f) 

28 return pyproject["project"]["version"] 

29 except Exception: 

30 pass 

31 return "Unknown"