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
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 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
canonical_id
property
¶
Canonical alias for id used by report and graph consumers.
occurrence_id
property
¶
Workflow identity for this finding on this exact asset occurrence.
finding_group_key
property
¶
Asset-independent issue identity used only for aggregate/expand views.
The occurrence id remains authoritative for triage, lifecycle, evidence, and persistence. Vulnerability groups intentionally omit the asset and installed version so repeated occurrences can be presented together without destroying their distinct workflow records.
finding_group_id
property
¶
Deterministic identifier for a grouped issue queue row.
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
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | |
AIBOMReport
dataclass
¶
Complete AI-BOM report.
Source code in src/agent_bom/models.py
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 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 | |
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
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 1570 1571 1572 1573 1574 1575 1576 1577 | |
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.