Skip to content

Commit 6cbf918

Browse files
committed
Fix entrypoint shell splitting and mcp-serve arg mismatch
Quote all env var expansions to handle special characters in connection strings and credentials. Only pass --db to mcp-serve (it doesn't accept --connection, --username, --password, or --port).
1 parent 37dc2a6 commit 6cbf918

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

docker-entrypoint.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,46 @@ set -e
44
# SIDEMANTIC_MODE: "serve" (default), "mcp", or "both"
55
MODE="${SIDEMANTIC_MODE:-serve}"
66

7-
# Build shared args from environment variables
8-
ARGS=""
7+
# Build arg arrays for each command.
8+
# serve accepts: --connection, --db, --host, --port, --username, --password
9+
# mcp-serve accepts: --db only
10+
11+
# Serve args
12+
SERVE_ARGS="--host 0.0.0.0"
913
if [ -n "$SIDEMANTIC_CONNECTION" ]; then
10-
ARGS="$ARGS --connection $SIDEMANTIC_CONNECTION"
14+
SERVE_ARGS="$SERVE_ARGS --connection \"$SIDEMANTIC_CONNECTION\""
1115
fi
1216
if [ -n "$SIDEMANTIC_DB" ]; then
13-
ARGS="$ARGS --db $SIDEMANTIC_DB"
17+
SERVE_ARGS="$SERVE_ARGS --db \"$SIDEMANTIC_DB\""
1418
fi
15-
16-
# Serve-specific args
17-
SERVE_ARGS=""
1819
if [ -n "$SIDEMANTIC_USERNAME" ]; then
19-
SERVE_ARGS="$SERVE_ARGS --username $SIDEMANTIC_USERNAME"
20+
SERVE_ARGS="$SERVE_ARGS --username \"$SIDEMANTIC_USERNAME\""
2021
fi
2122
if [ -n "$SIDEMANTIC_PASSWORD" ]; then
22-
SERVE_ARGS="$SERVE_ARGS --password $SIDEMANTIC_PASSWORD"
23+
SERVE_ARGS="$SERVE_ARGS --password \"$SIDEMANTIC_PASSWORD\""
2324
fi
2425
if [ -n "$SIDEMANTIC_PORT" ]; then
25-
SERVE_ARGS="$SERVE_ARGS --port $SIDEMANTIC_PORT"
26+
SERVE_ARGS="$SERVE_ARGS --port \"$SIDEMANTIC_PORT\""
27+
fi
28+
29+
# MCP args (only --db is supported)
30+
MCP_ARGS=""
31+
if [ -n "$SIDEMANTIC_DB" ]; then
32+
MCP_ARGS="$MCP_ARGS --db \"$SIDEMANTIC_DB\""
2633
fi
2734

2835
case "$MODE" in
2936
serve)
30-
exec sidemantic serve --host 0.0.0.0 $ARGS $SERVE_ARGS "$@"
37+
eval exec sidemantic serve $SERVE_ARGS "$@"
3138
;;
3239
mcp)
33-
exec sidemantic mcp-serve $ARGS "$@"
40+
eval exec sidemantic mcp-serve $MCP_ARGS "$@"
3441
;;
3542
both)
36-
# Start PG server in background, MCP on stdio in foreground
37-
sidemantic serve --host 0.0.0.0 $ARGS $SERVE_ARGS &
43+
eval sidemantic serve $SERVE_ARGS &
3844
SERVE_PID=$!
3945
trap "kill $SERVE_PID 2>/dev/null" EXIT
40-
exec sidemantic mcp-serve $ARGS "$@"
46+
eval exec sidemantic mcp-serve $MCP_ARGS "$@"
4147
;;
4248
*)
4349
echo "Unknown SIDEMANTIC_MODE: $MODE (use serve, mcp, or both)" >&2

0 commit comments

Comments
 (0)