Nexflow Smf

io.github.moejeaux由 GitHub 账号 moejeaux 发布v1.0.0更新于 Oct 24, 2026

Smart Meta-Facilitator for x402 payments on Base: route, verify, and settle payments.

概览

AI 生成的概览

NexFlow SMF 是一个本地 MCP 服务器,让助手在 Base 上路由、报价、验证并结算 x402 USDC 小额支付。

可以做什么
发现 x402 服务商并比较 Base 上 USDC 的各条定价路由,在确定路由前获取单一报价。检查服务状态与延迟,并在不实际付款的情况下模拟 x402 定价响应头。验证支付意图,并为已完成的 x402 支付获取结算回执,用于日志或审计。把 USDC 预算换算成大致的 API 调用次数,并通过托管工作流处理计量会话、预算检查、批量结算和收入分成记账。
适用场景
当助手或智能体需要为 Base 上受 x402 保护的 API 调用付费、计量或审计时,或在投入 USDC 前想比较服务商路由与价格时使用。也适合在执行付费操作前根据预算估算花费。
运行要求
以本地 npm 包通过 stdio 运行,需要 Node.js。需要在 NEXFLOW_API_KEY 环境变量中提供 NexFlow API 密钥,可从 NexFlow 开发者控制台获取。需要访问 NexFlow API 的网络连接;NEXFLOW_BASE_URL 可覆盖默认地址。仅支持桌面端。
安装前请注意
该服务器处理 Base 主网上的真实 USDC 支付,工作流调用、扣费和批量结算都是会花费资金的计费事件。必须提供 NEXFLOW_API_KEY 密钥,应保存在环境变量或密钥管理器中,切勿提交到代码库。结算与收入分成操作会写入链上状态,支付凭证和调用方标识会发送到 NexFlow API。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Nexflow Smf,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

NexFlow Smart Meta-Facilitator (SMF)

The x402-native metered billing and routing brain for AI agents and SaaS APIs on Base.

NexFlow SMF routes, verifies, and settles x402 micropayments on Base. It acts as an intelligent intermediary between payers and facilitators, selecting the optimal route based on cost, latency, and reliability. This repository contains the on-chain settlement contracts, TypeScript SDK, agent manifest specification, and integration examples.

🎴 Browse AgentCard Catalog →

Discover AI agent services with x402 payment routing through NexFlow SMF. Submit your service to the catalog.

📦 What's Included

ComponentDescription
contracts/Solidity contracts for atomic batch settlement with Merkle proof verification
sdk/Zero-dependency TypeScript SDK (@nexflow-smf/smf) for routing, verification, and settlement
examples/Ready-to-run examples demonstrating common integration patterns
examples/workflows/JSON workflow definitions for the NexFlow SMF workflow host
examples/client/Minimal TypeScript clients showing the 402 → pay → retry pattern

🧩 Skills (Cursor & AI agents)

Canonical list of NexFlow SMF skills. Each skill has a SKILL.md (for Cursor/agents) and lives in nexflow-smf-skills/. Machine-readable manifest: skills-manifest.json · API: GET https://api.nexflowapp.app/.well-known/skills (redirects to manifest).

SkillDescription
List FacilitatorsDiscover active x402 facilitators by network/asset before quoting or paying.
Route MatrixCompare priced routes (fees, latency) across facilitators for USDC on Base.
Route QuoteGet a single priced quote for a chosen facilitator before committing.
Settlement ReceiptFetch a settlement receipt for a completed x402 payment for logs or audits.
HealthcheckPing NexFlow SMF for status and latency before routing payments.
Simulate ChargeSee x402 pricing headers without performing a real payment.
Budget PlanTurn a USDC budget into an approximate number of SMF API calls.

🎴 Browse AgentCard Catalog

Discover NexFlow services as AgentCards, ready for AI agents and x402-aware clients:

https://nexflow-agentcards.pages.dev/


Choose Your Path

Monetize an existing API at the edge (recommended)

Drop a Lambda@Edge function in front of CloudFront. Every request to a protected path must include a valid x402-payment header — otherwise the client gets a 402 Payment Required with payment instructions. No backend changes needed.

How it works:

  1. viewer-request — Lambda calls /x402/verify with the payment proof (not billed). If valid, attaches a settlementIntentId and forwards to origin. If invalid, returns 402.
  2. origin-response — Lambda reads the settlementIntentId. If origin status < 400, calls /x402/settle to confirm delivery (this is the billable event). Returns the response unchanged.

Get started in 15 minutes:

AWS CloudFront + Lambda@Edge Quickstart →

