msmcp-azure 2.0.0b14__py3-none-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Azure MCP Server - PyPI package.
4
+
5
+ This module provides the entry point for the Azure MCP Server CLI.
6
+ The binary is bundled directly in the wheel for the target platform.
7
+ """
8
+
9
+ import os
10
+ import platform
11
+ import subprocess
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ __version__ = "2.0.0-beta.14" # Will be replaced during packaging
16
+
17
+ # Debug mode check
18
+ DEBUG = os.environ.get("DEBUG", "").lower() in ("true", "1", "*") or "mcp" in os.environ.get("DEBUG", "")
19
+
20
+
21
+ def debug_log(*args, **kwargs):
22
+ """Print debug messages to stderr if DEBUG is enabled."""
23
+ if DEBUG:
24
+ print(*args, file=sys.stderr, **kwargs)
25
+
26
+
27
+ def get_executable_path():
28
+ """Get the path to the platform-specific executable."""
29
+ # The binary is located in the bin subdirectory of this package
30
+ package_dir = Path(__file__).parent
31
+ bin_dir = package_dir / "bin"
32
+
33
+ # Determine the executable name based on platform
34
+ system = platform.system().lower()
35
+ if system == "windows":
36
+ executable_name = "azmcp.exe"
37
+ else:
38
+ executable_name = "azmcp"
39
+
40
+ executable_path = bin_dir / executable_name
41
+
42
+ debug_log(f"Package directory: {package_dir}")
43
+ debug_log(f"Binary directory: {bin_dir}")
44
+ debug_log(f"Executable path: {executable_path}")
45
+
46
+ return executable_path
47
+
48
+
49
+ def run_executable(args=None):
50
+ """
51
+ Run the platform-specific executable with the given arguments.
52
+
53
+ Args:
54
+ args: List of command-line arguments to pass to the executable.
55
+ Defaults to sys.argv[1:] if not provided.
56
+
57
+ Returns:
58
+ The exit code from the executable.
59
+ """
60
+ if args is None:
61
+ args = sys.argv[1:]
62
+
63
+ executable_path = get_executable_path()
64
+
65
+ if not executable_path.exists():
66
+ print(f"Error: Executable not found at {executable_path}", file=sys.stderr)
67
+ print(f"This may indicate a packaging issue or unsupported platform.", file=sys.stderr)
68
+ return 1
69
+
70
+ debug_log(f"Running: {executable_path} {' '.join(args)}")
71
+
72
+ try:
73
+ result = subprocess.run(
74
+ [str(executable_path)] + list(args),
75
+ stdin=sys.stdin,
76
+ stdout=sys.stdout,
77
+ stderr=sys.stderr,
78
+ )
79
+ return result.returncode
80
+ except PermissionError:
81
+ print(f"Error: Permission denied executing {executable_path}", file=sys.stderr)
82
+ print("Try: chmod +x " + str(executable_path), file=sys.stderr)
83
+ return 126
84
+ except OSError as e:
85
+ print(f"Error executing {executable_path}: {e}", file=sys.stderr)
86
+ return 1
87
+
88
+
89
+ def main():
90
+ """Main entry point for the CLI."""
91
+ sys.exit(run_executable())
92
+
93
+
94
+ if __name__ == "__main__":
95
+ main()
96
+