Files
mesh-sdk/go/example/main.go
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
796 B
Go

// A tools bundle in Go: one tool of its own and one seat verb, served over stdio.
package main
import (
"fmt"
"os"
stdio "git.novox.be/novox/mesh-sdk/go"
)
func main() {
err := stdio.Serve("go-example", []stdio.Tool{
{Name: "greet", Description: "say hello", Input: map[string]any{"who": map[string]any{"type": "string", "description": "whom"}},
Run: func(a map[string]any) (any, error) {
who, _ := a["who"].(string)
if who == "" {
who = "world"
}
return map[string]any{"greeting": "hello " + who, "language": "go"}, nil
}},
{Name: "node-lamp.on", Description: "the seat's verb", Run: func(map[string]any) (any, error) {
return map[string]any{"on": true, "language": "go"}, nil
}},
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}