Use the NexFlow SMF SDK directly

For server-side integrations where you control the request lifecycle — route payments, verify intents, and trigger batch settlement from your own code.

bash
npm install @nexflow-smf/smf
typescript
import { NexFlowSMFClient } from '@nexflow-smf/smf';
const smf = new NexFlowSMFClient({  baseUrl: 'https://api.nexflowapp.app',  apiKey: process.env.NEXFLOW_API_KEY!,});
// Route a paymentconst route = await smf.route({  amount_wei: '1000000',  token_address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',  chain_id: 'eip155:8453',  payment_id: 'order-123',});
// Verify a payment intentconst result = await smf.verify({  payment_intent: 'x402:1:base:0xabc...',  recipient_address: '0xYourAddress...',});

Full SDK documentation →


What's in This Repo

PathDescription
examples/aws-cloudfront-lambdaedge/15-minute AWS quickstart — Lambda@Edge x402 pay-per-request gating
examples/basic-settlement.tsEnd-to-end SDK example: route, verify, settle
sdk/Zero-dependency TypeScript SDK (@nexflow-smf/smf)
contracts/Solidity contracts for atomic batch settlement with Merkle proofs
docs/API reference, facilitator contract, production checklist
AGENT_MANIFEST_V1.mdAgent Manifest spec for machine-to-machine discovery
nexflow-smf-skills/Cursor-style agent skills (route-matrix, quote, receipt, facilitators, health, simulate, budget)
PRICING.mdPricing model with example scenarios

Services Overview

ServiceDescriptionStatus
Smart Meta-FacilitatorIntelligent payment routing, verification, and batch settlementLive
CloudFront Edge GatingLambda@Edge adapter for pay-per-request access via CloudFrontLive
Agent Manifest & DiscoveryMachine-readable capability manifest for AI agent integrationLive
Pulse SchedulerMetered job scheduling with x402 billing (cron, webhooks, tasks)Live
Action CatalogPre-built metered actions (Shopify, Salesforce, data enrichment)Live

Base Mainnet Contracts

ContractAddressExplorer
AtomicBatchSettlement0x43A04228152115fDd5663B2Aa559Ebd84D17A49DBaseScan
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913BaseScan

🔄 Agent Workflows

NexFlow SMF allows agents to define, publish, and monetize hosted workflows — multi-step compositions of core SMF operations that other agents can invoke via the 402/MPP payment gateway.

  • Workflow creation and inspection are free.
  • Workflow invocation is paid — the price is computed from the sum of step costs plus a creator-defined markup.
  • Workflow creators earn rev-share on every invocation.

Available Core Operations

Workflows can compose any of these paid SMF operations:

OperationDescription
create_sessionCreate a metered session with a budget
budget_checkCheck planned charges against budgets
budget_diagnosticsAnalyze sessions for overrun risk
process_chargesDeduct charges from a session or caller
verify_paymentValidate a payment descriptor
settle_batchSettle a batch of transactions
revenue_shareRecord revenue-share accounting for a period
route_quoteGet a payment routing quote
usage_timeseriesTime-series spend data for a caller/session
configure_alertsSet budget/usage alert thresholds
monitor_sessionsList sessions with budget & spend status
monitor_alertsReturn triggered budget/usage alerts
pricing_estimateEstimate cost of a set of operations

Example Workflows

Safety-Capped Session Runner

examples/workflows/safety_capped_session_runner.json

A 5-step workflow that:

  1. Creates a session with a requested budget
  2. Checks a planned charge against that budget
  3. Processes the charge
  4. Configures a 90% budget alert
  5. Returns current session status
Usage Health Check

examples/workflows/usage_health_check.json

A 3-step diagnostic workflow that:

  1. Pulls recent spend timeseries (hourly, configurable window)
  2. Checks budget status (zero-cost probe)
  3. Returns active alerts
Batch Settlement Runner

examples/workflows/revenue_share_settlement.json

A 5-step workflow demonstrating the full payment lifecycle:

  1. Creates a settlement session with a budget
  2. Checks that planned charges fit within the budget
  3. Processes a batch of charges
  4. Settles the batch
  5. Returns final session status

The workflow creator earns their standard rev-share (set via creatorShareBps) on every invocation. Rev-share credits accumulate per wallet and are batched for payout when they reach $5+.

Input example:

json
{  "sessionBudget": { "amount": 2000000, "currency": "USDC" },  "charges": [    { "callerId": "agent_a", "amount": 500000, "description": "API usage week 12" },    { "callerId": "agent_b", "amount": 300000, "description": "Compute usage week 12" }  ],  "settlementPeriod": "2026-03-01/2026-03-31"}

