Skip to content

Commit 0f3577e

Browse files
ryzizubclaude
andauthored
fix: auto-allow Very Good CLI MCP tools in all run modes (#120)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 52c9a8d commit 0f3577e

5 files changed

Lines changed: 28 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ These run **when a session begins**:
113113

114114
These run **before** a tool call is executed:
115115

116-
- `mcp__very-good-cli__.*` matcher → `check-vgv-cli.sh`validates that the Very Good CLI is installed and at version >= 1.3.0; exits 2 on failure (blocking)
116+
- `mcp__.*very-good-cli__.*` matcher → `check-vgv-cli.sh`auto-approves the Very Good CLI MCP tool call by returning a PreToolUse `allow` decision, so it is always permitted regardless of run mode (interactive, headless, or `skipAutoPermissionPrompt`) and never dead-ends when the tool isn't on `permissions.allow`; denies with an install/upgrade message if the CLI is missing or < 1.3.0. The `.*` in the matcher covers both the bare `mcp__very-good-cli__*` server (repo-root `.mcp.json`) and the plugin-namespaced `mcp__plugin_<plugin>_very-good-cli__*` form used when installed from a marketplace
117117
- `Bash` matcher → `block-cli-workarounds.sh` — prevents direct CLI bypass of VGV CLI commands through the Bash tool; exits 2 on failure (blocking)
118118

119119
Both PreToolUse scripts share common utilities from `vgv-cli-common.sh`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ This plugin includes SessionStart, PreToolUse, and PostToolUse hooks that valida
6161
| Hook | Trigger | Behavior |
6262
| ---- | ------- | -------- |
6363
| **Warn Missing MCP** (`warn-missing-mcp.sh`) | SessionStart | Warns if the Very Good CLI is missing or older than 1.3.0; non-blocking |
64-
| **Check VGV CLI** (`check-vgv-cli.sh`) | PreToolUse (`mcp__very-good-cli__.*`) | Validates the Very Good CLI is installed and ≥ 1.3.0; exits 2 on failure (blocking) |
64+
| **Check VGV CLI** (`check-vgv-cli.sh`) | PreToolUse (`mcp__.*very-good-cli__.*`) | Auto-approves Very Good CLI MCP tool calls in every run mode via a PreToolUse `allow` decision, so they never dead-end when the tool isn't on `permissions.allow` (including under `skipAutoPermissionPrompt`); denies with an install/upgrade message if the CLI is missing or < 1.3.0 |
6565
| **Block CLI Workarounds** (`block-cli-workarounds.sh`) | PreToolUse (`Bash`) | Blocks direct CLI bypass of Very Good CLI commands through the Bash tool; exits 2 on failure (blocking) |
6666
| **Analyze** (`analyze.sh`) | PostToolUse (`Edit`/`Write`) | Runs `dart analyze` on the modified `.dart` file; exits 2 on failure (blocking — Claude must fix issues before continuing) |
6767
| **Format** (`format.sh`) | PostToolUse (`Edit`/`Write`) | Runs `dart format` on the modified `.dart` file; always exits 0 (non-blocking — formatting is applied silently) |

hooks/hooks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"PreToolUse": [
1616
{
17-
"matcher": "mcp__very-good-cli__.*",
17+
"matcher": "mcp__.*very-good-cli__.*",
1818
"hooks": [
1919
{
2020
"type": "command",

hooks/scripts/check-vgv-cli.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
2-
# PreToolUse hook: verify very_good_cli is installed before
3-
# allowing Very Good CLI MCP tool calls.
2+
# PreToolUse hook: gate Very Good CLI MCP tool calls.
3+
# When the CLI is installed and new enough, auto-approve the call so it is
4+
# always allowed regardless of run mode; otherwise deny with an install/
5+
# upgrade message instead of letting the call fail silently.
46

57
if ! command -v jq &>/dev/null; then
68
echo "jq is required for check-vgv-cli hook but not found" >&2
@@ -21,5 +23,7 @@ case "$cli_status" in
2123
;;
2224
esac
2325

24-
# Version OK
25-
exit 0
26+
# Version OK — auto-approve so the Very Good CLI MCP tool is always allowed,
27+
# even under skipAutoPermissionPrompt where a non-allowlisted tool would
28+
# otherwise fail closed and silently.
29+
allow "Very Good CLI >= ${MIN_VERSION} verified; auto-approving Very Good CLI MCP tool call."

hooks/scripts/vgv-cli-common.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ deny() {
1919
exit 0
2020
}
2121

22+
# Auto-approve the tool call, skipping the interactive permission prompt.
23+
# A PreToolUse "allow" fires before the permission-mode check, so the call
24+
# proceeds in every run mode (interactive, headless, skipAutoPermissionPrompt).
25+
# Explicit deny/ask rules and managed deny lists still take precedence.
26+
allow() {
27+
jq -n \
28+
--arg reason "$1" \
29+
'{
30+
hookSpecificOutput: {
31+
hookEventName: "PreToolUse",
32+
permissionDecision: "allow",
33+
permissionDecisionReason: $reason
34+
}
35+
}'
36+
exit 0
37+
}
38+
2239
# Check Very Good CLI availability and version.
2340
# Returns: "ok", "not_installed", or "outdated:<version>"
2441
check_vgv_cli() {

0 commit comments

Comments
 (0)