Local LLM Guard for Ollama / llama.cpp

io.github.AIops-tools由 GitHub 帳號 AIops-tools 發布v0.14.1更新於 Nov 8, 2026

Governed local-LLM observability: model policy, prompt scanner, capture proxy, 21 tools.

已驗證STDIO僅桌面安全與監控AI 與機器學習

概覽

AI 產生的概覽

稽核與治理本機 LLM 執行環境(Ollama、llama.cpp、LM Studio、vLLM):模型清單、提示詞掃描、政策攔阻與稽核日誌。

可以做什麼
  • 檢視執行環境狀態:列出已安裝與已載入模型、VRAM 用量、模型詳情、服務狀態及允許/拒絕政策判定
  • 核對來源:將已安裝模型的摘要與釘選值比對並標示漂移
  • 離線掃描提示詞:辨識金鑰、個人資料、原始碼外洩與越獄特徵,回傳去識別化結果與風險等級
  • 受控生成:先掃描、政策檢查並記錄,再呼叫模型,高風險或被禁用的模型會被攔阻
  • 管理模型與政策:拉取、移除、卸載模型,設定允許/拒絕清單並釘選摘要,可逆寫入會記錄復原權杖
  • 檢視用量與異常:查詢用量日誌,彙整影子模型、摘要漂移與被攔阻的提示詞,並提供代理設定指引
適用情境
適合在自己電腦上執行本機模型、希望助理盤點模型、限定可用模型、在提示詞送進模型前篩檢機密或注入內容,並為每次呼叫留下稽核紀錄的情境。
執行需求
以本機 stdio 程序執行,從 PyPI 安裝 ai-guardian-aiops(指令名為 ai-guardian),建議使用 uv 或 pipx,外掛方式安裝需 PATH 中有 uvx。需要可連線的本機執行環境(Ollama、llama.cpp、LM Studio 或 vLLM),透過 init 精靈寫入 config.yaml。僅當目標存有權杖時才需要 AI_GUARDIAN_AIOPS_MASTER_PASSWORD;資料存放於 ~/.ai-guardian。
安裝前請注意
寫入是真實的:remove_model、pull_model、unload_model 及允許/拒絕清單變更會作用於模型庫,而治理層只記錄不授權,應限制可用工具或執行環境帳號權限。主密碼環境變數可被同一個 shell 的其他程序讀取並留在歷史紀錄中。稽核與用量資料庫寫在本機,擷取代理只是收斂點,用戶端直連執行環境連接埠即可繞過。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Local LLM Guard for Ollama / llama.cpp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

AI Guardian

Audit availability: Real writes require a committed pending audit row and stop before contacting the platform if storage is unavailable. Reads and previews may continue with a warning; new audit rows store outcome summaries rather than full responses.

Disclaimer: Community-maintained open-source project. Not affiliated with, endorsed by, or sponsored by Ollama, IGEL, or any AI-security vendor. Product and trademark names belong to their owners. MIT licensed.

Governed observability + governance for on-endpoint local LLMs. It lets you observe + audit what your local models are actually fed, and gate what leaves in a prompt — the complement to IGEL AI Armor. AI Armor governs whether a local model may run on the endpoint; ai-guardian records what it did and gates what goes into the prompt (secrets, PII, source, jailbreaks) plus which model may serve it. Self-contained: it talks to each runtime's REST API and needs nothing beyond httpx and the MCP SDK. v0.1 provides opt-in route-through content governance, plus a transparent capture proxy for clients that did not opt in.

Supported runtimes

One tool, several local runtimes, selected per target by a runtime field in config.yaml (the init wizard asks). Ollama uses its native API; the other three share one OpenAI-compatible transport (/v1/models + /v1/chat/completions).

RuntimeruntimeDefault portList / policyScan + route-through guardProvenance
Ollamaollama11434✅✅digest (content hash — strong)
llama.cpp (llama-server)llamacpp8080✅✅props — /props model path/size → pinnable id
LM Studiolmstudio1234✅✅id only — weaker; pins report unverifiable
vLLM (local single-node)vllm8000✅✅id only — weaker; pins report unverifiable

The allow/deny model policy, the deterministic prompt scanner, the route-through guard (guarded_generate / observe_chat), provenance drift, and doctor work across all runtimes. Model lifecycle writes (pull / remove / unload) are Ollama-only — the OpenAI-compatible servers load a model at startup and expose no lifecycle endpoint, so those writes are refused with a clear message.

Provenance honesty: only Ollama (content digest) and llama.cpp (a /props-derived path/size identity) expose something to pin. LM Studio and vLLM expose only a model id, so a pinned digest is reported unverifiable rather than a false DRIFT.

vLLM here is a LOCAL endpoint-guarding use case. GPU inference-cluster operations (autoscale, drain, Ray Serve/Jobs, model lifecycle at fleet scale) belong to a different tool in the line — GPU cluster ops → inference-aiops.

What it does

