feat(mcp): the remote door and the sign-in behind it (P15 B1, D-83, D-86)
A second HTTP listener in the books server, on 127.0.0.1 only, off until the app's admin request (RemoteStart) names the one public address. Every connection begins with the relay's PROXY v2 header, whose address is the caller's (never an HTTP header); the door speaks stateless plain-JSON MCP for one company per path, and is its own OAuth 2.1 server: metadata at every place products look, client ID metadata documents, dynamic registration and a typed client id and secret, PKCE S256, exact redirects, single-use short codes, rotated refresh tokens (a reused one ends its family), short access tokens, the issuer pinned. /authorize never approves: it parks the request and only the owner-only admin socket turns it into a code. An approval is one principals token (so A4's list and revoke see it) plus a record naming the product, which survives the product registering again. Read and draft by default; posting raised per approval. Every table is bounded and expires; secrets are kept as SHA-256 only. A stranger's unsigned request is a 401 with the metadata pointer and is counted, never written to the books' record. The access record gains an optional 'from' (the caller's address), kept as an IP when it is one (the TIN masking would turn it to dots). The tools a model reaches for first now carry the company's name and 'call books.start first' in their own descriptions (plan 3.4), local and remote. Dependencies: none new to the tree. reqwest (client documents, as ledger-host already uses it), subtle, getrandom and hyper-util (already pulled in by ledger-store and axum) are now declared by ledger-mcp; cargo deny and the notices check pass unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
eafd269ba0
commit
e00e52f2f3
15 files changed
+5839
-41
No files matched your search
@@ -32,10 +32,44 @@
|
||||
//! for books that declared the journal feature
|
||||
//! `document_line_projects`; for the rest, that they wait for their
|
||||
//! format upgrade (BS-format-1, BS-statement-5 statement 6).
|
||||
//! 7. The company's name and the entry point also stand in the
|
||||
//! description of the tools a model reaches for first
|
||||
//! ([`FIRST_TOOLS`], decorated in `list_tools` by
|
||||
//! [`first_tools_lead`]), for local and remote callers alike: some
|
||||
//! products keep only the first 512 characters of the instructions
|
||||
//! (ChatGPT), and one is reported to drop them (claude.ai, 2026-03,
|
||||
//! unverified since), while a tool's description always arrives
|
||||
//! (plan/p15-app-and-relay.md 3.4, WB-assist-5).
|
||||
//! ```
|
||||
|
||||
use crate::settings::Settings;
|
||||
|
||||
/// The tools a model reaches for first: each one's description begins with
|
||||
/// [`first_tools_lead`] (INVARIANT 7).
|
||||
pub const FIRST_TOOLS: &[&str] = &[
|
||||
"books.start",
|
||||
"books.handbook",
|
||||
"books.chart",
|
||||
"books.show",
|
||||
"books.digest",
|
||||
"books.search_entries",
|
||||
"books.draft_entry",
|
||||
"books.post_entry",
|
||||
];
|
||||
|
||||
/// What begins the description of every tool in [`FIRST_TOOLS`]: the
|
||||
/// company, and the entry point, so they reach a model whatever the
|
||||
/// product does with the server's instructions.
|
||||
pub fn first_tools_lead(settings: &Settings) -> String {
|
||||
let unnamed = ledger_config::Company::default().name;
|
||||
let name = if settings.company.name.trim() == unnamed {
|
||||
shown_name("")
|
||||
} else {
|
||||
shown_name(&settings.company.name)
|
||||
};
|
||||
format!("For the books of {name}: call books.start first in every session. ")
|
||||
}
|
||||
|
||||
/// The most characters the connect text may have.
|
||||
pub const CONNECT_MAX: usize = 1400;
|
||||
|
||||
|
||||
Reference in new issue
Block a user