The node's runtime launches a tools bundle as a process and speaks MCP over stdio to it, so a tool may be written in any language and the transport stays in the runtime (ADR 0039's refusal, kept). Each SDK is the loop and the tool type and nothing else: `@novox/mesh-sdk/stdio` (serveStdio, and serveRegisteredOverStdio for a bundle that already registers the in-process way), python/, go/, rust/ and c/ beside it, each with an example answering `greet` and the seat verb `node-lamp.on`. Skeletons, by the operator's direction: the bare minimum one bundle per language needs to be built and answer, proven here by each example answering tools/list and tools/call on stdio.
20 lines
774 B
Rust
20 lines
774 B
Rust
// A tools bundle in Rust: one tool of its own and one seat verb, served over stdio.
|
|
use mesh_sdk::{serve, Tool};
|
|
use serde_json::{json, Map, Value};
|
|
|
|
fn greet(a: &Map<String, Value>) -> Result<Value, String> {
|
|
let who = a.get("who").and_then(Value::as_str).unwrap_or("world");
|
|
Ok(json!({"greeting": format!("hello {}", who), "language": "rust"}))
|
|
}
|
|
|
|
fn on(_: &Map<String, Value>) -> Result<Value, String> {
|
|
Ok(json!({"on": true, "language": "rust"}))
|
|
}
|
|
|
|
fn main() -> std::io::Result<()> {
|
|
serve("rust-example", &[
|
|
Tool { name: "greet", description: "say hello", input: json!({"who": {"type": "string", "description": "whom"}}), run: greet },
|
|
Tool { name: "node-lamp.on", description: "the seat's verb", input: json!({}), run: on },
|
|
])
|
|
}
|