1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! Shape A/B: a streamable-HTTP MCP server that serves a governed-Excel workbook
//! over all five workbook tools (`calculate`, `explain`, `get_manifest`,
//! `diff_version`, `render_workbook`) plus the `workbook://` render resource.
//!
//! This is THE canonical wiring of [`WorkbookBuilderExt::try_with_workbook_bundle`]
//! (D-09/D-12): a single chained call loads + integrity-verifies the bundle at
//! boot (fail-closed — a tampered bundle aborts the boot, WBSV-08) and registers
//! the served surface. The consumer imports SOLELY from `pmcp_server_toolkit`,
//! never naming `pmcp-workbook-runtime` (D-11).
//!
//! # Bundle source: embedded by default, `--bundle-dir` for live updates
//!
//! By default the example bakes the committed synthetic `tax-calc@1.1.0` golden
//! directly into the binary via [`include_dir!`] + [`EmbeddedSource`] — a
//! self-contained deploy artifact (WBSV-09): the spreadsheet logic ships INSIDE
//! the binary, so a remote deploy (Lambda / container) carries no out-of-band
//! bundle directory. That is the production default for an immutable workbook.
//!
//! Passing `--bundle-dir <path>` switches to a [`LocalDirSource`] over that
//! directory instead. This is how a production operator points the SAME binary
//! at a workbook updated OUT-OF-BAND (a newly promoted bundle dropped onto a
//! mounted volume) WITHOUT rebuilding — the embedded→local transition is the
//! seam between "ship the logic in the binary" and "update the logic at runtime".
//! Either way the bundle is loaded fail-closed: a tampered directory aborts boot.
//!
//! Run with:
//! ```sh
//! cargo run --example workbook_server_http \
//! --features workbook-embedded,http -p pmcp-server-toolkit
//! # or point at an out-of-band bundle directory:
//! cargo run --example workbook_server_http \
//! --features workbook-embedded,http -p pmcp-server-toolkit -- \
//! --bundle-dir bundles/tax-calc@1.1.0
//! ```
use SocketAddr;
use Arc;
use ;
use ;
use Server;
use ;
use Mutex;
use JoinHandle;
/// The committed synthetic golden bundle, baked into the binary at compile time.
/// Points STRAIGHT at the 92-02 committed `@1.1.0` golden (no examples/fixtures
/// duplication) so the embedded bytes are byte-identical to the on-disk golden
/// the integration tests load via `LocalDirSource`.
static EMBEDDED_BUNDLE: Dir = include_dir!;
/// Inline streamable-HTTP serve helper: collapses `with_config` + `start` and
/// binds an ephemeral port (`127.0.0.1:0`) so the bound address is reported back
/// for the smoke test / operator to read.
async
async