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.
28 lines
918 B
C
28 lines
918 B
C
/* A tools bundle in C: one tool of its own and one seat verb, served over stdio. */
|
|
#include "mesh_sdk.h"
|
|
#include <stdio.h>
|
|
|
|
static json_t *greet(json_t *args, char **error) {
|
|
(void)error;
|
|
const char *who = json_string_value(json_object_get(args, "who"));
|
|
char greeting[128];
|
|
snprintf(greeting, sizeof greeting, "hello %s", who ? who : "world");
|
|
return json_pack("{s:s,s:s}", "greeting", greeting, "language", "c");
|
|
}
|
|
|
|
static json_t *on(json_t *args, char **error) {
|
|
(void)args; (void)error;
|
|
return json_pack("{s:b,s:s}", "on", 1, "language", "c");
|
|
}
|
|
|
|
int main(void) {
|
|
json_t *who = json_pack("{s:{s:s,s:s}}", "who", "type", "string", "description", "whom");
|
|
const mesh_tool tools[] = {
|
|
{"greet", "say hello", who, greet},
|
|
{"node-lamp.on", "the seat's verb", NULL, on},
|
|
};
|
|
int rc = mesh_serve("c-example", tools, 2);
|
|
json_decref(who);
|
|
return rc;
|
|
}
|