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/domain/finding_model.py
stable_id
property
¶
Deterministic UUID derived from asset content.
Provider-local identifiers include their recorded account and region. 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.
Carries CVE, cloud, secret, source-analysis and runtime evidence with source identity and scope. BlastRadius remains a supported compatibility input.
Source code in src/agent_bom/domain/finding_model.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 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 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 | |
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/domain/finding_model.py
normalized_controls ¶
Return deduplicated structured controls for this finding.
all_compliance_tags ¶
Return deduplicated union of all compliance tag lists.
Source code in src/agent_bom/domain/finding_model.py
effective_severity ¶
sla_fields ¶
Deadline, its source and the KEV due date; anchor stands in for a missing first_seen.
Source code in src/agent_bom/domain/finding_model.py
to_dict ¶
Return a JSON-serializable finding payload.
Source code in src/agent_bom/domain/finding_model.py
AIBOMReport
dataclass
¶
Complete AI-BOM report.
Source code in src/agent_bom/models.py
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 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 | |
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
¶
Legacy read/write alias for Databricks vendor security best practices, not an official CIS benchmark.
to_findings ¶
Return unified findings reconciled with legacy and scanner evidence.
Reconcile explicit findings with the legacy blast-radius projection, retaining non-CVE findings when both representations are present. Convert supported scanner payloads and append secret evidence so machine consumers (JSON/SARIF/CSV) share the same finding stream.
Source code in src/agent_bom/models.py
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 | |
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.