Files
mesh-sdk/c/mesh_sdk.h
T
jochen 78817c949e A tools bundle speaks MCP over stdio: the loop in TypeScript, and skeleton SDKs for Python, Go, Rust and C (hq ADR 0187)
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.
2026-10-02 20:34:19 +02:00

30 lines
1.2 KiB
C

/* The Novox Mesh SDK for C — the skeleton (novox/hq ADR 0187).
*
* A tools bundle is a process the node's runtime launches and speaks MCP over stdio to:
* `initialize`, `tools/list` once, `tools/call` per call, newline-framed JSON-RPC on stdin and
* stdout. This is the loop, so a bundle writes its tools and nothing else. A tool named
* `<seat>.<verb>` is the module's implementation of that seat's verb; any other name is the
* module's own. JSON is jansson's.
*
* No transport here: the bus, the subjects and the memberships are the runtime's (ADR 0039, 0175).
* stdout is the protocol; log to stderr. */
#ifndef MESH_SDK_H
#define MESH_SDK_H
#include <jansson.h>
#define MESH_SDK_PROTOCOL "2025-03-26"
/* One tool. `run` returns a new JSON value (the answer) or NULL with *error set to a message the
* caller frees. `input` is the schema of the arguments, or NULL for a tool that takes nothing. */
typedef struct {
const char *name;
const char *description;
json_t *input;
json_t *(*run)(json_t *args, char **error);
} mesh_tool;
/* Serve these tools on stdin/stdout until stdin closes. Returns 0, or -1 on an I/O fault. */
int mesh_serve(const char *name, const mesh_tool *tools, size_t count);
#endif