Skip to main content

Documentation Index

Fetch the complete documentation index at: https://nekzus-32.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The Logic-Injection-on-Origin Protocol (LIOP) provides the @nekzus/liop, designed as a powerful yet highly familiar SDK. If you have previously built servers for MCP, transitioning to LIOP architecture is almost effortless. In this guide, we’ll build a basic LIOP Server that exposes a tool, and a Client that invokes it.
Under the hood, LIOP 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.

1. Installation

Install the official SDK in your Node.js or TypeScript project.
npm install @nekzus/liop zod

2. Create a LIOP Server (Data Node)

A LIOP 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
import { LiopServer } from '@nekzus/liop';
import { z } from 'zod';

// Initialize the Server with identity
const server = new LiopServer({
  name: "MyLocalDataNode",
  version: "1.0.0"
});

// Expose a tool. 
// Note: In LIOP, 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-Injection-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 Mesh
async function main() {
  await server.connect();
  console.log("LIOP Server is listening on the Mesh...");
}

main().catch(console.error);

3. Create a LIOP Client (Agent Node)

A LIOP Client acts as the Intelligence. It discovers servers on the mesh and injects compiled logic into them. Create a file named client.ts:
client.ts
import { LiopClient } from '@nekzus/liop';

async function main() {
  // Initialize the Client (TLS options are optional for local development)
  const client = new LiopClient();

  // Connect to the mesh
  await client.connect();
  console.log("Joined LIOP Protocol...");

  // Discover the server's tools and invoke logic
  try {
    // Invoke the tool using a CallToolRequest
    const result = await client.callTool({
      name: "query_database",
      arguments: {
        query: "SELECT * FROM massive_table WHERE anomaly = true"
      }
    });

    console.log("Received verified result:");
    console.log(result.content[0].text);
  } catch (err) {
    console.error("Agent execution failed:", err);
  }
}

main().catch(console.error);

4. Run your Mesh

First, start your isolated Server:
npx tsx server.ts
# Output: LIOP Server is listening on the Mesh...
In a separate terminal, unleash your Agent:
npx tsx client.ts
# Output: Joined LIOP Protocol...
# Output: Received mathematically-verified result:
# Output: Processed query results for: SELECT * FROM massive_table WHERE anomaly = true

What just happened?

Unlike legacy REST APIs or MCP strings parsing:
  1. Your Client discovered the Server instantly via a P2P Kademlia Routing Table.
  2. A Post-Quantum Kyber Handshake secured the intent.
  3. The query was serialized into an ultra-compact Protobuf Binary.
  4. The execution happened inside a microscopic WASI Sandbox on the server, safely isolated from your physical host.

Next Steps

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 LIOP.