feat: mcp over http on the official sdk, tls/token transport, docker, sqlc (#8)
MCP moves from mark3labs/mcp-go v0.17 (stdio only, 5 releases behind) to the official modelcontextprotocol/go-sdk with typed tool inputs, and gains a Streamable HTTP transport so a remote node can serve agents. Transport security works without a public DNS name: KNOX_AUTH_TOKEN guards every endpoint, KNOX_TLS_CERT/KEY serve TLS from a self-signed cert, and `knox tls init` mints one whose SANs are whatever addresses clients dial. Daemon hygiene for an always-on host: SIGTERM shutdown of the gossip and metrics servers, --version reporting the VCS revision, KNOX_LOCAL_SOURCES=none for a replicate-only node (no ingest tickers, no Obsidian vault adoption), and default watch dirs that skip paths which do not exist. Packaging: multi-stage Dockerfile (static, non-root, /data volume). sqlc pilot: schema moved to internal/db/schema.sql (embedded) and the read paths behind the MCP tools are now generated. The pilot found real drift — entries.created_at existed only as a runtime ALTER — so the column is declared in schema.sql and a parity test fails if generated code disagrees with db.Open. Conformance: scripts/conformance.sh runs the official suite against a throwaway node; conformance-baseline.yml records the capabilities knox deliberately does not implement (resources, prompts, completions, fixture tools). Refs #8
This commit is contained in:
+1024
-1004
File diff suppressed because it is too large
Load Diff
+23
-1
@@ -1,10 +1,13 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/watch"
|
||||
@@ -26,6 +29,16 @@ func NewWatchCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
}
|
||||
log.Printf("[knox] starting watcher, scanning %d directories", len(dirs))
|
||||
w := watch.New(kdb, dirs)
|
||||
|
||||
// A container sends SIGTERM on stop; shut down the HTTP servers so
|
||||
// restarts are clean instead of dropping the listeners abruptly.
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer stop()
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
w.Shutdown()
|
||||
}()
|
||||
|
||||
if err := w.Start(); err != nil {
|
||||
// Not log.Fatalf: --quiet redirects the logger to io.Discard,
|
||||
// so a fatal exit must reach the user on stderr directly.
|
||||
@@ -41,8 +54,17 @@ func NewWatchCmd(kdb *db.KnoxDB) *cobra.Command {
|
||||
|
||||
func defaultWatchDirs() []string {
|
||||
home, _ := getHomeDir()
|
||||
return []string{
|
||||
candidates := []string{
|
||||
home + "/.local/share/opencode/log",
|
||||
home + "/.skills",
|
||||
}
|
||||
// A headless node has none of these; watch nothing rather than logging a
|
||||
// failed watch for every missing path.
|
||||
dirs := make([]string, 0, len(candidates))
|
||||
for _, d := range candidates {
|
||||
if info, err := os.Stat(d); err == nil && info.IsDir() {
|
||||
dirs = append(dirs, d)
|
||||
}
|
||||
}
|
||||
return dirs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user