Skip to content

Commit

Permalink
feat(mcp): add LLM_MCP_NEED_CONFIRM and LLM_MCP_SKIP_CONFIRM (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Dec 13, 2024
1 parent 8e8b2f7 commit 8ace93b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

## Provided by users

| Name | Description |
| ------------------ | --------------------------------------------------------------------------------------------- |
| `LLM_DUMP_RESULTS` | Controls whether to print the execution results of the tool, e.g. `get_current_weather\|fs.*\|todo:.*`, `.*` |
| Name | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------ |
| `LLM_DUMP_RESULTS` | Controls whether to print the execution results of the tool, e.g. `get_current_weather\|fs.*\|todo:.*`, `.*` |
| `LLM_MCP_NEED_CONFIRM`| Controls whether to prompt for confirmation before executing certain tools, e.g., `git_commit\|git_reset`, `.*` . |
| `LLM_MCP_SKIP_CONFIRM`| Controls whether to bypass confirmation requests for certain tools, e.g., `git_status\|git_diff.*`, `.*` . |
19 changes: 19 additions & 0 deletions scripts/run-mcp-tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' \
Expand Down

0 comments on commit 8ace93b

Please sign in to comment.