Merge commit '52c4d1f' into feat/remote-node
# Conflicts: # internal/db/db.go
This commit is contained in:
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run the official MCP conformance suite against a knox MCP HTTP endpoint.
|
||||
#
|
||||
# scripts/conformance.sh # start a throwaway node
|
||||
# KNOX_MCP_URL=http://host:8930/ scripts/conformance.sh # test a running node
|
||||
#
|
||||
# A throwaway node uses a temporary database, so nothing here touches the real
|
||||
# index. Exit code is the suite's: 0 when everything outside the baseline passes.
|
||||
set -euo pipefail
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
addr="${KNOX_CONF_ADDR:-127.0.0.1:18940}"
|
||||
url="${KNOX_MCP_URL:-http://${addr}/}"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${pid:-}" ]]; then
|
||||
kill "$pid" 2>/dev/null || true
|
||||
wait "$pid" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ -z "${KNOX_MCP_URL:-}" ]]; then
|
||||
tmpdb="$(mktemp -d)"
|
||||
go build -o "${tmpdb}/knox" "$root"
|
||||
KNOX_DB="${tmpdb}/index.db" "${tmpdb}/knox" mcp --http "$addr" &
|
||||
pid=$!
|
||||
# Wait for the endpoint to accept requests rather than sleeping blindly. A
|
||||
# stale listener on the port would otherwise be tested by mistake, so fail
|
||||
# loudly if the child never comes up.
|
||||
ready=""
|
||||
for _ in $(seq 1 50); do
|
||||
if ! kill -0 "$pid" 2>/dev/null; then
|
||||
echo "error: knox exited before serving on ${addr} (port in use?)" >&2
|
||||
exit 1
|
||||
fi
|
||||
if curl -sf -o /dev/null -X POST "$url" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Accept: application/json, text/event-stream' \
|
||||
-d '{"jsonrpc":"2.0","id":1,"method":"ping"}'; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
sleep 0.2
|
||||
done
|
||||
if [[ -z "$ready" ]]; then
|
||||
echo "error: knox did not become ready on ${addr}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
npx -y @modelcontextprotocol/conformance@latest server \
|
||||
--url "$url" \
|
||||
--expected-failures "$root/conformance-baseline.yml" \
|
||||
"$@"
|
||||
Reference in New Issue
Block a user