|
| 1 | +name: IntentProbe MCP/tool scanner |
| 2 | +author: mcpware |
| 3 | +description: Scan MCP servers, agent tools, and skills with the local IntentProbe activation scanner. |
| 4 | + |
| 5 | +branding: |
| 6 | + icon: shield |
| 7 | + color: blue |
| 8 | + |
| 9 | +inputs: |
| 10 | + paths: |
| 11 | + description: Newline-separated paths or shell globs to scan. |
| 12 | + required: false |
| 13 | + default: "." |
| 14 | + fail-on: |
| 15 | + description: Minimum decision that fails the job. One of never, warn, block, quarantine. |
| 16 | + required: false |
| 17 | + default: block |
| 18 | + format: |
| 19 | + description: Output format from intentprobe scan-path. One of summary or json. |
| 20 | + required: false |
| 21 | + default: summary |
| 22 | + intentprobe-version: |
| 23 | + description: PyPI intentprobe version to install. |
| 24 | + required: false |
| 25 | + default: 0.1.4 |
| 26 | + python-version: |
| 27 | + description: Python version used by the action. |
| 28 | + required: false |
| 29 | + default: "3.11" |
| 30 | + max-files: |
| 31 | + description: Maximum candidate files read under each scanned directory. |
| 32 | + required: false |
| 33 | + default: "200" |
| 34 | + max-file-bytes: |
| 35 | + description: Maximum bytes read from each candidate file. |
| 36 | + required: false |
| 37 | + default: "200000" |
| 38 | + local-files-only: |
| 39 | + description: Set true to require the model to already exist in the runner cache. |
| 40 | + required: false |
| 41 | + default: "false" |
| 42 | + |
| 43 | +runs: |
| 44 | + using: composite |
| 45 | + steps: |
| 46 | + - name: Set up Python |
| 47 | + uses: actions/setup-python@v6 |
| 48 | + with: |
| 49 | + python-version: ${{ inputs.python-version }} |
| 50 | + |
| 51 | + - name: Cache Hugging Face model files |
| 52 | + uses: actions/cache@v4 |
| 53 | + with: |
| 54 | + path: | |
| 55 | + ~/.cache/huggingface/hub |
| 56 | + ~/.cache/torch |
| 57 | + key: ${{ runner.os }}-intentprobe-${{ inputs.intentprobe-version }}-qwen25-05b-v1 |
| 58 | + |
| 59 | + - name: Install IntentProbe |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + python -m pip install --upgrade pip |
| 64 | + python -m pip install "intentprobe==${{ inputs.intentprobe-version }}" |
| 65 | +
|
| 66 | + - name: Scan MCP/tool targets |
| 67 | + shell: bash |
| 68 | + env: |
| 69 | + INTENTPROBE_PATHS: ${{ inputs.paths }} |
| 70 | + INTENTPROBE_FAIL_ON: ${{ inputs.fail-on }} |
| 71 | + INTENTPROBE_FORMAT: ${{ inputs.format }} |
| 72 | + INTENTPROBE_MAX_FILES: ${{ inputs.max-files }} |
| 73 | + INTENTPROBE_MAX_FILE_BYTES: ${{ inputs.max-file-bytes }} |
| 74 | + INTENTPROBE_LOCAL_FILES_ONLY: ${{ inputs.local-files-only }} |
| 75 | + run: | |
| 76 | + set -euo pipefail |
| 77 | +
|
| 78 | + case "$INTENTPROBE_FAIL_ON" in |
| 79 | + never|warn|block|quarantine) ;; |
| 80 | + *) echo "::error::fail-on must be one of never, warn, block, quarantine"; exit 1 ;; |
| 81 | + esac |
| 82 | +
|
| 83 | + case "$INTENTPROBE_FORMAT" in |
| 84 | + summary|json) ;; |
| 85 | + *) echo "::error::format must be summary or json"; exit 1 ;; |
| 86 | + esac |
| 87 | +
|
| 88 | + case "$INTENTPROBE_LOCAL_FILES_ONLY" in |
| 89 | + true|false) ;; |
| 90 | + *) echo "::error::local-files-only must be true or false"; exit 1 ;; |
| 91 | + esac |
| 92 | +
|
| 93 | + scan_one() { |
| 94 | + local target="$1" |
| 95 | + local status |
| 96 | + local args=( |
| 97 | + scan-path "$target" |
| 98 | + --format "$INTENTPROBE_FORMAT" |
| 99 | + --fail-on "$INTENTPROBE_FAIL_ON" |
| 100 | + --max-files "$INTENTPROBE_MAX_FILES" |
| 101 | + --max-file-bytes "$INTENTPROBE_MAX_FILE_BYTES" |
| 102 | + ) |
| 103 | +
|
| 104 | + if [ "$INTENTPROBE_LOCAL_FILES_ONLY" = "true" ]; then |
| 105 | + args+=(--local-files-only) |
| 106 | + fi |
| 107 | +
|
| 108 | + echo "::group::intentprobe scan-path $target" |
| 109 | + set +e |
| 110 | + intentprobe "${args[@]}" |
| 111 | + status=$? |
| 112 | + set -e |
| 113 | + echo "::endgroup::" |
| 114 | + return "$status" |
| 115 | + } |
| 116 | +
|
| 117 | + targets_file="$(mktemp)" |
| 118 | + printf '%s\n' "$INTENTPROBE_PATHS" > "$targets_file" |
| 119 | +
|
| 120 | + scanned=0 |
| 121 | + while IFS= read -r target || [ -n "$target" ]; do |
| 122 | + target="${target#"${target%%[![:space:]]*}"}" |
| 123 | + target="${target%"${target##*[![:space:]]}"}" |
| 124 | +
|
| 125 | + [ -z "$target" ] && continue |
| 126 | + [[ "$target" == \#* ]] && continue |
| 127 | +
|
| 128 | + if [ -e "$target" ]; then |
| 129 | + scanned=$((scanned + 1)) |
| 130 | + scan_one "$target" |
| 131 | + continue |
| 132 | + fi |
| 133 | +
|
| 134 | + if compgen -G "$target" > /dev/null; then |
| 135 | + while IFS= read -r match; do |
| 136 | + [ -z "$match" ] && continue |
| 137 | + scanned=$((scanned + 1)) |
| 138 | + scan_one "$match" |
| 139 | + done < <(compgen -G "$target") |
| 140 | + else |
| 141 | + echo "::warning::IntentProbe target not found: $target" |
| 142 | + fi |
| 143 | + done < "$targets_file" |
| 144 | +
|
| 145 | + if [ "$scanned" -eq 0 ]; then |
| 146 | + echo "::error::IntentProbe did not scan any targets. Check the paths input." |
| 147 | + exit 1 |
| 148 | + fi |
0 commit comments