Python API¶
Use the public Python API when another tool needs typed agent-bom results
without parsing terminal output, or when services and notebooks need a small
control-plane client for stable REST endpoints.
Install¶
Use the API extra when the same environment also starts a local control plane:
Local Scan Helpers¶
from agent_bom import check, diff, scan
from agent_bom.sdk import inventory
report = scan(project=".", offline=True)
for finding in report.to_findings():
print(finding.id, finding.severity)
package = check("requests@2.31.0", ecosystem="pypi", offline=True)
print(package.status, package.vulnerabilities)
fleet = inventory("fleet-inventory.json")
print(fleet.agent_count, fleet.package_count)
delta = diff("baseline.json", "current.json")
print(delta.summary)
The API delegates to the same scanner, inventory, and history-diff primitives used elsewhere in the product. It is not a parallel scan engine.
Control-Plane Client¶
from agent_bom import AgentBomClient
with AgentBomClient(
base_url="https://agent-bom.internal",
api_key="agent-bom-api-key",
tenant_id="tenant-a",
) as client:
print(client.health()["status"])
manifest = client.agent_manifest()
runtime = client.runtime_production_index()
intel = client.intel_sources()
decision = client.should_i_deploy("flask@2.0.0", block_risk=80)
print(manifest["schema_version"], runtime["schema_version"], len(intel.get("sources", [])), decision["decision"])
Run the packaged smoke example against a live API:
AGENT_BOM_BASE_URL=http://127.0.0.1:8422 \
AGENT_BOM_API_KEY=dev-key \
python examples/python_sdk/control_plane_smoke.py
The client accepts either api_key or bearer_token. tenant_id is sent as
X-Agent-Bom-Tenant-ID and used as the default tenant scope for tenant-aware
methods.
Payload-first methods accept the obvious positional form:
client.ingest_findings(
[{"id": "finding-1", "severity": "high", "title": "External scanner finding"}],
source="external-scanner",
)
client.register_dataset_version("training-set", version_id="2026-05-24")
client.should_i_deploy("flask@2.0.0", block_risk=80)
agent_bom.sdk ¶
Public Python API for embedding agent-bom in other tools.
This module is intentionally thin: it exposes stable Python functions while delegating to the same scanner, inventory, and history primitives used by the CLI and MCP surfaces. It is not a second scan implementation.
Asset
dataclass
¶
What is affected by this finding.
Source code in src/agent_bom/finding.py
stable_id
property
¶
Deterministic UUID derived from asset content.
Same asset type + identifier always produces the same ID across scans. This enables tracking: first seen, last seen, resolved, re-emerged.
canonical_id
property
¶
Canonical alias for stable_id used by reports and graph joins.
source_ids
property
¶
Original source identifiers retained as provenance.
Finding
dataclass
¶
Unified finding — one model for all issue types across all sources.
Phase 1 covers CVE findings (migrated from BlastRadius). Phase 2 will add cloud CIS, proxy, SAST, skill findings.
Source code in src/agent_bom/finding.py
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
canonical_id
property
¶
Canonical alias for id used by report and graph consumers.
__post_init__ ¶
Compute stable ID from finding content if not explicitly set.
Source code in src/agent_bom/finding.py
normalized_controls ¶
all_compliance_tags ¶
Return deduplicated union of all compliance tag lists.
Source code in src/agent_bom/finding.py
effective_severity ¶
to_dict ¶
Return a JSON-serializable finding payload.
Source code in src/agent_bom/finding.py
AIBOMReport
dataclass
¶
Complete AI-BOM report.
Source code in src/agent_bom/models.py
982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 | |
has_mcp_context
property
¶
True if scan discovered real MCP servers (not synthetic SBOM/image wrappers).
Uses explicit server surface classification rather than command heuristics.
has_agent_context
property
¶
True if scan discovered real AI agents (not synthetic SBOM/image wrappers).
Synthetic agents (SBOM ingest, image scan) use AgentType.CUSTOM with
names prefixed by sbom: or image:. Real discovered agents have
specific agent types (CLAUDE_DESKTOP, CURSOR, etc.).
to_findings ¶
Return the unified findings list, auto-populating from blast_radii if empty.
Phase 1 shim: if self.findings is already populated (dual-write path),
return it directly. Otherwise convert blast_radii on the fly so callers
can always work with the unified model.
Source code in src/agent_bom/models.py
cve_findings ¶
Return only CVE-type findings from the unified stream.
AgentBomSDKError ¶
PackageCheckResult
dataclass
¶
Typed result returned by :func:check and :func:async_check.
Source code in src/agent_bom/sdk.py
InventoryResult
dataclass
¶
Typed inventory wrapper returned by :func:inventory.
Source code in src/agent_bom/sdk.py
DiffResult
dataclass
¶
Typed report diff wrapper returned by :func:diff.
Source code in src/agent_bom/sdk.py
scan ¶
scan(*, config_path: str | Path | None = None, project: str | Path | None = None, demo: bool = False, offline: bool = False, enrich: bool = False, compliance: bool = False, transitive: bool = False, max_depth: int = 3, blast_radius_depth: int = 2) -> AIBOMReport
Run the standard local scan pipeline and return a typed report.
project and config_path both point at a local project/config scope.
The name config_path is kept for MCP/API users who are already familiar
with that argument; internally this delegates to the same simple scan runner
used by CLI commands.
Source code in src/agent_bom/sdk.py
async_check
async
¶
Check one package spec and return a typed vulnerability result.
Source code in src/agent_bom/sdk.py
check ¶
Synchronous wrapper around :func:async_check.
Async applications should call :func:async_check directly to avoid nesting
event loops.
Source code in src/agent_bom/sdk.py
inventory ¶
Load a JSON/CSV/NDJSON inventory artifact and return typed counts.
Source code in src/agent_bom/sdk.py
diff ¶
diff(baseline: str | Path | Mapping[str, Any], current: str | Path | Mapping[str, Any]) -> DiffResult
Diff two agent-bom reports or SBOM documents.