NmpClient class is the orchestrator for Agent Nodes. It connects your Node.js or edge application to the Kademlia DHT Mesh, validates cryptographic identities, and dispatches WebAssembly logic payloads directly to remote Data Nodes (Servers).
Unlike traditional REST clients that just <fetch> static JSON endpoints, an NmpClient literally pushes its logic functions across the internet to be executed natively at the server.
Initialization and Configuration
Connecting to the Mesh requires instantiating the client with identification metadata and security properties.Configuration Options
When creating anNmpClient, the second argument configures its network footprint:
capabilities.roots: Declares if this agent supports specific protocol standards (like root hierarchy changes notifications).capabilities.quantumResistant: Forces the client to enforce Post-Quantum Handshakes (Kyber768) and symmetric encryption (AES-256-GCM) when dispatching WASM binaries to remote Data Nodes, guaranteeing maximum security against quantum decryption algorithms.
Connecting to the Mesh
Unlike MCP which requires a direct stdio pipe or a hardcoded SSE URL, NMP uses decentralized peer-to-peer routing. You provide a Peer ID (the unique Ed25519 identity of the Server you want to reach), and libp2p handles NAT traversal automatically.Calling a Server Capability (Tool)
Once connected, you can invoke capabilities exposed by any Data Node you trust. Under the hood, the SDK will bundle your intent into WASM and inject it over gRPC.Creating Watchdogs (Push Subscriptions)
The true power of Logic-on-Origin is the ability to spawn Watchdogs. Instead of manually pollingclient.callTool() every 5 seconds, you upload a persistent watcher module.
Cryptographic Validation (The ZK Shield)
While the network layer is encrypted using symmetric AES-256-GCM, theNmpClient fundamentally doubts the execution origin.
When callTool returns from the remote Data Node, the payload might contain an image_id hash or a zk_receipt (if the server is running inside a TEE). To mathematically prove the server executed the exact WASM binary you originally sent (and not a tampered one), you must invoke the cryptographic verifier:
NmpMcpBridge automatically runs this capability natively on behalf of legacy MCP clients, intercepting any hallucinated JSONs automatically.
Error Handling & Zero-Trust Rejections
Because the Server enforces a strictWASI sandbox and uses the Zero-Time Guardian to inspect your .wasm payload BEFORE execution, your client must be prepared to handle sandbox rejections.