Skip to content

Commit 1a80168

Browse files
committed
fix: diagnose binary
1 parent 2ec133a commit 1a80168

File tree

4 files changed

+90
-2
lines changed

4 files changed

+90
-2
lines changed

.github/workflows/build-github-mcp-server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
description = "Official GitHub MCP Server"
7777
authors = [{ name = "John Doe" }]
7878
dependencies = [
79-
"uipath-mcp==0.0.72",
79+
"uipath-mcp==0.0.73",
8080
]
8181
requires-python = ">=3.10"
8282
EOF

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-mcp"
3-
version = "0.0.72"
3+
version = "0.0.73"
44
description = "UiPath MCP SDK"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import os
2+
import platform
3+
import subprocess
4+
5+
6+
def diagnose_binary(binary_path):
7+
"""Diagnose why a binary file can't be executed."""
8+
results = {}
9+
10+
# Check if file exists
11+
results["exists"] = os.path.exists(binary_path)
12+
if not results["exists"]:
13+
return f"Error: {binary_path} does not exist"
14+
15+
# Get system architecture
16+
results["system_arch"] = platform.machine()
17+
results["system_os"] = platform.system()
18+
19+
# Check file type using 'file' command
20+
try:
21+
file_output = subprocess.check_output(
22+
["file", binary_path], universal_newlines=True
23+
)
24+
results["file_type"] = file_output.strip()
25+
except subprocess.CalledProcessError:
26+
results["file_type"] = "Could not determine file type (file command failed)"
27+
except FileNotFoundError:
28+
results["file_type"] = (
29+
"Could not determine file type (file command not available)"
30+
)
31+
32+
# For Linux, check ELF header
33+
if platform.system() == "Linux":
34+
try:
35+
readelf_output = subprocess.check_output(
36+
["readelf", "-h", binary_path], universal_newlines=True
37+
)
38+
# Extract architecture from readelf output
39+
arch_line = [
40+
line for line in readelf_output.splitlines() if "Machine:" in line
41+
]
42+
if arch_line:
43+
results["binary_arch"] = arch_line[0].strip()
44+
else:
45+
results["binary_arch"] = "Could not determine binary architecture"
46+
except subprocess.CalledProcessError:
47+
results["binary_arch"] = "Not a valid ELF binary (readelf command failed)"
48+
except FileNotFoundError:
49+
results["binary_arch"] = (
50+
"Could not check ELF header (readelf command not available)"
51+
)
52+
53+
# Print summary
54+
print(f"Diagnosis for {binary_path}:")
55+
print(f"File exists: {results['exists']}")
56+
print(f"System architecture: {results['system_arch']}")
57+
print(f"System OS: {results['system_os']}")
58+
print(f"File type: {results['file_type']}")
59+
if "binary_arch" in results:
60+
print(f"Binary architecture: {results['binary_arch']}")
61+
62+
# Provide potential solution
63+
if "ELF" in results.get("file_type", "") and results["system_os"] == "Linux":
64+
if (
65+
"64-bit" in results["file_type"]
66+
and "x86-64" in results["file_type"]
67+
and results["system_arch"] != "x86_64"
68+
):
69+
return (
70+
"Error: Binary was compiled for x86_64 architecture but your system is "
71+
+ results["system_arch"]
72+
)
73+
elif (
74+
"ARM" in results.get("binary_arch", "")
75+
and "arm" not in results["system_arch"].lower()
76+
):
77+
return (
78+
"Error: Binary was compiled for ARM architecture but your system is "
79+
+ results["system_arch"]
80+
)
81+
82+
return "Binary format may be incompatible with your system. You need a version compiled specifically for your architecture and operating system."

src/uipath_mcp/_cli/_runtime/_runtime.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,18 @@ async def _register(self) -> None:
255255
server_stderr_output = ""
256256

257257
import os
258+
259+
from ._diagnose import diagnose_binary
260+
258261
print(f"Current working directory: {os.getcwd()}")
259262
print(f"Files in directory: {os.listdir('.')}")
260263
binary_path = "github-mcp-server"
261264
print(f"Binary exists: {os.path.exists(binary_path)}")
262265
print(f"Binary is executable: {os.access(binary_path, os.X_OK)}")
263266

267+
diagnosis = diagnose_binary(binary_path)
268+
print(diagnosis)
269+
264270
try:
265271
# Create a temporary session to get tools
266272
server_params = StdioServerParameters(

0 commit comments

Comments
 (0)