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:
@@ -13,12 +13,14 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/david/knox/internal/db"
|
||||
"github.com/david/knox/internal/httpauth"
|
||||
"github.com/david/knox/internal/metrics"
|
||||
)
|
||||
|
||||
@@ -237,7 +239,7 @@ func (c *Client) Push(kdb *db.KnoxDB, peerVector map[string]int64) (int, error)
|
||||
return 0, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := (&http.Client{Timeout: c.Timeout}).Do(req)
|
||||
resp, err := httpauth.Client(c.Timeout).Do(req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -257,7 +259,7 @@ func (c *Client) get(url string, v any) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := (&http.Client{Timeout: c.Timeout}).Do(req)
|
||||
resp, err := httpauth.Client(c.Timeout).Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -398,6 +400,22 @@ func vectorMax(v map[string]int64) int64 {
|
||||
return m
|
||||
}
|
||||
|
||||
// isLoopbackAddr reports whether a listen address is only reachable locally.
|
||||
// An empty host (":8931") binds every interface and is therefore not loopback.
|
||||
func isLoopbackAddr(addr string) bool {
|
||||
host, _, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if host == "" {
|
||||
return false
|
||||
}
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
return ip.IsLoopback()
|
||||
}
|
||||
return host == "localhost"
|
||||
}
|
||||
|
||||
// ListenAddr returns the advertised HTTP address (KNOX_PEER_ADDR or default).
|
||||
func ListenAddr() (addr string) {
|
||||
if addr = os.Getenv("KNOX_PEER_ADDR"); addr != "" {
|
||||
|
||||
Reference in New Issue
Block a user