How to Register a Workflow

bash
# Register the Safety-Capped Session Runnercurl -X POST "$NEXFLOW_SMF_BASE_URL/nexflow/workflows" \  -H "Content-Type: application/json" \  -H "X-Caller-Id: demo_caller" \  --data-binary "@examples/workflows/safety_capped_session_runner.json"

Response:

json
{  "workflowId": "wf_abc123_1",  "name": "Safety-Capped Session Runner",  "invokeUrl": "/nexflow/workflows/wf_abc123_1/invoke",  "status": "active",  "steps": 5,  "pricing": { "billingMode": "per_call", "markupBps": 300 }}

How to Invoke a Workflow

bash
# First call — no payment proof → 402 Payment Requiredcurl -X POST "$NEXFLOW_SMF_BASE_URL/nexflow/workflows/wf_abc123_1/invoke" \  -H "Content-Type: application/json" \  -H "X-Caller-Id: demo_caller" \  --data '{    "requestedBudget": { "amount": 500000, "currency": "USDC" },    "plannedCost": { "amount": 50000, "currency": "USDC" }  }'

The first call returns HTTP 402 with a payment challenge:

json
{  "object": "payment_challenge",  "operation": "workflow_invoke",  "workflow_id": "wf_abc123_1",  "required_amount": 17350,  "currency": "usdc",  "price_breakdown": {    "totalPrice": 17350,    "baseCost": 7000,    "markup": 210,    "platformFee": 149  },  "instructions": "Pay via MPP using the challenge above, then retry with X-PAYMENT-PROOF header."}

After the agent pays (via Tempo MPP or x402), it retries with the proof:

bash
# Second call — with valid proof → 200 OKcurl -X POST "$NEXFLOW_SMF_BASE_URL/nexflow/workflows/wf_abc123_1/invoke" \  -H "Content-Type: application/json" \  -H "X-Caller-Id: demo_caller" \  -H "X-PAYMENT-PROOF: <base64-encoded-proof-json>" \  --data '{    "requestedBudget": { "amount": 500000, "currency": "USDC" },    "plannedCost": { "amount": 50000, "currency": "USDC" }  }'

TypeScript Client Example

See examples/client/invokeUsageHealthCheck.ts for a runnable demo of the full 402 → proof → retry flow.

bash
export NEXFLOW_SMF_BASE_URL=http://localhost:3001export WORKFLOW_ID=wf_abc123_1npx tsx examples/client/invokeUsageHealthCheck.ts

Environment Variables

VariableRequiredDescription
NEXFLOW_API_KEYYesYour NexFlow API key (nf_live_xxx or nf_test_xxx)
NEXFLOW_BASE_URLNoOverride API URL (default: https://api.nexflowapp.app)
NEXFLOW_SMF_BASE_URLNoNexFlow SMF bridge URL for workflow invocations (default: http://localhost:3001)
WORKFLOW_IDNoWorkflow ID for the client example scripts

Sign up or log in at nexflowapp.app, go to Developers → API Keys, and click Create API key. Use that key with the examples in this repo.

Never commit API keys or secrets. Use environment variables or a secrets manager.


Supported Networks & Tokens

NetworkChain IDStatus
Base mainneteip155:8453Primary
TokenAddressDecimals
USDC0x833589fCD6eDb6E08f4c7C32D4f71b54bdA029136

Documentation

DocWhat's inside
Facilitator API/verify and /settle contracts, settlementIntentId lifecycle, error handling, retry guidance
API ReferenceAll endpoints (SMF core, x402 routing, agent discovery), SDK reference, contract ABI
Production ChecklistIdempotency, latency, CloudWatch logging, failure modes, key rotation
PricingPulse metering, facilitator settle-only pricing, example scenarios
Agent ManifestMachine-to-machine capability discovery spec
SDK READMEFull SDK docs: installation, methods, error handling, utilities

Development

Building the SDK

bash
cd sdknpm installnpm run build       # Build for production (CJS + ESM + types)npm run dev         # Watch modenpm run typecheck   # Type checking

Running Examples

bash
# SDK examplecd sdk && npm installnpx tsx ../examples/basic-settlement.ts
# Lambda@Edge examplecd examples/aws-cloudfront-lambdaedgenpm installnpm run build   # requires NEXFLOW_FACILITATOR_URL and NEXFLOW_API_KEY

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Security

For security concerns, see SECURITY.md.

License

MIT License — see LICENSE for details.


Links


Built for the x402 ecosystem on Base

来源:README.md,提交 43c75db

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分