import subprocess
import os
import sys

def main():
    # 获取二进制文件路径
    binary_path = os.path.join(os.path.dirname(__file__), "elasticsearch-core-mcp-server")
    
    # 检查并修复权限
    if not os.access(binary_path, os.X_OK):
        print(f"Fixing permissions for {binary_path}")
        os.chmod(binary_path, 0o755)  # 设置为可执行权限
    
    # 执行二进制文件
    ret = subprocess.call([binary_path] + sys.argv[1:])
    sys.exit(ret)
