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
//! A program's own MCP server: the Model Context Protocol on stdin and
//! stdout, a JSON-RPC message a line, as `tinystore mcp` answers it. A tool is
//! a value with a mark, read, write or remove, which an agent's host reads to
//! ask its person before each tool that changes something; a tool that
//! writes or removes is offered only when the allow list, the program's
//! `--write`, names it. tinystore's own read tools mount beside the
//! program's, on the store it holds.
//!
//! ```no_run
//! use serde_json::json;
//! use tinystore::mcp::{self, Tool};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let store = tinystore::Store::open("data", Default::default())?;
//! let write = std::env::args().skip_while(|arg| arg != "--write").nth(1);
//! let name = json!({ "type": "object", "properties": { "name": { "type": "string" } }, "required": ["name"] });
//! mcp::server("dashbin", env!("CARGO_PKG_VERSION"))
//! .instructions("Read dashbin's dashboards and the store under them.")
//! .tools(mcp::read_tools(&store).prefix("store_")) // store_logs, store_kv_get, …
//! .tool(Tool::reads("dashboards_list", "The project's dashboards.", json!({ "type": "object" }), |_| {
//! Ok(json!([{ "name": "latency" }]))
//! }))
//! .tool(Tool::writes("dashboard_save", "Saves a dashboard.", name.clone(), |given| {
//! let name = given["name"].as_str().ok_or("dashboard_save takes name")?;
//! Ok(json!({ "saved": name }))
//! }))
//! .tool(Tool::removes("dashboard_delete", "Deletes a dashboard.", name, |_| Ok(json!({ "deleted": true }))))
//! .allow(write.as_deref()) // none, "all", or "dashboard_save,dashboard_delete"
//! .serve()?; // answers stdin until it closes
//! # Ok(())
//! # }
//! ```
//!
//! The modules below the server's own are the reads tinystore's tools make
//! and the JSON they answer, which the command line's `--json` prints too:
//! hidden, since they promise a program nothing.
pub use Server;
pub use read_tools;
pub use read_tools_in;
pub use ;
/// A server named `name` at `version`, as the agent's host lists it, with no
/// tool yet.