aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-12-13 17:18:01 +0800
committerGitHub <noreply@github.com>2024-12-13 17:18:01 +0800
commitd692625662c0f7262dab9af049e0adb33ce2e46e (patch)
tree56a46488e9f3271a20d62e5886644e6978d2bf8d /scripts
parent8ace93beb813a431b4f26e277f8c0bcebdfa8511 (diff)
downloadllm-functions-docker-d692625662c0f7262dab9af049e0adb33ce2e46e.tar.gz
refactor: add docs and update scripts (#150)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create-tool.sh2
-rwxr-xr-xscripts/mcp.sh25
-rwxr-xr-xscripts/run-mcp-tool.sh2
3 files changed, 15 insertions, 14 deletions
diff --git a/scripts/create-tool.sh b/scripts/create-tool.sh
index c335934..395cac7 100755
--- a/scripts/create-tool.sh
+++ b/scripts/create-tool.sh
@@ -8,7 +8,7 @@ set -e
#
# @option --description <text> The tool description
# @flag --force Override the exist tool file
-# @arg name! The script file name.
+# @arg name! The script file name
# @arg params* The script parameters
main() {
diff --git a/scripts/mcp.sh b/scripts/mcp.sh
index bb83aa3..fecf52a 100755
--- a/scripts/mcp.sh
+++ b/scripts/mcp.sh
@@ -8,7 +8,8 @@ MCP_JSON_PATH="$ROOT_DIR/mcp.json"
FUNCTIONS_JSON_PATH="$ROOT_DIR/functions.json"
MCP_BRIDGE_PORT="${MCP_BRIDGE_PORT:-8808}"
-# @cmd Start/Restart mcp bridge server
+# @cmd Start/restart the mcp bridge server
+# @alias restart
start() {
if [[ ! -f "$MCP_JSON_PATH" ]]; then
_die "error: not found mcp.json"
@@ -29,7 +30,7 @@ start() {
build-bin
}
-# @cmd Stop mcp bridge server
+# @cmd Stop the mcp bridge server
stop() {
pid="$(get-server-pid)"
if [[ -n "$pid" ]]; then
@@ -42,12 +43,12 @@ stop() {
"$0" recovery-functions -S
}
-# @cmd Run the tool
+# @cmd Run the mcp tool
# @arg tool![`_choice_tool`] The tool name
# @arg json The json data
run@tool() {
if [[ -z "$argc_json" ]]; then
- declaration="$(build-declarations | jq --arg tool "$argc_tool" -r '.[] | select(.name == $tool)')"
+ declaration="$(generate-declarations | jq --arg tool "$argc_tool" -r '.[] | select(.name == $tool)')"
if [[ -n "$declaration" ]]; then
_ask_json_data "$declaration"
fi
@@ -58,7 +59,7 @@ run@tool() {
bash "$ROOT_DIR/scripts/run-mcp-tool.sh" "$argc_tool" "$argc_json"
}
-# @cmd Show logs
+# @cmd Show the logs
# @flag -f --follow Follow mode
logs() {
args=""
@@ -72,7 +73,7 @@ logs() {
# @cmd Build tools to bin
build-bin() {
- tools=( $(build-declarations | jq -r '.[].name') )
+ tools=( $(generate-declarations | jq -r '.[].name') )
for tool in "${tools[@]}"; do
if _is_win; then
bin_file="$BIN_DIR/$tool.cmd"
@@ -88,7 +89,7 @@ build-bin() {
# @cmd Merge mcp tools into functions.json
# @flag -S --save Save to functions.json
merge-functions() {
- result="$(jq --argjson json1 "$("$0" recovery-functions)" --argjson json2 "$(build-declarations)" -n '($json1 + $json2)')"
+ result="$(jq --argjson json1 "$("$0" recovery-functions)" --argjson json2 "$(generate-declarations)" -n '($json1 + $json2)')"
if [[ -n "$argc_save" ]]; then
printf "%s" "$result" > "$FUNCTIONS_JSON_PATH"
else
@@ -111,12 +112,12 @@ recovery-functions() {
fi
}
-# @cmd Build tools to bin
-build-declarations() {
+# @cmd Generate function declarations for the mcp tools
+generate-declarations() {
curl -sS http://localhost:$MCP_BRIDGE_PORT/tools | jq '.[] |= . + {mcp: true}'
}
-# @cmd Wait for mcp bridge server to ready
+# @cmd Wait for the mcp bridge server to ready
wait-for-server() {
while true; do
if [[ "$(curl -fsS http://localhost:$MCP_BRIDGE_PORT/health 2>&1)" == "OK" ]]; then
@@ -126,7 +127,7 @@ wait-for-server() {
done
}
-# @cmd
+# @cmd Get the server pid
get-server-pid() {
curl -fsSL http://localhost:$MCP_BRIDGE_PORT/pid 2>/dev/null || true
}
@@ -173,7 +174,7 @@ _is_win() {
}
_choice_tool() {
- build-declarations | jq -r '.[].name'
+ generate-declarations | jq -r '.[].name'
}
_die() {
diff --git a/scripts/run-mcp-tool.sh b/scripts/run-mcp-tool.sh
index fb987e1..8f3a5c0 100755
--- a/scripts/run-mcp-tool.sh
+++ b/scripts/run-mcp-tool.sh
@@ -74,7 +74,7 @@ run() {
if [[ -t 1 ]] && [[ "$skip_confirm" -ne 1 ]]; then
read -r -p "Are you sure you want to continue? [Y/n] " ans
if [[ "$ans" == "N" || "$ans" == "n" ]]; then
- echo "error: canceld!" 2>&1
+ echo "error: canceled!" 2>&1
exit 1
fi
fi