Skip to main content
Glama

llm-web-guard

Defensive security checks for the AI features you ship.

CI License: MIT Python 3.11+

llm-web-guard is a CLI, GitHub Action and MCP server for Claude, Cursor and other AI assistants. It finds security and cost mistakes in LLM-powered web apps, maps them to the OWASP LLM Top 10 and can ask a real model for a second opinion.

It is defensive by design: it reads local source files, never sends a request to your application and never executes project code.

What it catches

ID

Severity

Check

LWG001

Critical

Hardcoded OpenAI, Anthropic, OpenRouter, Google, Groq, Perplexity or xAI keys.

LWG002

Critical

Provider keys exposed through NEXT_PUBLIC_, VITE_ or browser-side code.

LWG003

Medium

Model calls without max_tokens, maxTokens, maxOutputTokens or equivalent.

LWG004

Low

Model calls without a timeout or abort signal.

LWG005

High

User input interpolated into a system prompt.

LWG006

High

Model output passed to dangerouslySetInnerHTML without sanitization.

LWG007

Medium

AI API routes with no obvious authentication check.

LWG008

Medium

AI API routes with no obvious rate limit, quota or credit check.

LWG009

High

Wildcard CORS on an AI endpoint.

Checks are deterministic and run locally. LWG007 and LWG008 are explicitly heuristic: they tell you to review, not that a vulnerability is proven.

Related MCP server: MCP Shield

Install

With uv:

uv tool install git+https://github.com/htsecurity/llm-web-guard.git

Or with pipx:

pipx install git+https://github.com/htsecurity/llm-web-guard.git

CLI

# Scan the current project
llm-web-guard scan

# Scan a specific app
llm-web-guard scan ./apps/web

# JSON or SARIF for CI/code scanning
llm-web-guard scan --format json --output report.json
llm-web-guard scan --format sarif --output llm-web-guard.sarif

# Fail only on critical findings, or do not fail at all
llm-web-guard scan --fail-on critical
llm-web-guard scan --fail-on none

# See available local and hosted models
llm-web-guard models

Exit codes:

  • 0: no finding at or above the --fail-on threshold.

  • 1: a finding reached the threshold.

  • 2: invalid input, path or AI configuration.

AI review (real models, optional)

The deterministic scan never needs an API key. To get a second opinion on the highest-severity findings:

# Local first: uses an installed Ollama model when available
llm-web-guard scan --ai-review --ai-max 3

# Pick a specific local model
llm-web-guard scan --ai-review --ai-provider ollama --model qwen2.5:14b

# Or use OpenRouter
export OPENROUTER_API_KEY=...
llm-web-guard scan --ai-review --ai-provider openrouter

What happens:

  1. Ollama is tried first when --ai-provider auto is used.

  2. If no local model is available, OpenRouter is used when OPENROUTER_API_KEY is set.

  3. Only the finding and a small code window are sent, not the whole project.

  4. The model must return structured JSON with a verdict, confidence, rationale, remediation and an optional patch hint.

  5. Results are cached by input hash. --ai-max defaults to 3 and is capped at 20.

Example with a local model:

AI (ollama/qwen2.5:14b): confirmed (100%) — The API key is exposed in the
client-side code, which is a critical security issue as it can be accessed by
any user of the web application.

The CLI prints the provider, model and token usage in JSON output. No AI call is made unless --ai-review or the MCP review tool is explicitly used.

Environment

Copy .env.example to .env for local use. Real .env files are gitignored.

Variable

Purpose

OPENROUTER_API_KEY

Optional OpenRouter key.

OPENROUTER_DEFAULT_MODEL

Optional model ID. If empty, a low-cost model is selected from the live catalog.

OLLAMA_BASE_URL

Local OpenAI-compatible endpoint. Default: http://localhost:11434/v1.

OLLAMA_MODEL

Optional local model ID.

The models command reads the live OpenRouter catalog and shows prices per 1M input/output tokens. OpenRouter results are cached for one hour.

Use it from Claude and other MCP clients

The MCP server exposes four tools:

Tool

Purpose

scan(path)

Deterministic local scan. No AI calls.

review(finding, code_context, provider?, model?)

Real LLM second opinion on one finding.

models(provider?)

List local Ollama models and live OpenRouter models.

rules()

List the checks and OWASP mappings.

Claude Code:

claude mcp add llm-web-guard -- uvx --from git+https://github.com/htsecurity/llm-web-guard llm-web-guard-mcp

