Skip to content

Commit 23fe202

Browse files
committed
fix: resolve docker compose configuration and symlink issues
- Fix docker compose commands to consistently use -f flag with config path - Improve main executable to better handle installation paths - Replace symlink with actual file copy to prevent absolute path issues
1 parent e1d63c7 commit 23fe202

File tree

3 files changed

+140
-5
lines changed

3 files changed

+140
-5
lines changed

files-db-mcp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,19 @@
44
# Get the script directory (where this script is located)
55
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
66

7-
# Execute the run script
8-
exec "$SCRIPT_DIR/scripts/run.sh" "$@"
7+
# Check if the local run script exists
8+
if [ -f "$SCRIPT_DIR/scripts/run.sh" ]; then
9+
# Execute the run script
10+
exec "$SCRIPT_DIR/scripts/run.sh" "$@"
11+
else
12+
# Check if installed in default location
13+
if [ -f "$HOME/.files-db-mcp/scripts/run.sh" ]; then
14+
echo "Using installed scripts from $HOME/.files-db-mcp"
15+
exec "$HOME/.files-db-mcp/scripts/run.sh" "$@"
16+
else
17+
echo "Error: Cannot find run.sh script"
18+
echo "Please reinstall files-db-mcp:"
19+
echo "curl -fsSL https://raw.githubusercontent.com/randomm/files-db-mcp/main/install/install.sh | bash"
20+
exit 1
21+
fi
22+
fi

run.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

run.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
# Startup script for Files-DB-MCP
3+
4+
# Stop on error
5+
set -e
6+
7+
# Detect project directory
8+
PROJECT_DIR=$(pwd)
9+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
10+
11+
# Print banner
12+
echo "=================================================="
13+
echo " Files-DB-MCP - Vector Search for Code Projects "
14+
echo "=================================================="
15+
echo
16+
echo "Starting Files-DB-MCP for project: $PROJECT_DIR"
17+
echo
18+
19+
# Check if Docker and Docker Compose are installed
20+
if ! command -v docker >/dev/null 2>&1; then
21+
echo "Error: Docker is not installed or not in PATH"
22+
echo "Please install Docker: https://docs.docker.com/get-docker/"
23+
exit 1
24+
fi
25+
26+
if ! docker compose version >/dev/null 2>&1; then
27+
echo "Error: Docker Compose is not installed or not in PATH"
28+
echo "Please install Docker Compose: https://docs.docker.com/compose/install/"
29+
exit 1
30+
fi
31+
32+
# Set environment variables
33+
export PROJECT_DIR=$PROJECT_DIR
34+
35+
# Get the repository base directory
36+
BASE_DIR="$(dirname "$SCRIPT_DIR")"
37+
38+
# Stop and remove any existing containers from previous runs
39+
echo "Cleaning up any existing containers..."
40+
if [ "$PROJECT_DIR" != "$BASE_DIR" ]; then
41+
# Using absolute path to docker-compose.yml
42+
docker compose -f "$BASE_DIR/docker-compose.yml" down
43+
else
44+
# Running from project directory
45+
docker compose down
46+
fi
47+
48+
# Check if docker-compose.yml exists in the base directory
49+
if [ ! -f "$BASE_DIR/docker-compose.yml" ]; then
50+
echo "Error: docker-compose.yml not found at $BASE_DIR/docker-compose.yml"
51+
echo "This usually happens when the installation paths are incorrect."
52+
53+
# Check the common installation directory
54+
if [ -f "$HOME/.files-db-mcp/docker-compose.yml" ]; then
55+
echo "Found docker-compose.yml in the default installation directory."
56+
BASE_DIR="$HOME/.files-db-mcp"
57+
echo "Using $BASE_DIR as the base directory."
58+
else
59+
echo "Could not find docker-compose.yml in the expected locations."
60+
echo "Please make sure files-db-mcp is properly installed."
61+
exit 1
62+
fi
63+
fi
64+
65+
# Run Docker Compose with proper timeout for startup
66+
echo "Starting Docker Compose services..."
67+
# Use the docker-compose.yml from the base directory
68+
COMPOSE_HTTP_TIMEOUT=300 docker compose -f "$BASE_DIR/docker-compose.yml" up --build -d
69+
70+
# Wait for services to start
71+
echo
72+
echo "Files-DB-MCP is starting up..."
73+
echo "Waiting for services to initialize..."
74+
75+
# Get the actual container names as they might be different
76+
MCP_CONTAINER=$(docker compose -f "$BASE_DIR/docker-compose.yml" ps -q files-db-mcp)
77+
VECTOR_DB_CONTAINER=$(docker compose -f "$BASE_DIR/docker-compose.yml" ps -q vector-db)
78+
79+
echo "Container IDs: MCP=$MCP_CONTAINER, Vector DB=$VECTOR_DB_CONTAINER"
80+
81+
# Wait up to 2 minutes for MCP to become healthy
82+
timeout=120
83+
interval=5
84+
elapsed=0
85+
86+
echo "Waiting for MCP service to become healthy..."
87+
while [ $elapsed -lt $timeout ]; do
88+
# Check if files-db-mcp is healthy
89+
if [ ! -z "$MCP_CONTAINER" ]; then
90+
MCP_STATUS=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no health check{{end}}' "$MCP_CONTAINER" 2>/dev/null || echo "error")
91+
echo -n "MCP Status: $MCP_STATUS"
92+
echo
93+
94+
if [ "$MCP_STATUS" = "healthy" ]; then
95+
echo "MCP service is healthy!"
96+
break
97+
fi
98+
else
99+
echo "MCP container not found"
100+
fi
101+
102+
sleep $interval
103+
elapsed=$((elapsed + interval))
104+
echo -n "."
105+
done
106+
107+
if [ $elapsed -ge $timeout ]; then
108+
echo "Timeout waiting for MCP service to become healthy."
109+
echo "Check MCP container logs with: docker logs $MCP_CONTAINER"
110+
echo "Check Vector DB container logs with: docker logs $VECTOR_DB_CONTAINER"
111+
exit 1
112+
fi
113+
114+
echo
115+
echo "Files-DB-MCP is ready!"
116+
echo "Indexing is running in the background."
117+
echo "You can now connect to the MCP interface at http://localhost:3000"
118+
echo
119+
echo "To check indexing status: curl http://localhost:3000/health"
120+
echo "To stop the service: docker compose down"
121+
echo
122+
echo "Services are running in the background. Happy coding!"

scripts/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ echo "Files-DB-MCP is starting up..."
7373
echo "Waiting for services to initialize..."
7474

7575
# Get the actual container names as they might be different
76-
MCP_CONTAINER=$(docker compose ps -q files-db-mcp)
77-
VECTOR_DB_CONTAINER=$(docker compose ps -q vector-db)
76+
MCP_CONTAINER=$(docker compose -f "$BASE_DIR/docker-compose.yml" ps -q files-db-mcp)
77+
VECTOR_DB_CONTAINER=$(docker compose -f "$BASE_DIR/docker-compose.yml" ps -q vector-db)
7878

7979
echo "Container IDs: MCP=$MCP_CONTAINER, Vector DB=$VECTOR_DB_CONTAINER"
8080

0 commit comments

Comments
 (0)