Ollama persists no queryable prompt/response history — conversational context is client-supplied on every request. So ai-guardian observes on two fronts:

  • Passive inventory / state auditing — over /api/tags, /api/ps, /api/show, /api/version: what models are installed and running, their VRAM residency, license/params/capabilities, and their provenance digests. Every model is annotated with an allow/deny policy verdict, so shadow (unsanctioned) models show allowed: false.
  • Opt-in route-through content governance — callers send a prompt through ai-guardian (guarded_generate / observe_chat). It scans the text (secrets / PII / source / jailbreak), checks the model against policy, records the interaction to its own usage log (~/.ai-guardian/usage.db), and only then calls Ollama — blocking when the risk band is too high or the model is disallowed. The raw prompt is never stored (only its length + redacted findings).

Now available (ai-guardian proxy serve): a transparent capture proxy that applies the same scan + model policy + recording to traffic from clients that never opted in — point them at the proxy instead of the runtime. It inspects requests and streams responses through untouched, and it is a chokepoint, not an enforcement boundary: a client that can still reach the runtime's real port bypasses it entirely. proxy_guidance returns the command and that caveat; the CLI prints it on every start.

Key features

  • Deterministic, offline prompt scanner — no I/O, no network, so it is fully testable offline. Flags secrets (AWS AKIA, private-key blocks, GitHub / Slack / OpenAI / Google tokens, JWTs, assigned api_key=…, high-entropy fallback), PII (email, US SSN, credit card with a Luhn check), source/config-leak heuristics, and jailbreak / prompt-injection signatures — rolled up into a weighted risk band (low / medium / high / critical; any critical dominates). Findings are redacted — the scanner never re-emits the secret it caught.
  • Model allow/deny policy (shell-glob patterns) so shadow / unsanctioned models surface as allowed: false, plus provenance digest pinning to flag a model whose digest drifted (re-pulled / tampered).
  • Route-through guard — guarded_generate / observe_chat scan + policy-gate
    • record + run-if-allowed, blocking on risk-band >= block_threshold (default high) or a disallowed model.
  • Vendored governance harness — audit log, token/runaway budget guard, descriptive risk tiers, and undo-token recording, bundled in the package (no external dependency).
  • Highly self-testable — Ollama is free + local for the API parts; the scanner, policy, and risk-band are pure deterministic offline logic.

What this tool does, and does not, decide

It delivers local-LLM observability and operations — reads and writes — accurately, and records every one of them. It does not decide whether a write to the model estate is allowed to happen. That is the agent's judgement, or the permission of the host and account you run it under: point it at a runtime the account cannot administer — an Ollama daemon whose model store the user can't modify, or an endpoint the agent reaches read-only — and the writes fail at the runtime, the place that actually owns the permission. Simplest of all, hand the connecting agent only the scan/observe tools.

So the harness has no read-only switch, no deny-rules file, and no approval gate to configure. (Content governance is a separate, product-level thing that stays: the model allow/deny policy and the guarded_generate block threshold still scan and gate what a model is asked to do.) The one thing the harness guarantees is that nothing is silent: every call, over MCP and over the CLI alike, lands an audit row in ~/.ai-guardian/audit.db, and destructive writes still capture their before-state and record an inverse where one exists.

Each tool declares a risk_level, kept in agreement with its [READ]/[WRITE] documentation tag by a test, and carried into the audit row as a descriptive tier — so a reviewer can see at a glance that a row was a high-risk delete. It is a label, not a gate.

