From 8ace93beb813a431b4f26e277f8c0bcebdfa8511 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 13 Dec 2024 08:20:51 +0800 Subject: feat(mcp): add LLM_MCP_NEED_CONFIRM and LLM_MCP_SKIP_CONFIRM (#149) --- scripts/run-mcp-tool.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'scripts') diff --git a/scripts/run-mcp-tool.sh b/scripts/run-mcp-tool.sh index 08beafd..fb987e1 100755 --- a/scripts/run-mcp-tool.sh +++ b/scripts/run-mcp-tool.sh @@ -60,6 +60,25 @@ run() { is_temp_llm_output=1 export LLM_OUTPUT="$(mktemp)" fi + + if [[ -n "$LLM_MCP_SKIP_CONFIRM" ]]; then + if grep -q -w -E "$LLM_MCP_SKIP_CONFIRM" <<<"$tool_name"; then + skip_confirm=1 + fi + fi + if [[ -n "$LLM_MCP_NEED_CONFIRM" ]]; then + if grep -q -w -E "$LLM_MCP_NEED_CONFIRM" <<<"$tool_name"; then + skip_confirm=0 + fi + fi + 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 + exit 1 + fi + fi + curl -sS "http://localhost:${MCP_BRIDGE_PORT:-8808}/tools/$tool_name" \ -X POST \ -H 'content-type: application/json' \ -- cgit v1.2.3