Claude Desktop, Cursor and other stdio MCP clients:

{
  "mcpServers": {
    "llm-web-guard": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/htsecurity/llm-web-guard",
        "llm-web-guard-mcp"
      ]
    }
  }
}

Then ask:

Scan this project for LLM security issues. Do not send code to a model yet.

Review the highest-severity finding with my local Ollama model.

GitHub Action

The action is deterministic and makes no AI calls in CI:

- uses: htsecurity/llm-web-guard@v0.1.0
  with:
    path: .
    fail-on: high

SARIF output for GitHub code scanning:

- uses: htsecurity/llm-web-guard@v0.1.0
  id: llm-security
  with:
    path: .
    fail-on: none
    format: sarif
    output: llm-web-guard.sarif

- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: llm-web-guard.sarif

Privacy and safety

  • The scanner reads source files only. It does not execute code, install dependencies, browse your app or send HTTP requests to it.

  • Secret-looking values are redacted in output.

  • AI review is opt-in and sends only the finding and a small code window.

  • Use --ai-provider ollama to keep review data on your machine.

  • No telemetry, analytics or background jobs.

Limitations

  • This is a static heuristic scanner, not a penetration test or a guarantee that an app is secure.

  • It does not prove exploitability. Findings marked medium confidence need a human review.

  • It does not understand every framework, custom wrapper or authorization model.

  • It does not replace dependency scanning, secret scanning, auth testing or a full OWASP ASVS review.

Development

git clone https://github.com/htsecurity/llm-web-guard.git
cd llm-web-guard
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .

The test suite includes a deliberately vulnerable Next.js fixture, a safe fixture, SARIF validation, an MCP stdio client test and mocked AI responses. CI runs on Python 3.11 and 3.13.

License

MIT. See LICENSE.

Available Tools

4 tools
modelsA

List available Ollama models and current OpenRouter models with prices.

Inputs: provider. Returns: object

reviewB

Ask a real LLM to review one finding and a small code snippet.

The snippet is sent to the selected provider. Use provider=ollama to keep it on this machine. The default is local Ollama first, then OpenRouter.

Inputs: finding (required), code_context (required), model, provider. Returns: object

rulesA

List the deterministic checks and their OWASP LLM mappings.

Inputs: no named parameters. Returns: object

scanC

Scan a local project for LLM web security issues. Read-only, no AI calls.

Inputs: path. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct role: scan runs the deterministic static pass, review does a single LLM-backed deep dive on one finding, while models and rules are pure informational lookups. The scan vs. review boundary is spelled out explicitly (read-only/no AI calls vs. snippet sent to a provider), so misselection is unlikely.

    Naming Consistency4/5

    All names are single lowercase tokens with no case/style drift, which is predictable. The only inconsistency is grammatical: scan/review are verbs while models/rules are bare nouns that implicitly mean list_models/list_rules.

    Tool Count5/5

    Four tools is a tight, well-scoped surface for a small security scanner: detection, AI-assisted triage, provider discovery, and rule enumeration. No tool looks redundant or like filler, and nothing essential is obviously missing at this scale.

    Completeness4/5

    The lifecycle (list rules -> scan -> inspect providers -> review a finding) is coherent and has no dead ends. Minor gaps: no way to enumerate/export the findings from a scan in structured form, and no configuration/baseline management for suppressions or provider defaults.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that audits other MCP servers. Run MCPWatch security scans from inside Claude Code or any MCP-compatible agent with 10 OWASP MCP Top 10 aligned checks and A-F letter grades.
      MIT
    • A
      license
      C
      quality
      D
      maintenance
      Security scanner and MCP server that catches dangerous patterns in MCP servers and AI agent projects, such as leaked secrets, shell execution, and prompt-injection text. Runs as both a CLI and MCP server with CI-friendly severity gates.
      2
      1
      MIT
    • A
      license
      C
      quality
      C
      maintenance
      A local-first, authorization-gated MCP server for web security assessment that transforms URLs into traceable, reviewable reports and integrates with Claude Code and local LLMs.
      15
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A read-only MCP server that lets an agent audit its own environment by discovering local MCP configurations and skill folders on Windows, macOS, and Linux and running offline static checks for prompt injection, hidden instructions, hardcoded secrets, dangerous commands, unpinned packages, and excessive filesystem or transport permissions. It exposes tools to scan everything discovered, list configurations, vet a single skill, or analyze supplied text, returning text, JSON, SARIF, or HTML findings with CI-friendly severity levels.
      7 npm
      MIT