diff options
| author | Your Name <you@example.com> | 2026-05-18 03:37:27 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 03:37:27 +0530 |
| commit | 8a2f7a6c9423e0c00fae3c1233bee9e0bb3ae239 (patch) | |
| tree | 8f8d2ede379b7e3cc0da82d472bcf0eeedcbf03b /Makefile | |
| parent | fe7c3be2fd9d464dbc837d1913409d2691bd50f5 (diff) | |
feat: ContextVM (MCP over Nostr) server with WS masking fix
- Full CVM server: persistent WS relay listener, kind 25910 subscription
- MCP protocol handlers: initialize, tools/list, tools/call, ping
- 10 MCP tools: get_config, set_config, get_balance, wallet_send,
get_sessions, get_usage, set_payout, set_metric, set_price, wallet_melt
- CEP-6 announcements via WS (kinds 11316, 11317, 10002)
- Auth check: owner npub only
- Fix: WebSocket client-to-server frame masking (RFC 6455 requirement)
- Fix: Raw event JSON in EVENT wrapper (no re-parsing that breaks sig)
- SNTP init after STA gets IP
- 282 unit tests passing (61 CVM + 60 MCP handler + 161 existing)
- Integration test scaffold: tests/integration/test-cvm.mjs
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 41 |
1 files changed, 39 insertions, 2 deletions
| @@ -23,9 +23,10 @@ TOLLGATE_IP ?= 10.192.45.1 | |||
| 23 | .PHONY: flash flash-a flash-b monitor monitor-a monitor-b | 23 | .PHONY: flash flash-a flash-b monitor monitor-a monitor-b |
| 24 | .PHONY: test test-unit test-integration test-e2e test-all | 24 | .PHONY: test test-unit test-integration test-e2e test-all |
| 25 | .PHONY: test-smoke test-api test-network test-portal test-payment | 25 | .PHONY: test-smoke test-api test-network test-portal test-payment |
| 26 | .PHONY: test-reset-auth test-session-expiry test-dns-firewall | 26 | .PHONY: test-reset-auth test-session-expiry test-dns-firewall test-cvm |
| 27 | .PHONY: tokens wallet-setup wallet-info wallet-balance mint-token send-token | 27 | .PHONY: tokens wallet-setup wallet-info wallet-balance mint-token send-token |
| 28 | .PHONY: clean erase-nvs reset serial-log bootstrap-config | 28 | .PHONY: clean erase-nvs reset serial-log bootstrap-config |
| 29 | .PHONY: cvm-pubkey cvm-test-tool cvm-announce | ||
| 29 | 30 | ||
| 30 | help: | 31 | help: |
| 31 | @echo "TollGate ESP32 — Makefile" | 32 | @echo "TollGate ESP32 — Makefile" |
| @@ -50,6 +51,12 @@ help: | |||
| 50 | @echo " test-reset-auth Reset auth + per-client NAT filter test" | 51 | @echo " test-reset-auth Reset auth + per-client NAT filter test" |
| 51 | @echo " test-dns-firewall DNS hijack + NAT filter test" | 52 | @echo " test-dns-firewall DNS hijack + NAT filter test" |
| 52 | @echo " test-session-expiry Session lifecycle with 65s expiry wait" | 53 | @echo " test-session-expiry Session lifecycle with 65s expiry wait" |
| 54 | @echo " test-cvm ContextVM protocol integration test" | ||
| 55 | @echo "" | ||
| 56 | @echo "ContextVM:" | ||
| 57 | @echo " cvm-pubkey Print board's ContextVM npub" | ||
| 58 | @echo " cvm-announce Trigger re-publish of CEP-6 announcements" | ||
| 59 | @echo " cvm-test-tool Send single MCP tools/call (METHOD=get_config)" | ||
| 53 | @echo "" | 60 | @echo "" |
| 54 | @echo "Wallet:" | 61 | @echo "Wallet:" |
| 55 | @echo " wallet-setup Initialize nutshell wallet for test mint" | 62 | @echo " wallet-setup Initialize nutshell wallet for test mint" |
| @@ -153,7 +160,7 @@ test-unit: | |||
| 153 | @echo "=== Running host unit tests ===" | 160 | @echo "=== Running host unit tests ===" |
| 154 | $(MAKE) -C tests/unit test | 161 | $(MAKE) -C tests/unit test |
| 155 | 162 | ||
| 156 | test-integration: test-api test-network test-reset-auth test-dns-firewall | 163 | test-integration: test-api test-network test-reset-auth test-dns-firewall test-cvm |
| 157 | @echo "=== Integration tests passed ===" | 164 | @echo "=== Integration tests passed ===" |
| 158 | 165 | ||
| 159 | test-e2e: | 166 | test-e2e: |
| @@ -198,6 +205,10 @@ test-dns-firewall: | |||
| 198 | @echo "=== Running DNS + firewall test ===" | 205 | @echo "=== Running DNS + firewall test ===" |
| 199 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-dns-firewall.mjs | 206 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-dns-firewall.mjs |
| 200 | 207 | ||
| 208 | test-cvm: | ||
| 209 | @echo "=== Running CVM integration test ===" | ||
| 210 | TOLLGATE_IP=$(TOLLGATE_IP) $(NODE) tests/integration/test-cvm.mjs | ||
| 211 | |||
| 201 | # ────────────────────────────────────────────── | 212 | # ────────────────────────────────────────────── |
| 202 | # Wallet | 213 | # Wallet |
| 203 | # ────────────────────────────────────────────── | 214 | # ────────────────────────────────────────────── |
| @@ -230,6 +241,32 @@ send-token: | |||
| 230 | tokens: send-token | 241 | tokens: send-token |
| 231 | 242 | ||
| 232 | # ────────────────────────────────────────────── | 243 | # ────────────────────────────────────────────── |
| 244 | # ContextVM | ||
| 245 | # ────────────────────────────────────────────── | ||
| 246 | |||
| 247 | cvm-pubkey: | ||
| 248 | @echo "=== Board ContextVM npub ===" | ||
| 249 | @nak key public a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2 | xargs -I{} nak encode npub {} | ||
| 250 | @echo "" | ||
| 251 | @echo "Search for this npub on https://contextvm.org/servers" | ||
| 252 | |||
| 253 | cvm-announce: | ||
| 254 | @echo "=== Triggering CEP-6 re-announcement ===" | ||
| 255 | curl -s http://$(TOLLGATE_IP):2121/ | head -1 || echo "Board not reachable" | ||
| 256 | |||
| 257 | cvm-test-tool: | ||
| 258 | @METHOD=$${METHOD:-get_config}; \ | ||
| 259 | PARAMS=$${PARAMS:-{}}; \ | ||
| 260 | echo "=== Calling $$METHOD via CVM ==="; \ | ||
| 261 | NPUB_HEX=$$(nak key public a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2); \ | ||
| 262 | CONTENT="$$(echo "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"$$METHOD\",\"arguments\":$$PARAMS}}" | jq -c .)"; \ | ||
| 263 | EVENT_JSON="$$(nak event --kind 25910 --tag p=$$NPUB_HEX --content "$$CONTENT" wss://relay.damus.io 2>/dev/null)"; \ | ||
| 264 | echo "Published: $$EVENT_JSON"; \ | ||
| 265 | echo "Waiting for response..."; \ | ||
| 266 | sleep 3; \ | ||
| 267 | nak req -k 25910 -a $$NPUB_HEX -l 5 wss://relay.damus.io | ||
| 268 | |||
| 269 | # ────────────────────────────────────────────── | ||
| 233 | # Utilities | 270 | # Utilities |
| 234 | # ────────────────────────────────────────────── | 271 | # ────────────────────────────────────────────── |
| 235 | 272 | ||