list_baselines
List all built-in and user-imported compliance baselines for VMware vSphere hardening, covering CIS, DISA STIG, vSphere SCG, China DJCP 2.0, and PCI-DSS frameworks.
Instructions
[READ] List built-in and user-imported compliance baselines.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- vmware_harden/mcp/tools.py:22-45 (handler)The actual tool handler: decorated with @vmware_tool(risk_level='low'), it calls list_builtins() and load_builtin() from the baselines.loader module to build a list of baseline dicts with id, name, version, applies_to, and rule_count.
@vmware_tool(risk_level="low") def list_baselines() -> list[dict]: """List built-in and user-imported baselines. Returns: list of {id, name, version, applies_to, rule_count}. """ from vmware_harden.baselines.loader import list_builtins, load_builtin out: list[dict] = [] for name in list_builtins(): try: b = load_builtin(name) out.append( { "id": b.id, "name": b.name, "version": b.version, "applies_to": list(b.applies_to), "rule_count": len(b.rules), } ) except Exception as e: out.append({"id": name, "error": f"failed to load: {e}"}) return out - mcp_server/server.py:19-22 (registration)Registration of the tool on the FastMCP server via @server.tool(name='list_baselines'), wrapping the implementation from vmware_harden.mcp.tools.
@server.tool(name="list_baselines") def _list_baselines_impl() -> list[dict]: """[READ] List built-in and user-imported compliance baselines.""" return t.list_baselines() - list_builtins() helper used by the handler: discovers baseline YAML files in both the user directory and the package builtin directory.
def list_builtins() -> list[str]: """Return sorted names of all discoverable baselines. Includes both user dir (~/.vmware-harden/baselines) and package built-in directory; deduplicated by stem (user wins on collision). """ names: set[str] = set() for base in (USER_DIR, BUILTIN_DIR): if not base.exists(): continue for p in base.glob("*.yaml"): names.add(p.stem) return sorted(names) - load_builtin(name) helper used by the handler: resolves and loads a baseline YAML by name.
def load_builtin(name: str) -> Baseline: """Load a baseline by name (without `.yaml` suffix). Searches user dir (~/.vmware-harden/baselines) first, then the package's built-in directory. """ return load_baseline(_resolve_baseline_path(name)) - Baseline Pydantic model that defines the schema for baseline data (id, name, version, applies_to, rules).
class Baseline(BaseModel): """A complete baseline of compliance rules.""" model_config = ConfigDict(extra="forbid") id: str name: str version: str source: str | None = None extends: str | None = None applies_to: list[NodeType] rules: list[Rule]