feat(app): the Connect page's Claude desktop app row writes a one-click extension (P15 C1)

Claude's desktop extension format is the MCP Bundle: a .mcpb zip with a
manifest.json (manifest 0.3, github.com/anthropics/mcpb). The row's
button makes the company's agent key if there is none and writes
Documents/Wanderbooks/Extensions/wanderbooks-<id>.mcpb: a manifest whose
server is a binary running this program's own stable path as
mcp --book <id>, the 512 px icon and a short README as the entry point.
The package carries no program (the one executable is the installed
one), no key and no path of the data root. The page then says in plain
words where in Claude to pick the file and to keep Wanderbooks open, and
offers to show the file. The manifest is checked against Anthropic's
published schema (a test fixture) and its required fields. The blessed
Connect page pictures change by exactly the new row. The program's
version is now one value set by main for every platform, not only Unix.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 15:31:21 -07:00
1 parent 479d3a5c5e
commit 2bc442f795
15 files changed
+1039 -21

No files matched your search

+13 -2
View File
@@ -282,6 +282,18 @@ impl ledger_gui::owner::Owner for ViewerOwner {
)
}
fn claude_desktop_extension(
&self,
book: &str,
company: &str,
) -> Result<ledger_gui::owner::ExtensionMade, String> {
let made = ledger_host::extension::claude_desktop_extension(&self.common, book, company)?;
Ok(ledger_gui::owner::ExtensionMade {
file: made.path.display().to_string(),
folder: made.folder.display().to_string(),
})
}
fn new_books(&self, id: &str, currency: &str) -> Result<String, String> {
ledger_host::commands::new_books_and_home(&self.common, id, currency)
}
@@ -690,8 +702,7 @@ fn is_bare_launch(words: &[String], stdin_is_terminal: bool) -> bool {
}
fn main() {
#[cfg(unix)]
ledger_host::update::set_program_version(env!("CARGO_PKG_VERSION"));
ledger_host::set_program_version(env!("CARGO_PKG_VERSION"));
// A file's path may be any name the system takes: the file commands
// get the words as given. Everything else is text.
let given: Vec<std::ffi::OsString> = env::args_os().skip(1).collect();
+142
View File
@@ -0,0 +1,142 @@
//! The Claude desktop extension the Connect page writes (plan P15 unit C1,
//! WB-pkg-5): its package is Anthropic's MCP Bundle, and its manifest is
//! checked against Anthropic's published schema for manifest version 0.3
//! (`tests/fixtures/mcpb/`, with where it came from).
//!
//! ```text
//! GOAL: a package the Claude desktop app can install, naming this
//! program's bridge for one company, with nothing secret in it.
//! SOURCE: WB-pkg-5; github.com/anthropics/mcpb (MANIFEST.md, the 0.3
//! schema); ledger-host extension.rs.
//! INVARIANTS:
//! 1. The package is a zip whose root holds `manifest.json`; every file
//! the manifest names (`icon`, `server.entry_point`) is in the zip.
//! 2. The manifest validates against the 0.3 schema, which refuses any
//! field the specification does not define.
//! 3. The server is a `binary` whose command is the program's path and
//! whose arguments are `mcp --book <id>`.
//! SCENARIOS:
//! 1. A package made for a company with an awkward name validates.
//! 2. Every required field of the schema is present.
//! ```
use serde_json::Value;
use std::io::Read;
fn schema() -> jsonschema::Validator {
let text = include_str!("fixtures/mcpb/mcpb-manifest-v0.3.schema.json");
jsonschema::validator_for(&serde_json::from_str::<Value>(text).unwrap()).unwrap()
}
fn made(company: &str) -> (tempfile::TempDir, std::path::PathBuf) {
let dir = tempfile::tempdir().unwrap();
let bridge: Vec<std::ffi::OsString> = [
"/Applications/Wanderbooks.app/Contents/MacOS/wanderbooks",
"mcp",
"--book",
"acme",
]
.map(Into::into)
.to_vec();
let made = ledger_host::extension::write_in(dir.path(), "acme", company, "0.1.0", &bridge)
.expect("the package is written");
(dir, made.path)
}
fn read(path: &std::path::Path) -> (Value, Vec<String>) {
let mut zip = zip::ZipArchive::new(std::fs::File::open(path).unwrap()).unwrap();
let names: Vec<String> = (0..zip.len())
.map(|i| zip.by_index(i).unwrap().name().unwrap().to_string())
.collect();
let mut text = String::new();
zip.by_name("manifest.json")
.expect("manifest.json is at the root of the package")
.read_to_string(&mut text)
.unwrap();
(serde_json::from_str(&text).unwrap(), names)
}
#[test]
fn the_manifest_is_one_the_published_schema_accepts() {
for company in [
"Wanderland Labs LLC",
"Quote \" and <markup> & \u{e9}\u{4e2d}",
&"long ".repeat(100),
"",
] {
let (_dir, path) = made(company);
let (manifest, _) = read(&path);
let errors: Vec<String> = schema()
.iter_errors(&manifest)
.map(|e| format!("{e} at {}", e.instance_path()))
.collect();
assert!(errors.is_empty(), "{company:?}: {errors:?}\n{manifest:#}");
// The check is not vacuous: a field the specification lacks, or a
// missing required one, is refused.
let mut extra = manifest.clone();
extra["no_such_field"] = Value::Bool(true);
assert!(!schema().is_valid(&extra));
let mut short = manifest.clone();
short.as_object_mut().unwrap().remove("author");
assert!(!schema().is_valid(&short));
}
}
#[test]
fn every_file_the_manifest_names_is_in_the_package() {
let (_dir, path) = made("Acme");
let (manifest, names) = read(&path);
assert_eq!(manifest["manifest_version"], "0.3");
for named in [
manifest["icon"].as_str().unwrap(),
manifest["server"]["entry_point"].as_str().unwrap(),
] {
assert!(names.iter().any(|n| n == named), "{named} in {names:?}");
}
// The schema's required fields, by the schema's own list.
let schema: Value =
serde_json::from_str(include_str!("fixtures/mcpb/mcpb-manifest-v0.3.schema.json")).unwrap();
for field in schema["required"].as_array().unwrap() {
assert!(manifest.get(field.as_str().unwrap()).is_some(), "{field}");
}
for field in schema["properties"]["server"]["required"]
.as_array()
.unwrap()
{
assert!(manifest["server"].get(field.as_str().unwrap()).is_some());
}
}
#[test]
fn the_server_runs_this_programs_bridge_for_the_company() {
let (_dir, path) = made("Acme");
let (manifest, _) = read(&path);
let server = &manifest["server"];
assert_eq!(server["type"], "binary");
assert_eq!(
server["mcp_config"]["command"],
"/Applications/Wanderbooks.app/Contents/MacOS/wanderbooks"
);
assert_eq!(
server["mcp_config"]["args"],
serde_json::json!(["mcp", "--book", "acme"])
);
// The package carries no program (the one executable is the installed
// one) and no key.
let (_, names) = read(&path);
assert_eq!(names.len(), 3, "{names:?}");
assert_eq!(manifest["name"], "wanderbooks-acme");
}
/// The 512 px icon is a PNG (the manifest's `icon` is "a png icon file").
#[test]
fn the_icon_is_a_png() {
let (_dir, path) = made("Acme");
let mut zip = zip::ZipArchive::new(std::fs::File::open(path).unwrap()).unwrap();
let mut head = [0u8; 8];
zip.by_name("icon.png")
.unwrap()
.read_exact(&mut head)
.unwrap();
assert_eq!(&head, b"\x89PNG\r\n\x1a\n");
}
+10
View File
@@ -0,0 +1,10 @@
mcpb-manifest-v0.3.schema.json is Anthropic's published JSON Schema for the
manifest.json of an MCP Bundle (.mcpb, formerly the Desktop Extension .dxt),
manifest_version 0.3, copied verbatim on 2026-11-21 from
https://github.com/anthropics/mcpb (schemas/mcpb-manifest-v0.3.schema.json,
main branch). The specification's prose is MANIFEST.md in the same
repository; the install steps are Claude's help article "Getting started
with Local MCP servers on Claude Desktop" (support.claude.com).
The repository's licence: Apache-2.0 for new contributions, MIT for older
ones (its LICENSE file); both fit this project's MIT OR Apache-2.0. It is
a test fixture only and is not shipped.
@@ -0,0 +1,376 @@
{
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"dxt_version": {
"type": "string",
"const": "0.3",
"description": "@deprecated Use manifest_version instead"
},
"manifest_version": {
"type": "string",
"const": "0.3"
},
"name": {
"type": "string"
},
"display_name": {
"type": "string"
},
"version": {
"type": "string"
},
"description": {
"type": "string"
},
"long_description": {
"type": "string"
},
"author": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string",
"format": "email"
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"name"
],
"additionalProperties": false
},
"repository": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"type",
"url"
],
"additionalProperties": false
},
"homepage": {
"type": "string",
"format": "uri"
},
"documentation": {
"type": "string",
"format": "uri"
},
"support": {
"type": "string",
"format": "uri"
},
"icon": {
"type": "string"
},
"icons": {
"type": "array",
"items": {
"type": "object",
"properties": {
"src": {
"type": "string"
},
"size": {
"type": "string",
"pattern": "^\\d+x\\d+$"
},
"theme": {
"type": "string",
"minLength": 1
}
},
"required": [
"src",
"size"
],
"additionalProperties": false
}
},
"screenshots": {
"type": "array",
"items": {
"type": "string"
}
},
"localization": {
"type": "object",
"properties": {
"resources": {
"type": "string",
"pattern": "\\$\\{locale\\}"
},
"default_locale": {
"type": "string",
"pattern": "^[A-Za-z0-9]{2,8}(?:-[A-Za-z0-9]{1,8})*$"
}
},
"required": [
"resources",
"default_locale"
],
"additionalProperties": false
},
"server": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"python",
"node",
"binary"
]
},
"entry_point": {
"type": "string"
},
"mcp_config": {
"type": "object",
"properties": {
"command": {
"type": "string"
},
"args": {
"type": "array",
"items": {
"type": "string"
}
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"platform_overrides": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"command": {
"$ref": "#/properties/server/properties/mcp_config/properties/command"
},
"args": {
"$ref": "#/properties/server/properties/mcp_config/properties/args"
},
"env": {
"$ref": "#/properties/server/properties/mcp_config/properties/env"
}
},
"additionalProperties": false
}
}
},
"required": [
"command"
],
"additionalProperties": false
}
},
"required": [
"type",
"entry_point",
"mcp_config"
],
"additionalProperties": false
},
"tools": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false
}
},
"tools_generated": {
"type": "boolean"
},
"prompts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"arguments": {
"type": "array",
"items": {
"type": "string"
}
},
"text": {
"type": "string"
}
},
"required": [
"name",
"text"
],
"additionalProperties": false
}
},
"prompts_generated": {
"type": "boolean"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"license": {
"type": "string"
},
"privacy_policies": {
"type": "array",
"items": {
"type": "string",
"format": "uri"
}
},
"compatibility": {
"type": "object",
"properties": {
"claude_desktop": {
"type": "string"
},
"platforms": {
"type": "array",
"items": {
"type": "string",
"enum": [
"darwin",
"win32",
"linux"
]
}
},
"runtimes": {
"type": "object",
"properties": {
"python": {
"type": "string"
},
"node": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
"user_config": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"string",
"number",
"boolean",
"directory",
"file"
]
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"required": {
"type": "boolean"
},
"default": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"multiple": {
"type": "boolean"
},
"sensitive": {
"type": "boolean"
},
"min": {
"type": "number"
},
"max": {
"type": "number"
}
},
"required": [
"type",
"title",
"description"
],
"additionalProperties": false
}
},
"_meta": {
"type": "object",
"additionalProperties": {
"type": "object",
"additionalProperties": {}
}
}
},
"required": [
"name",
"version",
"description",
"author",
"server"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}