diff options
| author | Your Name <you@example.com> | 2026-05-19 01:10:06 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 01:10:06 +0530 |
| commit | 42902a36bc52e009a1e8d3c371741e30a9cb4c33 (patch) | |
| tree | 46db33710a3650b2267933a8375d3598af11319a /main/mcp_handler.h | |
| parent | fe7c3be2fd9d464dbc837d1913409d2691bd50f5 (diff) | |
feat: ContextVM (MCP over Nostr) server with full integration
Complete CVM implementation: persistent WebSocket relay listener,
kind 25910 event subscription, MCP protocol handlers, CEP-6 announcements,
10 MCP tools, per-board hardware locks, WiFi EU regulatory fix.
Architecture:
- cvm_server.c: WS relay listener, kind 25910 subscription, MCP dispatch
- mcp_handler.c/h: 10 MCP tools (get_config, set_config, get_balance,
wallet_send, get_sessions, get_usage, set_payout, set_metric,
set_price, wallet_melt)
- Responses published via existing WS connection (not new TLS)
- Auth check: only owner npub accepted
- CEP-6: kinds 11316 (server), 11317 (tools), 10002 (relay list)
- WS ping/pong keepalive every 30s, 60s TLS read timeout
Critical fixes:
- WiFi country code DE (ESP-IDF defaults to CN, breaks EU APs)
- Subscription #p filter must be array not string
- Use-after-free: tags_str freed before nostr_event_to_json
- MCP responses via existing WS (ESP32 can't open multiple TLS)
- EVENT msg buffer underflow, WS frame masking, TLS write loop
Per-board hardware locks:
- Lock files in physical-router-test-automation/locks/
- lock-a/b/c, unlock-a/b/c targets in 3 Makefiles
- All hardware-touching targets require board lock
Verified on Board B via relay.primal.net:
- 282 unit tests passing (61 CVM + 60 MCP + 161 existing)
- MCP initialize roundtrip: PASS
- tools/list: PASS
- tools/call get_config: PASS
- tools/call get_balance: PASS
- tools/call set_price: PASS (write operation)
- CEP-6 announcements (11316, 11317, 10002): all accepted by relay
- WiFi STA connection (EnterSSID-2.4GHz): PASS with country code DE
- Board A WiFi confirmed hardware issue (not firmware)
Diffstat (limited to 'main/mcp_handler.h')
| -rw-r--r-- | main/mcp_handler.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/main/mcp_handler.h b/main/mcp_handler.h index e42b5ee..09aab9f 100644 --- a/main/mcp_handler.h +++ b/main/mcp_handler.h | |||
| @@ -9,6 +9,12 @@ typedef enum { | |||
| 9 | MCP_TOOL_SET_CONFIG = 1, | 9 | MCP_TOOL_SET_CONFIG = 1, |
| 10 | MCP_TOOL_GET_BALANCE = 2, | 10 | MCP_TOOL_GET_BALANCE = 2, |
| 11 | MCP_TOOL_WALLET_SEND = 3, | 11 | MCP_TOOL_WALLET_SEND = 3, |
| 12 | MCP_TOOL_GET_SESSIONS = 4, | ||
| 13 | MCP_TOOL_GET_USAGE = 5, | ||
| 14 | MCP_TOOL_SET_PAYOUT = 6, | ||
| 15 | MCP_TOOL_SET_METRIC = 7, | ||
| 16 | MCP_TOOL_SET_PRICE = 8, | ||
| 17 | MCP_TOOL_WALLET_MELT = 9, | ||
| 12 | MCP_TOOL_UNKNOWN = 99 | 18 | MCP_TOOL_UNKNOWN = 99 |
| 13 | } mcp_tool_t; | 19 | } mcp_tool_t; |
| 14 | 20 | ||
| @@ -30,6 +36,12 @@ mcp_response_t mcp_handle_get_config(void); | |||
| 30 | mcp_response_t mcp_handle_set_config(const char *params_json); | 36 | mcp_response_t mcp_handle_set_config(const char *params_json); |
| 31 | mcp_response_t mcp_handle_get_balance(void); | 37 | mcp_response_t mcp_handle_get_balance(void); |
| 32 | mcp_response_t mcp_handle_wallet_send(const char *params_json); | 38 | mcp_response_t mcp_handle_wallet_send(const char *params_json); |
| 39 | mcp_response_t mcp_handle_get_sessions(void); | ||
| 40 | mcp_response_t mcp_handle_get_usage(void); | ||
| 41 | mcp_response_t mcp_handle_set_payout(const char *params_json); | ||
| 42 | mcp_response_t mcp_handle_set_metric(const char *params_json); | ||
| 43 | mcp_response_t mcp_handle_set_price(const char *params_json); | ||
| 44 | mcp_response_t mcp_handle_wallet_melt(const char *params_json); | ||
| 33 | 45 | ||
| 34 | mcp_response_t mcp_dispatch(const mcp_request_t *req); | 46 | mcp_response_t mcp_dispatch(const mcp_request_t *req); |
| 35 | 47 | ||