Skip to main content
Glama

list_violations

Retrieve compliance violations from the latest snapshot, optionally filtered by severity to identify security issues in vSphere environments.

Instructions

[READ] Latest snapshot's violations, optionally filtered by severity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
severityNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The actual implementation of list_violations. Queries the Twin database for the latest snapshot's violations, optionally filtered by severity, and returns a list of dicts with id, rule_id, node_id, severity, baseline_id, and evidence.
    @vmware_tool(risk_level="low")
    def list_violations(severity: str | None = None) -> list[dict]:
        """[READ] Latest snapshot's violations, optionally filtered by severity."""
        from vmware_harden.store.twin import Twin
    
        twin = Twin(_resolve_db())
        try:
            latest = twin.conn.execute(
                "SELECT id FROM snapshots ORDER BY scan_started_at DESC LIMIT 1"
            ).fetchone()
            if not latest:
                return []
            params: list = [latest[0]]
            sql = (
                "SELECT id, rule_id, node_id, severity, baseline_id, evidence "
                "FROM violation WHERE snapshot_id = ?"
            )
            if severity:
                sql += " AND severity = ?"
                params.append(severity)
            sql += " ORDER BY severity DESC, rule_id"
            rows = twin.conn.execute(sql, params).fetchall()
            out: list[dict] = []
            for r in rows:
                try:
                    ev = json.loads(r[5]) if r[5] else None
                except Exception:
                    ev = None
                out.append(
                    {
                        "id": r[0],
                        "rule_id": r[1],
                        "node_id": r[2],
                        "severity": r[3],
                        "baseline_id": r[4],
                        "evidence": ev,
                    }
                )
            return out
        finally:
            twin.close()
  • Registration of the 'list_violations' MCP tool via @server.tool decorator on the FastMCP server. Delegates to t.list_violations(severity).
    @server.tool(name="list_violations")
    def _list_violations_impl(severity: str | None = None) -> list[dict]:
        """[READ] Latest snapshot's violations, optionally filtered by severity."""
        return t.list_violations(severity)
  • The 'violation' table DDL that defines the schema for violation records queried by list_violations.
    """
    CREATE TABLE IF NOT EXISTS violation (
        id VARCHAR PRIMARY KEY,
        snapshot_id VARCHAR NOT NULL,
        baseline_id VARCHAR NOT NULL,
        rule_id VARCHAR NOT NULL,
        node_id VARCHAR NOT NULL,
        severity VARCHAR NOT NULL,
        evidence JSON,
        detected_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        status VARCHAR DEFAULT 'open'
    )
    """,
  • Helper function _resolve_db() used by list_violations to get the database path.
    def _resolve_db() -> Path:
        """Return the configured DB path, defaulting to user dir."""
        return _DB_PATH or Path(os.path.expanduser("~/.vmware-harden/twin.duckdb"))
  • The Twin class (DuckDB-backed store) that list_violations instantiates to query the database.
    class Twin:
        """Single-file DuckDB-backed estate twin."""
    
        def __init__(self, db_path: Path):
            self.db_path = db_path
            self.conn = duckdb.connect(str(db_path))
            self.init_schema()  # idempotent; CREATE IF NOT EXISTS
    
        def init_schema(self) -> None:
            """Create all tables if they don't exist (idempotent)."""
            for stmt in DDL:
                self.conn.execute(stmt)
    
        def list_tables(self) -> list[str]:
            """Return names of all user tables in the database."""
            rows = self.conn.execute(
                "SELECT table_name FROM information_schema.tables "
                "WHERE table_schema = 'main'"
            ).fetchall()
            return [r[0] for r in rows]
    
        def start_snapshot(self, target: str) -> str:
            """Begin a new scan snapshot. Returns the snapshot id (UUID)."""
            snap_id = str(uuid.uuid4())
            self.conn.execute(
                "INSERT INTO snapshots (id, target, scan_started_at) VALUES (?, ?, ?)",
                [snap_id, target, datetime.now(timezone.utc)],
            )
            return snap_id
    
        def finish_snapshot(self, snapshot_id: str, status: str = "completed") -> None:
            """Mark a snapshot finished with the given status."""
            self.conn.execute(
                "UPDATE snapshots SET scan_finished_at = ?, status = ? WHERE id = ?",
                [datetime.now(timezone.utc), status, snapshot_id],
            )
    
        def write_node_state(
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The [READ] prefix indicates it is read-only, which is positive. However, no annotations are provided, and the description does not elaborate on further behavioral aspects such as pagination, limits, or error states, leaving some gaps despite the output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no extraneous words. It efficiently conveys the tool's purpose and key use case.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one optional parameter, output schema present), the description adequately covers the core functionality. Minor omissions like snapshot availability or empty results are acceptable.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% coverage, so the description compensates by stating the parameter 'severity' is for optional filtering. This adds meaning beyond the schema's type definition, though valid severity values are not specified.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'list' and resource 'violations' from the latest snapshot, with optional filtering. It distinguishes itself from sibling tools like list_baselines and list_drift_events by specifying it's for violations from the latest snapshot.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for current violations from the latest snapshot but does not explicitly state when not to use this tool or provide alternatives. No comparison with siblings like list_drift_events or scan_target is given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zw008/VMware-Harden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server