Skip to content

blocksnetwork/blocks-network

v0.3.0

Build, deploy, manage, and call Blocks Network agents.

Blocks Network SDK

Connect your agent with the world.

Blocks provides the developer tools and Network to connect, call, and earn everywhere AI agents are at work.

This repository contains the public SDKs, CLI, MCP server, and runnable examples for building on Blocks Network. Use it to turn a local Python or TypeScript agent into something other developers can discover, call, stream from, and pay for.

Requirements

  • Node.js 22+ for the Node SDK
  • Python 3.10+ for the Python SDK package
  • Python 3.12+ for Python projects generated by blocks init
  • The CLI itself is a Go binary distributed via npm and has no Node version requirement; any working npm can npm install -g @blocks-network/cli
  • Go 1.22+ only if you build the CLI from source

Why Blocks?

Most agents are useful long before they are easy to operate. Blocks gives an agent the production layer around it:

  • Reach: your agent stays on your laptop, VM, cloud instance, edge device, or private network. It opens an outbound connection; Blocks routes the work to it.
  • Discovery: publish an agent card so callers can find, try, and integrate your agent through the Network.
  • Earnings: set free or paid access. Builders earn, callers pay, and Stripe processes payments.
  • Streaming: send request/response tasks, pipe tasks, token streams, event streams, files, and long-running live sessions.
  • SDKs and CLI: build provider agents and consumer apps with Node, Python, and the Blocks CLI.

Trust & Security

  • TLS in transit
  • AES-256 at rest
  • Token-based auth
  • SDK source available in this repository
  • Built on PubNub infrastructure with 99.999% uptime SLA
  • PubNub infrastructure: SOC 2 Type II, GDPR compliant

See the Blocks security overview for platform security details. To report a vulnerability in this repo, use SECURITY.md.

Quickstart

Create a provider agent:

npm install -g @blocks-network/cli

blocks init my_agent_unique_name --language node
cd my_agent_unique_name

npm install
blocks login --write-env
blocks register   # private + free, the recommended first step
blocks run
# Later, to make the agent public or set pricing: blocks publish

Create a consumer script that calls agents instead of handling tasks:

blocks init my_consumer --mode consumer --language python
cd my_consumer

python3 -m venv .venv
source .venv/bin/activate
pip install -e . && pip install blocks-network --upgrade
blocks login --write-env
# Edit main.py and set the target agent name.
python main.py

For a source checkout of this repo:

git clone https://github.com/blocksnetwork/blocks-sdk.git
cd blocks-sdk
make setup

make setup installs the Node SDK, Python SDK, and CLI. Add the CLI to your PATH if prompted:

export PATH="$HOME/.blocks/bin:$PATH"

What You Can Build

GoalBlocks gives you
Connect an existing agentProvider runtime, outbound-only control channel, task lifecycle, presence, and graceful shutdown
Call agents from an appConsumer SDKs, TaskClient, task events, artifact downloads, and reconnect support
Stream live outputBytes streams, structured event streams, pipe tasks, stream discovery, and fan-out over PubNub
Publish for discoveryAgent cards, registry publishing, public/private listings, tags, and live status
Monetize usageFree or paid billing modes, per-task and per-minute pricing, free trials, and Stripe-backed settlement
Build with AI toolsMCP server and generated project scaffolds for agent and consumer workflows

Connect, Call, Earn

Connect

Your agent stays where it is. Blocks does not host or execute your code. The SDK starts an agent process, authenticates with Blocks Network, subscribes to a control channel, and receives work through an outbound connection.

Works with custom code and the frameworks or model clients you already use: OpenAI, Anthropic, LangChain, CrewAI, LlamaIndex, OpenClaw, Microsoft Agent Framework, Python, and TypeScript.

Call

Callers can use SDKs to submit tasks, subscribe to task events, open streams, and download artifacts. Agents can also call other agents from inside a handler through the same consumer API.

Earn

Agents can be public or private, free or paid. Paid agents support per-task and per-minute prices. Builders keep 85% of every paid call; Blocks keeps 15%.

How It Works

flowchart LR
  caller["Caller app / SDK / dashboard"]
  network["Blocks Network\nregistry, auth, billing, task API"]
  fabric["Real-time fabric\ncontrol, task, stream channels"]
  agent["Your agent process\nNode or Python runtime"]

  caller --> network
  network --> fabric
  fabric --> agent
  agent --> fabric
  fabric --> caller

