Skip to content

Commit 6f505c0

Browse files
authored
[BUZZOK-28810] Add support for MCP server to genai agents (#1798)
* Add support for MCP server to genai agents * Rework * Cleanup * Remove checks * Set pythonpath * Fix posix compatibility * Fix remaining posix incompatibilties
1 parent 910f02d commit 6f505c0

File tree

4 files changed

+64
-18
lines changed

4 files changed

+64
-18
lines changed

public_dropin_environments/python311_genai_agents/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ RUN uv venv ${VENV_PATH} && \
5252
WORKDIR ${WORKDIR}
5353

5454
COPY ./agent/agent.py ./agent/cgroup_watchers.py ${AGENTDIR}/
55-
COPY ./jupyter_kernel_gateway_config.py ./start_server.sh ${WORKDIR}/
55+
COPY ./jupyter_kernel_gateway_config.py ${WORKDIR}/jupyter_kernel_gateway_config.py
56+
COPY ./start_server_codespaces.sh ${WORKDIR}/start_server.sh
5657
COPY ./ipython_config.py /etc/ipython/
5758
COPY ./extensions /etc/ipython/extensions
5859

public_dropin_environments/python311_genai_agents/Dockerfile.local

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ RUN uv venv ${VENV_PATH} && \
9292
WORKDIR ${WORKDIR}
9393

9494
COPY ./agent/agent.py ./agent/cgroup_watchers.py ${AGENTDIR}/
95-
COPY ./jupyter_kernel_gateway_config.py ./start_server.sh ${WORKDIR}/
95+
COPY ./jupyter_kernel_gateway_config.py ${WORKDIR}/jupyter_kernel_gateway_config.py
96+
COPY ./start_server_codespaces.sh ${WORKDIR}/start_server.sh
9697
COPY ./ipython_config.py /etc/ipython/
9798
COPY ./extensions /etc/ipython/extensions
9899

public_dropin_environments/python311_genai_agents/start_server.sh renamed to public_dropin_environments/python311_genai_agents/start_server_codespaces.sh

File renamed without changes.

public_dropin_environments/python311_genai_agents/start_server_drum.sh

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,68 @@
55
# This is proprietary source code of DataRobot, Inc. and its affiliates.
66
#
77
# Released under the terms of DataRobot Tool and Utility Agreement.
8-
echo "Starting Custom Model environment with DRUM prediction server"
98

10-
if [ "${ENABLE_CUSTOM_MODEL_RUNTIME_ENV_DUMP}" = 1 ]; then
9+
# =============================================================================
10+
# Startup script for Custom Model or MCP Server environments
11+
# Determines which service to run based on directory contents
12+
# =============================================================================
13+
14+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
15+
16+
# Configure UV package manager
17+
export UV_PROJECT=${CODE_DIR}
18+
unset UV_COMPILE_BYTECODE # Disable compilation (already done in build)
19+
unset UV_CACHE_DIR # Disable caching for reproducibility
20+
21+
# Activate the virtual environment
22+
. ${VENV_PATH}/bin/activate
23+
24+
# Sync dependencies using UV
25+
# --active: Install into the active venv instead of creating a new one
26+
# --frozen: Skip dependency resolution, use exact versions from lock file
27+
# --extra: Install the 'agentic_playground' optional dependency group
28+
# Note: Compilation disabled since kernel venv is already compiled
29+
uv sync --frozen --active --no-progress --color never --extra agentic_playground || true
30+
31+
# Optional: Dump environment variables for debugging
32+
if [ "${ENABLE_CUSTOM_MODEL_RUNTIME_ENV_DUMP}" = "1" ]; then
1133
echo "Environment variables:"
1234
env
1335
fi
1436

15-
export UV_PROJECT=${CODE_DIR}
16-
unset UV_COMPILE_BYTECODE
17-
unset UV_CACHE_DIR
18-
source ${VENV_PATH}/bin/activate
19-
# `--active` to install into active kernel venv (instead of creating local from scratch)
20-
# `--frozen` to skip dependency resolution and just install exactly what's in lock file
21-
# Compilation DISABLED - kernel venv has already been compiled, and having compilation enabled
22-
# would re-compile all site-packages (takes quite some time)
23-
time uv sync --frozen --active --no-progress --color never --extra agentic_playground || true
24-
25-
echo
26-
echo "Executing command: drum server $*"
27-
echo
28-
exec drum server "$@"
37+
# -----------------------------------------------------------------------------
38+
# Option 1: Custom Model with DRUM Server
39+
# Requires: custom.py file in the same directory
40+
# -----------------------------------------------------------------------------
41+
if [ -f "$SCRIPT_DIR/custom.py" ]; then
42+
echo "Starting Custom Model environment with DRUM prediction server"
43+
44+
# Start DRUM server
45+
echo
46+
echo "Executing command: drum server $*"
47+
echo
48+
exec drum server "$@"
49+
50+
# -----------------------------------------------------------------------------
51+
# Option 2: MCP Server
52+
# Requires: app/ directory in the same location
53+
# -----------------------------------------------------------------------------
54+
elif [ -d "$SCRIPT_DIR/app" ]; then
55+
echo "Starting Custom Model environment with MCP server"
56+
57+
# Set Python path to script directory for module imports
58+
export PYTHONPATH="$SCRIPT_DIR"
59+
60+
# Start the MCP server
61+
exec python -m app.main
62+
63+
# -----------------------------------------------------------------------------
64+
# Error: No valid entry point found
65+
# -----------------------------------------------------------------------------
66+
else
67+
echo "Error: Neither custom.py nor app/ directory found in $SCRIPT_DIR"
68+
echo "This script requires either:"
69+
echo " - custom.py file for DRUM-based Custom Models"
70+
echo " - app/ directory for MCP Server applications"
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)