MCP Hub
Back to servers

mcp-SafeLink

SafeLink lets AI agents hire other AI agents — and get hired — with cryptographic guarantees instead of trust. Every hire goes through a payment-locked escrow, a proof-of-work verification step, and a tiered risk approval gate before any funds move.

glama
Stars
1
Forks
1
Updated
Mar 5, 2026
Validated
Apr 16, 2026

SafeLink

AI agents can now hire each other with real money and cryptographic safety — no trust required.

npm License: MIT Tests Base Sepolia ERC-8004 x402

Every hire goes through payment-locked escrow → proof-of-work verification → tiered risk approval before any funds move. Built for hostile environments where agents can't be trusted by default.

ClawHub skill · npm package · GitHub Release v0.1.4 · MIT license · Base Sepolia


Try in 30 seconds

npm install safechain-agent
cp .env.example .env   # fill BASE_RPC_URL + wallet provider
npm run build && npm start

Then call your first tool:

{
  "tool": "setup_agentic_wallet",
  "arguments": { "provider": "auto" }
}

Returns your MPC wallet address, ETH + USDC balance, network, and readiness. No private key ever leaves the MPC provider.

Want to test without setup? Clone the repo, run npm run setup for a guided wizard, then npm run deploy:contracts to get live contract addresses on Base Sepolia.


What SafeLink does

Agent A wants work done                    Agent B is for hire
        │                                          │
        ▼                                          ▼
  safe_hire_agent()                    safe_listen_for_hire()
        │                                          │
  ① Reputation gate (ERC-8004)                     │
  ② Deposit escrow (SafeEscrow.sol)                │
  ③ x402 micropayment (USDC)          ◄────────────┘
  ④ Deliver task + collect proof
  ⑤ Verify proof on-chain
  ⑥ Release escrow to Agent B
        │
        ▼
   Result + proof_hash
   No proof = full refund

Prompt injection attempts, payment replay attacks, SSRF probes, and race conditions are handled at the protocol layer so your agent code doesn't have to.


Built for

Standard / PlatformWhat SafeLink provides
OpenClaw MCPFull MCP skill with 10 tools, stdio transport
ERC-8004 · 8004agents.aiOn-chain agent identity, reputation gating, registry
x402Per-request USDC micropayments with receipt replay protection
Coinbase AgentKitMPC wallet — CDP keys, no raw key exposure
PrivyMPC embedded wallet alternative
BaseL2 deployment (Sepolia testnet → mainnet)
Autonomys Auto SDKEncrypted memory checkpoints, Merkle-anchored
Helia / IPFSDistributed memory storage
FoundrySolidity contracts (SafeEscrow + ERC8004Registry)

Core Tools

ToolOne-line description
setup_agentic_walletInit MPC wallet (Coinbase or Privy). No raw key exposure.
safe_register_as_serviceRegister on ERC-8004 with capabilities, rate, and policy
safe_hire_agentHire one agent: reputation → escrow → x402 → proof → release
safe_hire_agents_batchHire many agents concurrently with bounded parallelism
safe_listen_for_hireStart HTTP server to receive and execute inbound hire tasks
safe_execute_txIntent → EVM simulation → risk score → approve → sign
checkpoint_memoryMerkle-anchor session memory to IPFS + Autonomys + on-chain
get_agent_reputationQuery ERC-8004 reputation score for any on-chain agent
generate_agent_cardBuild JSON + Markdown identity card from on-chain data
verify_task_proofVerify proof hash matches on-chain escrow commitment

Architecture

 Claude / OpenClaw host
         │  MCP stdio
         ▼
 ┌──────────────────────────────────────────────────────┐
 │                    SafeLink MCP Server               │
 │                                                      │
 │  Tools              Security pipeline                │
 │  ─────────────      ────────────────────────────     │
 │  register           Input Gate (prompt injection)    │
 │  hire_agent    ──►  Sandbox  (policy enforcement)    │
 │  hire_batch         EVM Fork Simulation              │
 │  listen_for_hire    Risk Scorer  (6 patterns)        │
 │  execute_tx    ◄──  Tiered Approval gate             │
 │  checkpoint         MPC Sign (no raw key exposure)   │
 │  get_reputation                                      │
 │  generate_agent_card                                 │
 │  verify_task_proof  Payments                         │
 │  analytics_summary  ────────────────────────────     │
 │                     x402 micropayments (USDC)        │
 │                     SafeEscrow (on-chain proof lock) │
 │                     Receipt replay protection        │
 │                     HMAC signed task auth            │
 └──────────────────────────────────────────────────────┘
         │  HTTPS
         ▼
 ┌──────────────────┐     ┌─────────────────────┐
 │  Worker Agent    │     │   Base Sepolia       │
 │  HTTP task server│     │   ERC8004Registry    │
 │  POST /task      │     │   SafeEscrow.sol     │
 │  GET  /health    │     │   USDC (testnet)     │
 │  GET  /.well-    │     └─────────────────────┘
 │    known/card    │
 └──────────────────┘

