OpenFlare Logo OpenFlare Docs
Back to Studio

OpenFlare Agents Quick Start

Build and deploy stateful, Web3-connected autonomous AI agents on Cloudflare Workers edge infrastructure in under 5 minutes.

🚀 What you will build: You will deploy a stateful AI agent that connects to Cloudflare One MCP Server Portals, audits Robinhood EVM Chain smart contracts, and fixes Solana Rust programs on edge nodes with 0ms cold starts.

1. Install OpenFlare CLI

Run the official initialization command to scaffold a new agent project:

>_ Terminal
npm create openflare-agent@latest my-web3-agent
cd my-web3-agent
npm install

2. Configure Environment & Cloudflare Bindings

Open wrangler.toml and configure your Cloudflare Workers AI and D1 Database bindings:

📄 wrangler.toml
name = "my-web3-agent"
main = "src/index.ts"
compatibility_date = "2026-07-31"

[ai]
binding = "AI"

[[d1_databases]]
binding = "DB"
database_name = "my-d1-db"
database_id = "YOUR_D1_DATABASE_ID"

3. Create Your First Agent Class

Create src/agent.ts extending the core Agent class:

⚡ src/agent.ts
import { Agent, type Connection, type WSMessage } from "@openflare/agents";

export class Web3Agent extends Agent {
  async onConnect(connection: Connection) {
    connection.send(JSON.stringify({
      type: "ready",
      status: "Connected to OpenFlare Studio Edge"
    }));
  }

  async onMessage(connection: Connection, message: WSMessage) {
    const data = JSON.parse(message as string);
    
    // Execute Robinhood EVM Chain Audit
    if (data.action === "audit_evm") {
      const result = await this.env.AI.run("@cf/meta/llama-3.2-3b-instruct", {
        prompt: `Audit Robinhood EVM contract: ${data.contract}`
      });
      connection.send(JSON.stringify({ result }));
    }
  }
}

Overview & Architecture

OpenFlare Studio is built on Cloudflare Workers AI edge runtime, providing a unified developer environment for Web3 and Model Context Protocol (MCP) agents.

CHAIN ID 4663

Robinhood EVM Chain

Native EVM smart contract compilation, static security auditing via Blockscout API, and Web3 RPC execution.

SOLANA RUST

Solana Anchor & Pinocchio

Live Anchor & Pinocchio Rust smart contract autofixer complying strictly with solana.com/docs standards.

EDGE PORTAL

Cloudflare One MCP

Centralized Model Context Protocol server portal with 5x token savings (minimize_tools) and Workers codemode.

Autonomous Agent Runtime

The high-tech 3-column architecture flow mapping incoming channels, agent harness, SDK runtime, tools, and observability logging.

CHANNELS5
Chat Workspace
EVM Wallet (Chain 4663)
Solana Phantom Wallet
Email Session
HTTP Webhook API
A

Agent

Project Think & Reasoning Engine
Build-your-own Autonomous Agent
Agent Class
State
Sessions
Routing
WebSockets
TOOLS5
Sandbox Code Engine
Cloudflare One MCP
Browser Agent
Web & Vector Search
Robinhood & SOL Payments
OBSERVABILITY Logs · metrics · traces

OpenFlare Ecosystem Mind Map

Interactive tree branch mind map visualising connections between OpenFlare AI Studio, Web3 RPCs, MCP Portals, and Frontier AI Models.

OpenFlare AI Studio Web3 Tools Robinhood EVM Solana MCP Cloudflare D1 Agentic SDK Agent Class Durable State WebSockets MCP Portals Cloudflare One minimize_tools Workers Codemode AI Models Claude 3.5 Sonnet DeepSeek R1 32B Llama 3.3 70B

Prerequisites

  • Node.js: v18.0.0 or higher.
  • Wrangler CLI: Installed globally or via local project dependency.
  • Web3 Wallet: MetaMask / Robinhood Wallet for EVM, Phantom / Solflare for Solana.
  • Cloudflare Account: For Workers AI, D1 Database, and Pages deployment.

Agent Class Lifecycle

The Agent class is the foundational building block of OpenFlare Studio. It manages connection events, WebSocket state, and tool orchestration.

⚡ src/agentLifecycle.ts
import { Agent } from "@openflare/agents";

export class CustomAgent extends Agent {
  // 1. Triggered when client establishes WebSocket / Session connection
  async onConnect(connection: Connection) {
    console.log("Client connected:", connection.id);
  }

  // 2. Triggered when user or subagent sends a message/tool command
  async onMessage(connection: Connection, message: WSMessage) {
    console.log("Received payload:", message);
  }

  // 3. Triggered when client disconnects
  async onClose(connection: Connection) {
    console.log("Client closed connection:", connection.id);
  }
}

State & Durable Storage

Agents maintain durable identity and session state backed by Cloudflare D1 Database and KV storage.

WebSockets & Live Fibers

Agents communicate in real-time using duplex WebSockets and background execution fibers.

Cloudflare One MCP Server Portals

OpenFlare Studio complies strictly with the official Cloudflare One Access Controls MCP Specification.

Context Optimization Modes

🌐 MCP Endpoints
Primary MCP Portal:   https://app.openflare.fun/api/mcp
Minimize Tools Mode:  https://app.openflare.fun/api/mcp?optimize_context=minimize_tools
Search & Execute:    https://app.openflare.fun/api/mcp?optimize_context=search_and_execute
Workers Code Mode:   https://app.openflare.fun/api/mcp?codemode=search_and_execute

Connected Upstream Tools

  • Robinhood EVM RPC: https://rpc.mainnet.chain.robinhood.com
  • Robinhood Blockscout Explorer: https://robinhoodchain.blockscout.com
  • Solana Official MCP Server: https://mcp.solana.com/mcp
  • Cloudflare D1 Database: https://app.openflare.fun/api/mcp/d1

Robinhood EVM Chain (Chain ID 4663)

Native EVM smart contract compilation, static security auditing via Blockscout API, and automated Web3 RPC executions on Chain ID 4663.

Solana Anchor & Pinocchio Program Autofixer

The built-in Solana MCP tool automatically scans Rust source code for Anchor and Pinocchio smart contracts, fixing zero-copy account layouts and lifetime bounds.

Strict User Account Storage Isolation

All user data, chat sessions, API vault keys, custom skills, and MCP portals are strictly isolated per user account ID:

🗄️ Storage Schema
cyberterm_history_<userId>
cyberterm_saved_sessions_<userId>
cyberterm_user_settings_<userId>
cyberterm_custom_skills_<userId>
cyberterm_custom_mcp_portals_<userId>

API Keys & Vault Security

Store custom Gemini, OpenAI, Groq, and Anthropic Claude API keys securely inside your account's isolated API Vault.

HTTP REST API Reference

Invoke OpenFlare Studio AI programmatically using HTTP POST requests:

>_ cURL Request
curl -X POST "https://app.openflare.fun/api/chat" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet",
    "messages": [
      { "role": "user", "content": "Compile liquidity contract on Robinhood EVM Chain 4663" }
    ]
  }'