Skip to main content

pmcp_package/
lib.rs

1//! # pmcp-package
2//!
3//! The AI-Package format for portable MCP packages: typed manifest schemas,
4//! config-slot aggregation, local OCI pack/unpack, and canonical-digest
5//! computation.
6//!
7//! ## Dual-consumer contract
8//!
9//! This crate is consumed by **two** independent call sites:
10//! - `cargo-pmcp` (the CLI) — packs local server/agent/team/workflow artifacts
11//!   for publish.
12//! - The `pmcp.run` platform — unpacks and validates packages at
13//!   import/pre-flight time.
14//!
15//! Both call sites MUST resolve identical validation/digest behavior from the
16//! same crate code — that is the entire point of this crate existing as a
17//! shared, standalone, publishable library rather than being duplicated in
18//! each consumer.
19//!
20//! ## Scope fence
21//!
22//! This crate is **format only**:
23//! - Typed manifest schemas for the four package kinds (mcp-server, agent,
24//!   team, workflow).
25//! - Config-slot type system: classification, aggregation, deviation
26//!   detection.
27//! - Local OCI artifact pack/unpack (construct manifests + content-addressed
28//!   blobs on disk — no registry calls).
29//! - Canonical-digest computation for approval-record keying.
30//! - A DELIBERATELY NARROW read of a server's own config document
31//!   (`oci::config_validation`): it reads the `[[config_slots]]` declaration
32//!   table and resolves the dotted TOML path each declared slot names, so
33//!   `pack_server` can refuse a package whose slot list disagrees with the
34//!   config it ships, or whose slot-declared value key holds a resolved
35//!   literal. That is the whole extent of it — the crate models no config
36//!   schema, holds no opinion about the toolkit's config shape beyond those
37//!   two things, and never re-serializes the document (config layer bytes stay
38//!   verbatim).
39//!
40//! It explicitly does **NOT** contain:
41//! - Agent runtime semantics (no execution, no LLM calls, no tool dispatch).
42//! - Network or AWS SDK dependencies (no `reqwest`, no `tokio`, no
43//!   `oci-client`, no `aws-sdk-*` crate). Registry push/pull is a caller-side
44//!   concern at the *caller's* call site, not this crate's.
45//! - Secret **values** — config slots may declare that a secret is required
46//!   by *name*, but the crate's types are structurally incapable of holding
47//!   a resolved secret value (see `slot` module docs).
48
49pub mod digest;
50pub mod error;
51pub mod oci;
52pub mod package;
53pub mod reference;
54pub mod slot;
55pub mod validation;
56
57// ---------------------------------------------------------------------
58// Crate-root re-exports (dual-consumer ergonomics)
59// ---------------------------------------------------------------------
60//
61// `cargo-pmcp` and the `pmcp.run` platform both consume this crate's primary
62// types and functions without needing deep module paths (`pmcp_package::ServerPackage`
63// rather than `pmcp_package::package::ServerPackage`). Deep paths still work —
64// this block is additive, not a replacement for the module tree.
65
66pub use digest::{canonicalize, manifest_digest, verify, ManifestDigest};
67pub use error::{PackageError, Result};
68pub use oci::{
69    pack_agent, pack_server, pack_team, pack_workflow, parse_declared_config_slots, unpack_agent,
70    unpack_server, unpack_team, unpack_workflow, validate_config_slot_agreement,
71    validate_config_slot_placeholders, validate_no_undeclared_env_refs, AttestationFile,
72    BinaryMode, ConfigFile, DeclaredConfigSlot, OciLayout, OpenApiSpecFile, RestoredFile,
73    SubjectVerdict, UnpackedAttestation, UnpackedBinary, UnpackedServer, UnpackedTeam,
74};
75pub use package::{
76    AgentPackage, CedarPolicySet, DeployDescriptor, ServerPackage, TeamPackage, WorkflowManifest,
77};
78pub use reference::{ComponentRef, PinnedRef};
79pub use slot::{
80    aggregate, classify, classify_slots, detect_deviation, required_slots, ClassifiedSlot,
81    ConfigSlot, Deviation, RequiredSlot, SlotClass, SlotType, SuppliedBy,
82};
83pub use validation::validate as validate_deploy_descriptor;