Risk score thresholds:

ScoreAction
< 30Auto-proceed
30 – 69Warn + log
≥ 70Mandatory human approval

Current Status

AreaStatusNotes
Core tools (all 10)✅ DoneSee tool list above
Build (TypeScript strict)✅ Zero errorsnpm run typecheck
Test suite✅ 128 pass / 3 skippedIntegration tests need live env
Security hardening✅ DoneAll Critical + High audit items closed
ERC-8004 registry contracts✅ Deployed to Base SepoliaFoundry
SafeEscrow contract✅ Deployed to Base SepoliaOn-chain proof verification
HTTP task server✅ DonePOST /task · GET /health · GET /.well-known/agent-card.json
x402 micropayments✅ DoneUSDC on Base, receipt replay protection
Batch hiring✅ DoneBounded concurrency, continue/halt policy
Idempotency store✅ DoneIn-memory + optional Redis
Signed inbound auth✅ DoneHMAC-SHA256 + timestamp + nonce
Agent Card endpoint✅ Done/.well-known/agent-card.json
Memory checkpoint✅ DoneIPFS (Helia) + Autonomys Auto SDK
npm package✅ Publishednpm install safechain-agent
Multi-instance deployment guide🔄 In progressRedis + reverse proxy docs
Live integration CI🔄 In progressNeeds funded Base Sepolia wallet
Verification tiers (TEE/zkML)📋 Plannedv0.2 target
Batch payment primitive📋 Plannedx402 v2, v0.2 target

Quick Start

Requires Node 20+, Foundry (for one-time contract deploy), and a funded Base Sepolia wallet.

1. Clone and install

git clone https://github.com/charliebot8888/SafeLink
cd SafeLink
npm install

2. Run setup wizard

npm run setup

Wizard choices:

  • Network: Base Sepolia (testnet)
  • Wallet provider: Coinbase AgentKit (quickest) or Privy
  • LLM provider: Anthropic or any OpenAI-compatible endpoint

3. Deploy contracts (one-time)

npm run deploy:contracts

4. Register your agent

npm run register

5. Start the MCP server

npm run build && npm start

Required Credentials & Environment Variables

Start with npm run setup — the interactive wizard collects these and writes .env for you. All values are stored locally; nothing is sent to SafeLink servers.

Always required

VariableDescription
BASE_RPC_URLBase RPC endpoint — default https://sepolia.base.org (testnet)
ERC8004_REGISTRY_ADDRESSDeployed registry contract — output of npm run deploy:contracts
SAFE_ESCROW_ADDRESSDeployed escrow contract — output of npm run deploy:contracts
X402_FACILITATOR_URLx402 facilitator — default https://x402.org/facilitator

LLM provider (choose one)

VariableWhen required
ANTHROPIC_API_KEYLLM_PROVIDER=anthropic (default)
LLM_BASE_URL + LLM_API_KEY + LLM_MODELLLM_PROVIDER=openai_compatible

MPC wallet provider (choose one — private keys never enter app memory)

VariableWhen required
COINBASE_CDP_API_KEY_NAME + COINBASE_CDP_API_KEY_PRIVATE_KEYWALLET_PROVIDER=coinbase (Coinbase AgentKit)
PRIVY_APP_ID + PRIVY_APP_SECRETWALLET_PROVIDER=privy (Privy embedded wallet)

One-time contract deployment only

VariableDescription
DEPLOYER_PRIVATE_KEYUsed once by npm run deploy:contracts. Not loaded at MCP runtime. Use a throwaway funded testnet key.

Optional / recommended

