deciduus commited on
Commit
e2b7e2b
·
1 Parent(s): 9a578de

Edit: Changed mcp.py to mcp_handler.py to prevent potential import confusion between 'mcp' package and 'mcp.py'. Edited dockerfile to 'latest' so it doesnt spin up old builds after image creation. Also edited preinstall to ensure the mcp related dependencies can load non-interactive.

Browse files
agent.py CHANGED
@@ -691,7 +691,7 @@ class Agent:
691
 
692
  # Try getting tool from MCP first
693
  try:
694
- import python.helpers.mcp as mcp_helper
695
  mcp_tool_candidate = mcp_helper.MCPConfig.get_instance().get_tool(self, tool_name)
696
  if mcp_tool_candidate:
697
  tool = mcp_tool_candidate
 
691
 
692
  # Try getting tool from MCP first
693
  try:
694
+ import python.helpers.mcp_handler as mcp_helper
695
  mcp_tool_candidate = mcp_helper.MCPConfig.get_instance().get_tool(self, tool_name)
696
  if mcp_tool_candidate:
697
  tool = mcp_tool_candidate
docker/run/docker-compose.yml CHANGED
@@ -1,7 +1,7 @@
1
  services:
2
  agent-zero:
3
  container_name: agent-zero
4
- image: frdel/agent-zero-run:testing
5
  volumes:
6
  - ./agent-zero:/a0
7
  ports:
 
1
  services:
2
  agent-zero:
3
  container_name: agent-zero
4
+ image: frdel/agent-zero:latest
5
  volumes:
6
  - ./agent-zero:/a0
7
  ports:
docker/run/fs/ins/install_A0.sh CHANGED
@@ -1,5 +1,8 @@
1
  #!/bin/bash
2
 
 
 
 
3
  # branch from parameter
4
  if [ -z "$1" ]; then
5
  echo "Error: Branch parameter is empty. Please provide a valid branch name."
@@ -7,10 +10,11 @@ if [ -z "$1" ]; then
7
  fi
8
  BRANCH="$1"
9
 
10
- # clone project repo branch
11
- git clone -b "$BRANCH" "https://github.com/frdel/agent-zero" "/git/agent-zero"
 
 
12
 
13
- # setup python environment
14
  . "/ins/setup_venv.sh" "$@"
15
 
16
  # Ensure the virtual environment and pip setup
@@ -19,9 +23,20 @@ pip install --upgrade pip ipython requests
19
  # Install some packages in specific variants
20
  pip install torch --index-url https://download.pytorch.org/whl/cpu
21
 
 
 
 
 
 
 
 
22
  # Install remaining A0 python packages
23
  pip install -r /git/agent-zero/requirements.txt
24
 
 
 
 
 
25
  # install playwright
26
  bash /ins/install_playwright.sh "$@"
27
 
 
1
  #!/bin/bash
2
 
3
+ # Exit immediately if a command exits with a non-zero status.
4
+ # set -e
5
+
6
  # branch from parameter
7
  if [ -z "$1" ]; then
8
  echo "Error: Branch parameter is empty. Please provide a valid branch name."
 
10
  fi
11
  BRANCH="$1"
12
 
13
+ git clone -b "$BRANCH" "https://github.com/frdel/agent-zero" "/git/agent-zero" || {
14
+ echo "CRITICAL ERROR: Failed to clone repository. Branch: $BRANCH"
15
+ exit 1
16
+ }
17
 
 
18
  . "/ins/setup_venv.sh" "$@"
19
 
20
  # Ensure the virtual environment and pip setup
 
23
  # Install some packages in specific variants
24
  pip install torch --index-url https://download.pytorch.org/whl/cpu
25
 
26
+ pip install -v mcp==1.3.0 || {
27
+ echo "ERROR: Failed during separate attempt to install mcp==1.3.0. Will proceed to full requirements.txt install anyway."
28
+ }
29
+ python -c "import mcp; from mcp import ClientSession; print(f'DEBUG: mcp and mcp.ClientSession imported successfully after separate install. mcp path: {mcp.__file__}')" || {
30
+ echo "ERROR: mcp package or mcp.ClientSession NOT importable after separate mcp==1.3.0 installation attempt. Full requirements.txt will run next."
31
+ }
32
+
33
  # Install remaining A0 python packages
34
  pip install -r /git/agent-zero/requirements.txt
35
 
36
+ python -c "import mcp; from mcp import ClientSession; print(f'DEBUG: mcp and mcp.ClientSession imported successfully after requirements.txt. mcp path: {mcp.__file__}')" || {
37
+ echo "CRITICAL ERROR: mcp package or mcp.ClientSession not found or failed to import after requirements.txt processing."
38
+ }
39
+
40
  # install playwright
41
  bash /ins/install_playwright.sh "$@"
42
 
