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.

Fix mcp-server dependencies

f-trycua896c939f38eb
diff --git a/.github/workflows/publish-mcp-server.yml b/.github/workflows/publish-mcp-server.yml
index 253c1628dd..4d511bcbbe 100644
--- a/.github/workflows/publish-mcp-server.yml
+++ b/.github/workflows/publish-mcp-server.yml
@@ -19,17 +19,19 @@ on:
outputs:
version:
description: "The version that was published"
- value: ${{ jobs.determine-version.outputs.version }}
+ value: ${{ jobs.prepare.outputs.version }}
# Adding permissions at workflow level
permissions:
contents: write
jobs:
- determine-version:
+ prepare:
runs-on: macos-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
+ agent_version: ${{ steps.update-deps.outputs.agent_version }}
+ computer_version: ${{ steps.update-deps.outputs.computer_version }}
steps:
- uses: actions/checkout@v4
@@ -54,15 +56,102 @@ jobs:
echo "VERSION=$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: '3.10'
+
+ - name: Update dependencies to latest versions
+ id: update-deps
+ run: |
+ cd libs/mcp-server
+
+ # Install required package for PyPI API access
+ pip install requests
+
+ # Create a Python script for PyPI version checking
+ cat > get_latest_versions.py << 'EOF'
+ import requests
+ import json
+ import sys
+
+ def get_package_version(package_name, fallback="0.1.0"):
+ try:
+ response = requests.get(f'https://pypi.org/pypi/{package_name}/json')
+ print(f"API Response Status for {package_name}: {response.status_code}", file=sys.stderr)
+
+ if response.status_code != 200:
+ print(f"API request failed for {package_name}, using fallback version", file=sys.stderr)
+ return fallback
+
+ data = json.loads(response.text)
+
+ if 'info' not in data:
+ print(f"Missing 'info' key in API response for {package_name}, using fallback version", file=sys.stderr)
+ return fallback
+
+ return data['info']['version']
+ except Exception as e:
+ print(f"Error fetching version for {package_name}: {str(e)}", file=sys.stderr)
+ return fallback
+
+ # Get latest versions
+ print(get_package_version('cua-agent'))
+ print(get_package_version('cua-computer'))
+ EOF
+
+ # Execute the script to get the versions
+ VERSIONS=($(python get_latest_versions.py))
+ LATEST_AGENT=${VERSIONS[0]}
+ LATEST_COMPUTER=${VERSIONS[1]}
+
+ echo "Latest cua-agent version: $LATEST_AGENT"
+ echo "Latest cua-computer version: $LATEST_COMPUTER"
+
+ # Output the versions for the next job
+ echo "agent_version=$LATEST_AGENT" >> $GITHUB_OUTPUT
+ echo "computer_version=$LATEST_COMPUTER" >> $GITHUB_OUTPUT
+
+ # Determine major version for version constraint
+ AGENT_MAJOR=$(echo $LATEST_AGENT | cut -d. -f1)
+ COMPUTER_MAJOR=$(echo $LATEST_COMPUTER | cut -d. -f1)
+
+ NEXT_AGENT_MAJOR=$((AGENT_MAJOR + 1))
+ NEXT_COMPUTER_MAJOR=$((COMPUTER_MAJOR + 1))
+
+ # Update dependencies in pyproject.toml
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ # macOS version of sed needs an empty string for -i
+ sed -i '' "s/\"cua-agent\[all\]>=.*,<.*\"/\"cua-agent[all]>=$LATEST_AGENT,<$NEXT_AGENT_MAJOR.0.0\"/" pyproject.toml
+ sed -i '' "s/\"cua-computer>=.*,<.*\"/\"cua-computer>=$LATEST_COMPUTER,<$NEXT_COMPUTER_MAJOR.0.0\"/" pyproject.toml
+ else
+ # Linux version
+ sed -i "s/\"cua-agent\[all\]>=.*,<.*\"/\"cua-agent[all]>=$LATEST_AGENT,<$NEXT_AGENT_MAJOR.0.0\"/" pyproject.toml
+ sed -i "s/\"cua-computer>=.*,<.*\"/\"cua-computer>=$LATEST_COMPUTER,<$NEXT_COMPUTER_MAJOR.0.0\"/" pyproject.toml
+ fi
+
+ # Display the updated dependencies
+ echo "Updated dependencies in pyproject.toml:"
+ grep -E "cua-agent|cua-computer" pyproject.toml
+
publish:
- needs: determine-version
+ needs: prepare
uses: ./.github/workflows/reusable-publish.yml
with:
package_name: "mcp-server"
package_dir: "libs/mcp-server"
- version: ${{ needs.determine-version.outputs.version }}
+ version: ${{ needs.prepare.outputs.version }}
is_lume_package: false
base_package_name: "cua-mcp-server"
make_latest: false
secrets:
- PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
\ No newline at end of file
+ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
+
+ set-env-variables:
+ needs: [prepare, publish]
+ runs-on: macos-latest
+ steps:
+ - name: Set environment variables for use in other jobs
+ run: |
+ echo "AGENT_VERSION=${{ needs.prepare.outputs.agent_version }}" >> $GITHUB_ENV
+ echo "COMPUTER_VERSION=${{ needs.prepare.outputs.computer_version }}" >> $GITHUB_ENV
\ No newline at end of file
diff --git a/libs/mcp-server/pyproject.toml b/libs/mcp-server/pyproject.toml
index dd0ca44d8b..420cd343cf 100644
--- a/libs/mcp-server/pyproject.toml
+++ b/libs/mcp-server/pyproject.toml
@@ -13,7 +13,7 @@ authors = [
]
dependencies = [
"mcp>=1.6.0,<2.0.0",
- "cua-agent>=0.1.0,<0.2.0",
+ "cua-agent[all]>=0.1.0,<0.2.0",
"cua-computer>=0.1.0,<0.2.0",
]
diff --git a/libs/mcp-server/scripts/run_mcp_server.sh b/libs/mcp-server/scripts/run_mcp_server.sh
index 9039af9967..ebeb46ca49 100755
--- a/libs/mcp-server/scripts/run_mcp_server.sh
+++ b/libs/mcp-server/scripts/run_mcp_server.sh
@@ -40,25 +40,26 @@ fi
# Create virtual environment if it doesn't exist
if [ ! -d "$VENV_DIR" ]; then
- python3 -m venv "$VENV_DIR"
+ # Redirect output to prevent JSON parsing errors in Claude
+ python3 -m venv "$VENV_DIR" >/dev/null 2>&1
# Activate virtual environment
source "$VENV_DIR/bin/activate"
- # Upgrade pip
- pip install --upgrade pip
-
- # Install the required packages
- pip install "cua-mcp-server"
+ # Upgrade pip and install required packages
+ pip install --upgrade pip >/dev/null 2>&1
+ pip install "cua-mcp-server" >/dev/null 2>&1
else
# Activate existing virtual environment
source "$VENV_DIR/bin/activate"
# Check if mcp_server package is installed in the virtual environment
if ! python3 -c "import importlib.util; print(importlib.util.find_spec('mcp_server') is not None)" 2>/dev/null | grep -q "True" 2>/dev/null; then
- pip install "cua-mcp-server"
+ pip install "cua-mcp-server" >/dev/null 2>&1
fi
fi
-# Run the server in the virtual environment
+# Run the MCP server with isolation from development paths
+cd "$VENV_DIR" # Change to venv directory to avoid current directory in path
+
python3 -c "from mcp_server.server import main; main()"