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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! brep_mcp_core — the BREP MCP server, host-agnostic.
//!
//! The governing rule is that **the shape of the engine drives the MCP**:
//! every tool, schema and resource this crate serves is read from a registry
//! the engine or the app exposes, never from a table kept here. What lives in
//! this crate is the translation to the Model Context Protocol, session
//! management, the server-side compositions (image post-processing, scripts,
//! validation) that are MCP concerns rather than engine concerns, and the two
//! transports.
//!
//! The crate does not depend on the app. A *host* owns an app instance and
//! answers the [`host`] protocol; two exist: the app's own window (`brep-app
//! --mcp`, in the `BREP_app` crate) and the `BREP_mcp` crate's headless
//! `egui_kittest` harness. That is what lets the app embed the server without
//! a dependency cycle.
//!
//! Module map:
//! - [`tools`] — the server's view of a tool: `ToolSpec` (name, group, doc,
//! derived input schema, annotations, handler) and the sets that produce them.
//! - [`host`] — the host protocol: envelopes, replies, the backend seam and
//! the [`host::Platform`] a host supplies.
//! - [`session`] — one app instance under one host, its directory and recorder.
//! - [`schema`] — the kernel feature catalogue rendered as JSON Schema.
//! - [`validate`]— feature-parameter validation against the catalogue.
//! - [`script`] — the JSON step-list script format and its `expect` operators.
//! - [`script_sdk`] — the `sdk.<namespace>.<action>(args)` catalogue every
//! host's code runner exposes, and the `sdk` tool that describes it.
//! - [`declarations`] — one action's TypeScript signature, from its schemas.
//! - [`files`] — bounded file operations under named roots.
//! - [`image`] — PNG decode/encode, crop, scale, diff for screenshots.
//!
//! With the `server` feature (default):
//! - [`server`] — the dynamic `rmcp::ServerHandler` over those sets, stdio;
//! [`server::BrepServer`] is the entry point a host constructs.
//! - [`http`] — the same server over streamable HTTP on a loopback listener.
//! - [`cad`] — the CAD operation service: code execution (`run`), the
//! front-door tools, artifacts and journals.
//! - [`program`] — JavaScript test programs played through the code runner.
//! - [`runner`] — plays a script through a tool set and writes the artefacts.
//! - [`render_mesh`] — a CPU mesh renderer and silhouette comparison.
//! - [`generate`]— renders the registries to Markdown/JSON reference docs and
//! the old-to-new SDK mapping.
//! - [`launch_state`] — the native launch policy for execution journals.
//! - [`skills`], [`skill_distribution`], [`prompts`] — the embedded reviewed
//! workflows, their offline bundle installer, and MCP prompts.
//! - [`plm_fixture`] — a real `brep-plm serve` a script runs against (`plm`).
//!
//! Without `server` the crate is the tool set over the host protocol alone,
//! for a host that supplies its own platform — the browser build of the app,
//! which compiles this for wasm32 so a page serves the same tools the desktop
//! does. See the README for the transports, credentials and launch options.
// One action's TypeScript signature (the `sdk` tool). Target-free, so the
// browser's page renders the same text; it lives beside the service it was
// written for and is also `cad::declarations`.