Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Redirect stdout

f-trycua8135fcd7029f
diff --git a/libs/mcp-server/scripts/run_mcp_server.sh b/libs/mcp-server/scripts/run_mcp_server.sh
index e3556b1666..d462cae790 100755
--- a/libs/mcp-server/scripts/run_mcp_server.sh
+++ b/libs/mcp-server/scripts/run_mcp_server.sh
@@ -2,59 +2,72 @@
set -e
-# Function to check if a command exists
-command_exists() {
- command -v "$1" >/dev/null 2>&1
-}
-
-# Function to check if a Python package is installed
-package_installed() {
- python3 -c "import importlib.util; print(importlib.util.find_spec('$1') is not None)" | grep -q "True"
-}
-
-echo "πŸš€ CUA MCP Server Setup Script"
-echo "============================="
-
-# Check if Python is installed
-if ! command_exists python3; then
- echo "❌ Python 3 is not installed. Please install Python 3 and try again."
- exit 1
-fi
-
-echo "βœ… Python 3 is installed"
-
-# Check if pip is installed
-if ! command_exists pip3; then
- echo "❌ pip3 is not installed. Please install pip and try again."
- exit 1
-fi
-
-echo "βœ… pip3 is installed"
-
-# Check if mcp_server package is installed
-if ! package_installed mcp_server; then
- echo "πŸ”„ mcp_server package is not installed. Installing now..."
- pip3 install --user -e .
-
- if [ $? -ne 0 ]; then
- echo "❌ Failed to install mcp_server. Please check the error messages above."
+# Redirect all setup and installation output to stderr
+{
+ # Function to check if a command exists
+ command_exists() {
+ command -v "$1" >/dev/null 2>&1
+ }
+
+ # Function to check if a Python package is installed
+ package_installed() {
+ python3 -c "import importlib.util; print(importlib.util.find_spec('$1') is not None)" | grep -q "True"
+ }
+
+ echo "πŸš€ CUA MCP Server Setup Script"
+ echo "============================="
+
+ # Check if Python is installed
+ if ! command_exists python3; then
+ echo "❌ Python 3 is not installed. Please install Python 3 and try again."
exit 1
fi
-
- echo "βœ… mcp_server installed successfully"
-else
- echo "βœ… mcp_server is already installed"
-fi
-# Run the Python module directly
-echo "πŸš€ Starting MCP server..."
+ echo "βœ… Python 3 is installed"
-# Get the directory of this script
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
-PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
+ # Check if pip is installed
+ if ! command_exists pip3; then
+ echo "❌ pip3 is not installed. Please install pip and try again."
+ exit 1
+ fi
+
+ echo "βœ… pip3 is installed"
+
+ # Get the directory of this script
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+ PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
+
+ # Add the necessary paths to PYTHONPATH
+ export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"
+
+ # Check if we're in a Python project directory
+ cd "$PROJECT_ROOT"
+
+ # Check if mcp_server package is installed
+ if ! package_installed mcp_server; then
+ echo "πŸ”„ mcp_server package is not installed. Installing now..."
+
+ # Check if setup.py or pyproject.toml exists
+ if [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
+ pip3 install --user -e .
+
+ if [ $? -ne 0 ]; then
+ echo "❌ Failed to install mcp_server. Please check the error messages above."
+ exit 1
+ fi
+
+ echo "βœ… mcp_server installed successfully"
+ else
+ echo "❌ Cannot install mcp_server: neither setup.py nor pyproject.toml found in $PROJECT_ROOT"
+ # Continue anyway, maybe the module is already in PYTHONPATH
+ fi
+ else
+ echo "βœ… mcp_server is already installed"
+ fi
-# Add the necessary paths to PYTHONPATH
-export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"
+ echo "πŸš€ Starting MCP server..."
+} >&2 # Redirect all of the above to stderr
+# Only the actual server should communicate on stdout for proper MCP protocol
# Run the server module directly
-python3 -m mcp_server.server
\ No newline at end of file
+exec python3 -m mcp_server.server
\ No newline at end of file