docker/run/fs/ins/pre_install.sh CHANGED
@@ -5,20 +5,24 @@ chmod 0644 /etc/cron.d/*
5
 
6
  echo "=====BEFORE UPDATE====="
7
 
 
 
 
8
  # Update and install necessary packages
9
  apt clean
10
- apt-get update && apt-get upgrade -y && apt-get install -y \
11
  python3 \
12
  python3-venv \
13
  python3-pip \
14
  nodejs \
 
15
  openssh-server \
16
  sudo \
17
  curl \
18
  wget \
19
  git \
20
  ffmpeg \
21
- nginx\
22
  supervisor \
23
  cron \
24
  libmagic-dev \
@@ -40,6 +44,7 @@ echo "=====MID UPDATE====="
40
 
41
  # for some reason npm crashes builds on amd64 in this version and has to be installed separately
42
  # A0 can install it when needed
 
43
  # apt-get install -y \
44
  # npm
45
 
@@ -59,7 +64,13 @@ echo "=====AFTER UPDATE====="
59
  # fi
60
 
61
  # Install npx for use by local MCP Servers
62
- npm i -g npx shx
 
 
 
 
 
 
63
 
64
  # Prepare SSH daemon
65
  bash /ins/setup_ssh.sh "$@"
 
5
 
6
  echo "=====BEFORE UPDATE====="
7
 
8
+ # Set DEBIAN_FRONTEND to noninteractive to prevent prompts
9
+ export DEBIAN_FRONTEND=noninteractive
10
+
11
  # Update and install necessary packages
12
  apt clean
13
+ apt-get update && apt-get upgrade -y && apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install -y \
14
  python3 \
15
  python3-venv \
16
  python3-pip \
17
  nodejs \
18
+ npm \
19
  openssh-server \
20
  sudo \
21
  curl \
22
  wget \
23
  git \
24
  ffmpeg \
25
+ nginx \
26
  supervisor \
27
  cron \
28
  libmagic-dev \
 
44
 
45
  # for some reason npm crashes builds on amd64 in this version and has to be installed separately
46
  # A0 can install it when needed
47
+ # The line below is now redundant as npm is included in the main install list above
48
  # apt-get install -y \
49
  # npm
50
 
 
64
  # fi
65
 
66
  # Install npx for use by local MCP Servers
67
+ echo "DEBUG: Installing npx and shx globally using npm..."
68
+ npm i -g npx shx || {
69
+ echo "CRITICAL ERROR: Failed to install npx and shx using npm."
70
+ # exit 1 # Optionally exit if this is critical enough
71
+ }
72
+ echo "DEBUG: npx and shx installation attempt finished."
73
+
74
 
75
  # Prepare SSH daemon
76
  bash /ins/setup_ssh.sh "$@"
initialize.py CHANGED
@@ -76,16 +76,17 @@ def initialize():
76
  # update config with runtime args
77
  args_override(config)
78
 
79
- import python.helpers.mcp as mcp_helper
80
  import agent as agent_helper
81
  import python.helpers.print_style as print_style_helper
82
  if not mcp_helper.MCPConfig.get_instance().is_initialized():
83
  try:
84
  mcp_helper.MCPConfig.update(config.mcp_servers)
85
  except Exception as e:
86
- if agent_helper.AgentContext.first():
 
87
  (
88
- agent_helper.AgentContext.first().log
89
  .log(type="warning", content=f"Failed to update MCP settings: {e}", temp=False)
90
  )
91
  (
 
76
  # update config with runtime args
77
  args_override(config)
78
 
79
+ import python.helpers.mcp_handler as mcp_helper
80
  import agent as agent_helper
81
  import python.helpers.print_style as print_style_helper
82
  if not mcp_helper.MCPConfig.get_instance().is_initialized():
83
  try:
84
  mcp_helper.MCPConfig.update(config.mcp_servers)
85
  except Exception as e:
86
+ first_context = agent_helper.AgentContext.first()
87
+ if first_context:
88
  (
89
+ first_context.log
90
  .log(type="warning", content=f"Failed to update MCP settings: {e}", temp=False)
91
  )
92
  (
python/extensions/system_prompt/_10_system_prompt.py CHANGED
@@ -1,7 +1,7 @@
1
  from datetime import datetime
2
  from typing import Any, Optional
3
  from python.helpers.extension import Extension
4
- from python.helpers.mcp import MCPConfig
5
  from agent import Agent, LoopData
6
  from python.helpers.localization import Localization
7
 
 
1
  from datetime import datetime
2
  from typing import Any, Optional
3
  from python.helpers.extension import Extension
4
+ from python.helpers.mcp_handler import MCPConfig
5
  from agent import Agent, LoopData
6
  from python.helpers.localization import Localization
7
 
python/helpers/{mcp.py → mcp_handler.py} RENAMED
@@ -5,6 +5,10 @@ import asyncio
5
  from contextlib import AsyncExitStack
6
  from shutil import which
7
  from datetime import timedelta
 
 
 
 
8
  from mcp import ClientSession, StdioServerParameters
9
  from mcp.client.stdio import stdio_client
10
  from mcp.client.sse import sse_client
 
5
  from contextlib import AsyncExitStack
6
  from shutil import which
7
  from datetime import timedelta
8
+
9
+ import os
10
+ print(f"DEBUG: Listing /opt/venv/lib/python3.11/site-packages/ before mcp import: {os.listdir('/opt/venv/lib/python3.11/site-packages/')}")
11
+
12
  from mcp import ClientSession, StdioServerParameters
13
  from mcp.client.stdio import stdio_client
14
  from mcp.client.sse import sse_client
python/helpers/settings.py CHANGED
@@ -886,7 +886,7 @@ def _apply_settings(previous: Settings | None):
886
  memory_reload()
887
 
888
  # update mcp settings if necessary
889
- from python.helpers.mcp import MCPConfig
890
 
891
  async def update_mcp_settings(mcp_servers: str):
892
  PrintStyle(background_color="black", font_color="white", padding=True).print("Updating MCP config...")
 
886
  memory_reload()
887
 
888
  # update mcp settings if necessary
889
+ from python.helpers.mcp_handler import MCPConfig
890
 
891
  async def update_mcp_settings(mcp_servers: str):
892
  PrintStyle(background_color="black", font_color="white", padding=True).print("Updating MCP config...")