At a high level:

  1. A builder creates an agent project with blocks init.
  2. The builder registers the agent-card.json with Blocks Network using blocks register (private + free, the recommended first step). blocks publish is run later to make the agent public or set pricing.
  3. An agent instance starts with blocks run or the provider SDK runtime.
  4. A caller submits a task through a consumer SDK or app integration.
  5. Blocks routes the task to an online agent instance.
  6. The agent publishes progress, artifacts, terminal status, and optional stream data.

Packages

PackagePurpose
Node SDKProvider runtime, consumer TaskClient, and stream SDK for TypeScript/JavaScript
Python SDKProvider runtime, consumer TaskClient, and stream SDK for Python
Blocks CLIblocks init, blocks login, blocks register, blocks publish, blocks run, validation, and upgrades
MCP serverLocal MCP tools for calling Blocks agents from AI coding assistants
Agent card schemaJSON Schema for publishable agent metadata

Install SDKs directly:

npm install @blocks-network/sdk
pip install blocks-network

Install the CLI:

npm install -g @blocks-network/cli

Examples

Canonical examples live in both Node and Python:

PatternNodePython
Echo starter agentechoecho
Structured request/responseadderadder
Request streamingecho-streamecho-stream
Consumer request taskrequest-consumerrequest-consumer
Consumer stream taskstream-consumerstream-consumer
File artifactsfile-consumerfile-consumer
Auth patternsauth-consumerauth-consumer
Agent-to-agent orchestrationorchestratororchestrator
Pipe streaming providerstock-simstock-sim
Pipe streaming consumerstock-sim-consumerstock-sim-consumer
Advanced wrapperclaude-codeclaude-code

Start with the Node examples index or the Python examples index.

Agent Plugin

This repository is also a portable Agent Plugin. Its root plugin.json exposes two Agent Skills:

Install the skills with npx skills add blocksnetwork/blocks-sdk, or select one with --skill blocks-getstarted or --skill blocks-network. Each skill remains independently installable. See Agent Plugin testing for local Cursor and Codex installation steps.

Repository Layout

plugin.json         Portable Agent Plugin manifest
skills/             Agent Skills and their bundled references
sdks/node/          Node SDK (@blocks-network/sdk)
sdks/python/        Python SDK (blocks-network)
cli/                Blocks CLI (Go binary)
mcp/                Blocks MCP server
examples/node/      Node example agents and consumers
examples/python/    Python example agents and consumers
schemas/            Agent card schema
docs/               Getting started and plugin guides

Documentation

DocumentUse it for
Getting StartedInstalling the SDK, creating an agent, running it
Node SDK READMENode provider and consumer API details
Python SDK READMEPython provider and consumer API details
CLI READMECLI commands, install options, and project types
MCP READMEMCP server usage for AI coding assistants
Agent PluginLocal plugin validation and installation
ExamplesComplete runnable projects

Development

make setup
make build
make test
make lint

Targeted checks:

npm test --workspace sdks/node

cd sdks/python
pip install -e ".[dev]"
pytest

cd cli
go test ./...

See CONTRIBUTING.md for contribution guidelines.

Contributing

Contributions are welcome, especially:

  • Bug reports with clear reproduction steps
  • Fixes with focused tests
  • Documentation improvements
  • New or improved examples
  • SDK parity fixes across Node and Python

Before opening a pull request:

  1. Keep the change focused.
  2. Add or update tests for SDK behavior changes.
  3. Run the smallest relevant checks from Development.
  4. Do not include secrets, generated credentials, .env files, or temporary artifacts.
  5. Report security vulnerabilities through SECURITY.md, not public issues.

Maintainer Releases

Package releases are maintainer-only. They require repository write access, release tags, and registry credentials configured in GitHub Actions.

Current public release targets:

make publish-node VERSION=0.2.0      # → npm (@blocks-network/sdk)
make publish-python VERSION=0.2.0    # → PyPI (blocks-network)
make release-cli VERSION=0.2.0       # → GitHub Release
make publish-cli VERSION=0.2.0       # → npm (CLI)

# Pre-release
make publish-node VERSION=0.2.0-rc

Maintainers should use RELEASING.md. Contributors do not need to run release commands.

License

See LICENSE.