Running a smaller / local model? See agent-guardrails.md — it lists the guardrails this tool now enforces for you (so you don't spend prompt budget restating them) and gives a ready-made system prompt for what's left.

Capability matrix (21 MCP tools)

Reads (11)

ToolRiskWhat it returns
list_modelslowinstalled models, each with the allow/deny verdict (shadow → allowed:false)
running_modelslowloaded models: VRAM footprint + residency expiry
model_detailslowlicense / parameters / capabilities for one model
server_statuslowOllama reachability + version
vram_usagelowtotal VRAM used by loaded models; flag over-budget
policy_viewlowcurrent allow/deny policy + provenance digest pins
model_provenanceloweach installed digest vs its pin; flag drift
scan_promptlowpure text scan → findings + weighted risk band (no model call)
usage_eventslowquery the observed-usage log
anomaly_reportlowrollup: shadow models, digest drift, high-risk + blocked prompts
proxy_guidancelowthe proxy serve command + the client change, and the explicit caveat that the proxy is a chokepoint, not an enforcement boundary; writes nothing, starts nothing

Writes (8)

ToolRiskUndo / safety
pull_modelmediumrefused if it violates policy
remove_modelhighdry-run + undo (re-pull)
unload_modelmediumevict from VRAM (keep_alive:0)
set_model_allowlistmediumundo → prior allowlist
set_model_denylistmediumundo → prior denylist
pin_model_digestmediumpin a model's expected provenance digest
guarded_generatemediumthe route-through guard: scan + policy-gate + record + run-if-allowed
observe_chatmediumsame, for /api/chat messages

Undo (2)

ToolRiskWhat it does
undo_listlowlist recorded undo tokens
undo_applymediumreplay a recorded inverse descriptor

Risk-band gating: guarded_generate / observe_chat block when the prompt's risk band >= block_threshold (default high) or the model is disallowed. Blocked calls never reach Ollama and are recorded as blocked in the usage log.

Quick start

As a Claude Code plugin

One install gives an agent both the skill and the MCP server:

/plugin marketplace add AIops-tools/marketplace/plugin install ai-guardian@aiops-tools

The MCP server is fetched with uv and pinned to the package version this plugin declares, so an audit row can be traced back to the code that wrote it. Credentials are still configured with ai-guardian init — see below.

As an OpenClaw plugin

The same bundle is published on ClawHub, where one install delivers the skill and its MCP server together:

bash
openclaw plugins install clawhub:@zw008/ai-guardianopenclaw skills info ai-guardian          # expect: Visible to model: yes

Restart the OpenClaw gateway afterwards so it loads the plugin. The MCP server is fetched with uv, pinned to this exact release, so uvx has to be on PATH — without it the skill still installs but reports Visible to model: no. Credentials are configured exactly as below.

As a CLI or standalone MCP server

bash
uv tool install ai-guardian-aiops          # or: pipx install ai-guardian-aiopsai-guardian doctor                   # Ollama reachability + policy summary (works zero-config)ai-guardian overview                 # models installed/running, shadow count, usage statsai-guardian model list               # installed models with allow/deny verdictsai-guardian guard scan "my key is AKIAIOSFODNN7EXAMPLE"   # deterministic scan → risk band

The command and the package have different names. The CLI, the skill and this repo are all ai-guardian; the PyPI distribution is ai-guardian-aiops because ai-guardian was already taken. Both spellings below are correct and intentional — install ai-guardian-aiops, then run ai-guardian.

Route a prompt through the guard (scan + policy-gate + record + run-if-allowed) via MCP:

guarded_generate(model="llama3.2:3b", prompt="…", block_threshold="high")

Run as an MCP server (stdio) — the full 21-tool surface; the CLI is a convenience subset:

bash
export AI_GUARDIAN_AIOPS_MASTER_PASSWORD=...   # only if a target has a stored tokenai-guardian mcp                                # or: ai-guardian-mcp

Where that password then lives: an exported variable is readable by every process this shell starts and is recorded by shell history. On a shared or long-lived host, prefer the interactive prompt, or inject it from a secret manager for the life of the one command that needs it.

Governance

Every operation — MCP and CLI — passes through the bundled @governed_tool harness. It records; it does not authorize (see above).

  • Audit — every call (params, outcome summary, status, duration, risk tier, and any operator-supplied approver/rationale) is logged to ~/.ai-guardian/audit.db (relocatable via AI_GUARDIAN_AIOPS_HOME). This is separate from ~/.ai-guardian/usage.db, which holds the observed local-LLM usage.
  • Runaway guard — a safety backstop, not an authorization gate: the same call hammered in a tight loop trips a circuit breaker so a stuck agent can't burn unbounded calls/time. Disable with AI_GUARDIAN_RUNAWAY_MAX=0; optional hard ceilings via AI_GUARDIAN_MAX_TOOL_CALLS / AI_GUARDIAN_MAX_TOOL_SECONDS.
  • Undo recording — reversible writes record an inverse descriptor built from the fetched before-state.
  • Risk tier — a descriptive label on the audit row derived from risk_level; it gates nothing.

Supported scope + limitations

  • Scope: on-endpoint local LLMs — Ollama plus the OpenAI-compatible llama.cpp / LM Studio / local single-node vLLM — single-endpoint local-LLM observability + content governance. Not GPU inference-cluster ops (→ inference-aiops).
  • v0.1 = passive inventory/state auditing plus opt-in route-through content governance. A transparent capture proxy for other clients' traffic is v0.2 roadmap, not v0.1.
  • IGEL AI Armor interop is doc-level positioning today (complementary roles), not a wired integration.
  • Validation status — the scanner, policy, and risk-band are pure deterministic offline logic and are exercised as such by the test suite. The core Ollama route-through (real generation + policy deny + undo capture) was exercised against a live Ollama 0.24.0 on 2026-07-13; the rest of the Ollama surface and the OpenAI-compatible dialects (llama.cpp / LM Studio / local vLLM) are still covered by mocked responses only. ai-guardian doctor is the fastest live check; see docs/VERIFICATION.md for exactly which boxes are ticked.

Missing a capability?

Want a passive capture proxy, another scanner signature, a richer policy model, or an AI Armor hook? Open an issue or PR — feedback and contributions welcome.

來源:README.md,提交 ba601df

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

4
  1. v0.14.0Oct 30, 2026
  2. v0.13.0Oct 15, 2026
  3. v0.12.0Oct 15, 2026
  4. v0.11.3Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分