Start building with NMP in under 5 minutes using the official TypeScript SDK
The Neural Mesh Protocol (NMP) provides the @nekzus/neural-mesh, designed as a powerful yet highly familiar SDK. If you have previously built servers for MCP, transitioning to NMP architecture is almost effortless.In this guide, we’ll build a basic NMP Server that exposes a tool, and a Client that invokes it.
Under the hood, NMP is compiling your logic to WebAssembly and injecting it via P2P. However, the SDK abstracts this entirely, letting you focus on writing pure business logic.
An NMP Server acts as a Data Node. It connects to the mesh and listens for incoming injected logic from remote agents. It exposes secure tools and resources.Create a file named server.ts:
server.ts
Copy
import { NmpServer } from '@nekzus/neural-mesh';import { z } from 'zod';// Initialize the Server with identity and capabilitiesconst server = new NmpServer({ name: "MyLocalDataNode", version: "1.0.0"});// Expose a tool. // Note: In NMP, the async logic provided here is dynamically converted // into an isolated Capability for incoming WASM Agents.server.tool( "query_database", "Analyzes giant tables exactly at the origin. Pass a SQL-like string.", { query: z.string() }, async ({ query }) => { console.log(`[Server] Executing Logic-on-Origin for query: ${query}`); // Imagine processing 5GB of local data here. // Only the final result leaves the server. return { content: [{ type: "text", text: `Processed query results for: ${query}` }] }; });// Start the server and announce it to the Kademlia DHT Meshasync function main() { await server.connect(); console.log("NMP Server is listening on the Mesh...");}main().catch(console.error);
Now that you’ve run your first Mesh execution, dive deeper into the core architecture to understand how to leverage advanced capabilities like Continuous Watchdogs and Zero-Knowledge Proofs.
Core Architecture
Learn how the Data Layer and Transport Layer synergize in NMP.