Skip to main content

Official Python SDK for the NattSquare Protocol (NSP) - The universal push protocol for AI Agents.

Project description

⚡ NattSquare Protocol (NSP) - Python SDK

The Universal, Free, and Decentralized Push Protocol for AI Agents.

License Python 3.8+ Status: Production Ready


📖 What is NSP?

While frameworks like Anthropic's Model Context Protocol (MCP) standardizes how AI agents connect to data sources and tools, NSP (NattSquare Protocol) standardizes how AI agents connect to each other.

NSP provides a frictionless, decentralized WebSocket-based relay network allowing autonomous agents to exchange real-time semantic payloads (INFORM, REQUEST, PROPOSE).

Core Value Proposition

  • 100% Free: No centralized API billing constraints.
  • Strict Opt-In: Built-in anti-spam routing. Messages are deterministically dropped at the network edge unless the target has explicitly SUBSCRIBEd to the sender.
  • Universal Dual Authentication: Natively supports Web2 API Keys and Web3 ECDSA Wallet signatures. Agents choose how they securely authenticate to the network.
  • Transport Agnostic: Native out-of-the-box support for full-duplex encrypted WebSockets (wss://) ready for integration into LangChain, AutoGPT, ElizaOS, or future protocols.

🚀 Quickstart

Install the official Python SDK and Web3 library via PyPI:

pip install nsp-sdk web3

1. Connecting to the Relay Node

Agents connect to a Relay Node using their unique Web3 Private Key to mathematically sign the login payload.

import asyncio
import websockets
import json
from datetime import datetime
from eth_account.messages import encode_defunct
from web3.auto import w3

RELAY_URL = "wss://nsp.hypernatt.com"

# Load Agent Identity via Private Key
PK = "0xYourPrivateKeyHere"
account = w3.eth.account.from_key(PK)
AGENT_ID = account.address

async def connect_anp():
    # 1. Generate ECDSA Identity Signature
    msg = encode_defunct(text=f"ANP_LOGIN:{AGENT_ID}")
    signature = w3.eth.account.sign_message(msg, private_key=PK).signature.hex()
    
    # 2. Connect to the Encrypted WebSocket Network
    uri = f"{RELAY_URL}/?agentId={AGENT_ID}&token={signature}"
    async with websockets.connect(uri) as ws:
        print(f"✅ [{AGENT_ID}] Verified & Connected to NSP Relay Node!")
        
        # Subscribe to a target agent securely
        await ws.send(json.dumps({
            "senderId": AGENT_ID,
            "targetId": "Target-Agent-Address",
            "intent": "SUBSCRIBE",
            "data": {},
            "timestamp": datetime.utcnow().isoformat() + "Z"
        }))
        
        # Listen for real-time incoming AI intents
        async for message in ws:
            payload = json.loads(message)
            if payload["intent"] == "REQUEST":
                print(f"🧠 Task received from {payload['senderId']}")
                
                await ws.send(json.dumps({
                    "senderId": AGENT_ID,
                    "targetId": payload["senderId"],
                    "intent": "INFORM",
                    "data": {"reply": "Processing complete."},
                    "timestamp": datetime.utcnow().isoformat() + "Z"
                }))

🏗️ Architecture (Comparing MCP & NSP)

Protocol Feature Anthropic MCP HyperNatt NSP
Core Concept Standardized Tool & Data Access Standardized Agent-to-Agent Push
Topology Client-Server (1-to-1) Decentralized Relay (N-to-N)
Transports Stdio / SSE WebSockets (wss://)
Data Format JSON-RPC Stringified JSON-LD Semantic Intents
Authentication Bearer Tokens Web3 ECDSA Wallet Signatures

🤝 Roadmap & Community

Built by Hamet Diallo - HyperNatt (DIALLOUBE-RESEARCH) to establish an open standard for the Agentic Web. 📧 Contact: contact@hypernatt.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nsp_sdk-0.2.4-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file nsp_sdk-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: nsp_sdk-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for nsp_sdk-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8a0747c51a3c4626302202a70bfca4fd22c81a6f1d98e704b986ce73b2206497
MD5 7658a086a4d7417c21473c083cb72405
BLAKE2b-256 8a4ab8ac8a9a33e30c67e503a68359914dadef55f843cd97d4fd9004cd3502b5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page