Skip to content

Commit 50ee642

Browse files
authored
feat(mcp): auto install deps before starting mcp bridge server (#161)
1 parent fad2c60 commit 50ee642

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/mcp.sh

+10-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44
ROOT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/.." &> /dev/null && pwd)"
55
BIN_DIR="$ROOT_DIR/bin"
66
MCP_DIR="$ROOT_DIR/cache/__mcp__"
7+
MCP_LOG_FILE="$MCP_DIR/mcp-bridge.log"
78
MCP_JSON_PATH="$ROOT_DIR/mcp.json"
89
FUNCTIONS_JSON_PATH="$ROOT_DIR/functions.json"
910
MCP_BRIDGE_PORT="${MCP_BRIDGE_PORT:-8808}"
@@ -23,7 +24,9 @@ start() {
2324
llm_functions_dir="$(cygpath -w "$llm_functions_dir")"
2425
fi
2526
echo "Start MCP Bridge server..."
26-
nohup node "$index_js" "$llm_functions_dir" > "$MCP_DIR/mcp-bridge.log" 2>&1 &
27+
echo "Install node dependencies..." > "$MCP_LOG_FILE"
28+
npm install --prefix "$ROOT_DIR/mcp/bridge" 1>/dev/null 2>> "$MCP_LOG_FILE"
29+
nohup node "$index_js" "$llm_functions_dir" >> "$MCP_LOG_FILE" 2>&1 &
2730
wait-for-server
2831
echo "Merge MCP tools into functions.json"
2932
"$0" merge-functions -S
@@ -62,12 +65,13 @@ run@tool() {
6265
# @cmd Show the logs
6366
# @flag -f --follow Follow mode
6467
logs() {
65-
args=""
66-
if [[ -n "$argc_follow" ]]; then
67-
args="$args -f"
68+
if [[ ! -f "$MCP_LOG_FILE" ]]; then
69+
_die "error: not found log file at '$MCP_LOG_FILE'"
6870
fi
69-
if [[ -f "$MCP_DIR/mcp-bridge.log" ]]; then
70-
tail $args "$MCP_DIR/mcp-bridge.log"
71+
if [[ -n "$argc_follow" ]]; then
72+
tail -f "$MCP_LOG_FILE"
73+
else
74+
cat "$MCP_LOG_FILE"
7175
fi
7276
}
7377

0 commit comments

Comments
 (0)