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
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 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
canonical_id
property
¶
Canonical alias for id used by report and graph consumers.
vulnerability_id
property
¶
Canonical advisory identity, regardless of CVE/GHSA/OSV namespace.
cve_id remains the wire-compatible legacy field. New producers may
populate evidence.vulnerability_id and consumers should prefer this
namespace-neutral alias when joining findings to advisories.
advisory_ids
property
¶
Return deterministic, de-duplicated CVE/GHSA/OSV advisory aliases.
finding_category
property
¶
Stable category for consumers while legacy finding types remain intact.
security_domain
property
¶
Derived posture lane: one of cspm/vuln/aspm/dspm/aispm.
A pure function of source + finding type (+ evidence for the cloud data-vs-config split), so the overview and findings surfaces route each finding to exactly one coverage lane without double counting.
__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
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
AIBOMReport
dataclass
¶
Complete AI-BOM report.
Source code in src/agent_bom/models.py
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | |
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.).
agent_class_counts
property
¶
Real agents split by display class: AI clients vs background agents.
Excludes synthetic SBOM/image wrappers. client = discovered AI
host apps; background = framework/service agent definitions. See
:func:classify_agent_kind.
databricks_cis_benchmark_data
property
writable
¶
Deprecated alias for databricks_security_data.
Databricks has no official CIS benchmark; the canonical field is
databricks_security_data (vendor security best practices). This
CIS-named property is retained for backward compatibility with existing
clients and delegates both read and write to the canonical field.
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),
use it directly. Otherwise convert blast_radii on the fly. Hardcoded-
secret findings are always appended so machine consumers (JSON/SARIF/CSV)
see them, not just the console.
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.