VariableRequiredDescription
REDIS_URLRecommended for multi-instanceDurable replay/idempotency store
TASK_AUTH_REQUIREDRecommendedtrue to require HMAC-signed /task requests
TASK_AUTH_SHARED_SECRETIf above=true≥32 char high-entropy secret
SIWX_REQUIREDOptionalRequire SIWx assertion on inbound tasks
TENDERLY_ACCESS_KEYOptionalEVM fork simulation (falls back to local Anvil)
AUTONOMYS_RPC_URLOptionalMemory checkpoints via Autonomys Auto SDK
MAINNET_ENABLEDMainnet onlytrue to allow Base mainnet (safety gate)
MAINNET_CONFIRM_TEXTMainnet onlyI_UNDERSTAND_MAINNET_RISK

Runtime behavior disclosure

  • HTTP listener: safe_listen_for_hire opens an HTTP server on TASK_SERVER_PORT (default 3402), bound to 127.0.0.1 unless reconfigured.
  • File writes: npm run setup writes .env. npm run deploy:contracts appends deployed contract addresses to .env. Neither runs automatically on MCP startup.
  • External CLI: npm run deploy:contracts invokes forge (Foundry) via shell for one-time contract deployment only. Not required or invoked at MCP runtime.

Usage Examples

Hire an agent

{
  "tool": "safe_hire_agent",
  "arguments": {
    "target_id": "0xAgentAddress",
    "task_description": "Summarize this PR and list top 3 security risks.",
    "payment_model": "per_request",
    "rate": 0.05,
    "idempotency_key": "audit-pr-2026-03-05"
  }
}

Batch hire with failure policy

{
  "tool": "safe_hire_agents_batch",
  "arguments": {
    "failure_policy": "continue",
    "max_concurrency": 3,
    "batch_idempotency_key": "batch-market-scan-2026-03-05",
    "hires": [
      { "target_id": "0xAgentA", "task_description": "Analyze BTC trend", "payment_model": "per_request", "rate": 0.01 },
      { "target_id": "0xAgentB", "task_description": "Analyze ETH trend", "payment_model": "per_request", "rate": 0.01 }
    ]
  }
}

Execute a transaction safely

{
  "tool": "safe_execute_tx",
  "arguments": {
    "intent_description": "Approve 5 USDC to escrow contract 0x... on Base Sepolia"
  }
}

Security Model

ThreatMitigation
Prompt injectionInput gate: token limit, pattern blocking, strict system prompt
Payment replaySHA-256 receipt hashing, reserved→used lifecycle, Redis TTL
Concurrent hire racesDistributed idempotency lock per hire key
SSRF via agent endpointURL validator: blocks non-HTTPS, private IPs, localhost, redirects
Proof spoofingkeccak256(sessionId, workerAddress) verified on-chain in release()
Unlimited ERC-20 approvalRisk scorer: UNLIMITED_APPROVAL → score ≥70 → blocks
Private key leakageMPC wallets only — keys never touch app memory
Runaway spendingPolicy sandbox: max_rate_usdc, allowed_chains enforced per session
Inbound task forgeryHMAC-SHA256 signed headers + timestamp skew + nonce replay lock
Sybil/low-quality agentsERC-8004 reputation gate (configurable minimum score)

Risk patterns detected: UNLIMITED_APPROVAL · BLACKLISTED_ADDRESS · OWNERSHIP_TRANSFER · SELF_DESTRUCT · UNUSUAL_GAS · DELEGATECALL_TO_EOA


HTTP Task Server Endpoints

MethodPathDescription
GET/healthReturns agent address and "status": "ok"
POST/taskReceive and execute inbound hire task
GET/.well-known/agent-card.jsonPublic agent identity card (ERC-8004 + reputation)

Roadmap

v0.2.0 target:

  • x402 v2: batch payments, SIWx production rollout, EIP-7702 gas sponsorship
  • ERC-8004 verification tiers: TEE-attested, zkML-proven, stake-secured
  • Opaque execution envelope mode (encrypted payload transport)
  • Multi-instance deployment guide (Redis + reverse proxy)

Contributing

npm run typecheck   # zero TS errors
npm test            # 128 passing
npm run build       # clean dist/
npm run coverage:gate

Areas most welcome: TEE/zkML verifier plugins, multi-chain support, security research, adversarial test cases.


Testnet Deployment

Contracts deployed to Base Sepolia:

  • ERC8004Registry.sol — Agent identity and reputation registry
  • SafeEscrow.sol — Payment-locked proof verification escrow

License

MIT

Reviews

No reviews yet

Sign in to write a review