CSPR Sentinel

CSPR Sentinel

An MCP server for autonomous AI agents to discover, pay for, and rate paid APIs on Casper with policy-controlled approvals and on-chain reputation.

Category
访问服务器

README

CSPR Sentinel

CSPR Sentinel is a policy-controlled payment and reputation layer for autonomous AI agents on Casper. It exposes an MCP server that lets agents discover paid services, request x402 purchases, wait for human approval when required, and build bilateral reputation from verifiable outcomes.

The included RWA diligence agent demonstrates the full flow with synthetic commercial paper data:

  1. It buys a low-cost asset verification service automatically.
  2. It sends a higher-cost risk intelligence request to the owner approval queue.
  3. After approval, the request is paid and delivered.
  4. The application stores the Casper transaction hash and anchors reputation aggregates on-chain.

The provider datasets are synthetic and are not investment, legal, or compliance advice.

Why it exists

Agents need the ability to pay for one API call at a time, but unrestricted signing keys are unsafe. CSPR Sentinel separates planning from authority. The model can request a purchase; deterministic policy code decides whether it is denied, executed, or held for owner approval.

Architecture

flowchart LR
    A[RWA Agent] -->|MCP tool call| M[CSPR Sentinel MCP]
    M --> P[Policy engine]
    P -->|small request| X[x402 client]
    P -->|large request| H[Owner approval]
    H --> X
    X --> S[Paid API]
    S --> F[Casper facilitator]
    F --> C[Casper Testnet]
    C --> L[Payment evidence]
    L --> R[Reputation registry]
    P --> N[(Neon)]
    R --> N

Monorepo

  • apps/web: Next.js dashboard, API routes, paid provider endpoints, x402 and contract adapters.
  • packages/core: policy engine, purchase state machine, reputation formulas, Neon repository.
  • packages/mcp: five MCP tools over Streamable HTTP.
  • packages/agent: Anthropic RWA planner and deterministic fallback.
  • contracts/reputation: Odra contract for counters, payment receipts, and rating uniqueness.

MCP tools

Tool Purpose
list_services Filter paid APIs by category, price, and provider reputation.
request_purchase Run policy checks and auto-pay or create an approval.
get_purchase_status Read policy, approval, payment, delivery, and evidence state.
submit_provider_rating Submit one verified-buyer rating per delivered purchase.
get_reputation Read agent or provider score, counters, label, and chain anchor.

Purchase states are requested, policy_denied, pending_approval, approved, paying, settled, delivered, and failed.

Local development

Requirements: Node.js 20 or newer and pnpm 10.

cp .env.example apps/web/.env.local
pnpm install
pnpm dev

Open http://localhost:3000. The default DEMO_MODE=true uses simulated deploy hashes and clearly labels the interface as Simulation mode. Anthropic is optional in this mode; without a key, a deterministic planner creates the same two-service diligence plan.

Run verification:

pnpm typecheck
pnpm test
pnpm security:scan
pnpm build

Neon persistence

Set DATABASE_URL, apply the included Drizzle migration, then start the app:

pnpm db:migrate
pnpm dev

Without DATABASE_URL, the app uses a process-local memory repository suitable for the interactive demo and tests.

GitHub owner access

Set GITHUB_ID, GITHUB_SECRET, NEXTAUTH_SECRET, and OWNER_GITHUB_LOGIN. Only the allow-listed GitHub login can create approval decisions in production. A matching x-demo-admin-key header is also accepted for controlled API automation. MCP, direct purchase, and rating requests use the separate x-agent-api-key header.

Casper Testnet mode

Follow docs/TESTNET.md. Real mode requires a funded agent wallet, WCSPR, the official Casper x402 facilitator, two provider payees, and the deployed reputation contract.

When all variables are set, change DEMO_MODE=false. The runtime then:

  • creates EIP-712 payment authorizations with @make-software/casper-x402;
  • settles through the configured facilitator;
  • stores the returned Casper transaction hash;
  • calls record_purchase and record_provider_rating on the reputation contract.

Private keys are read only from server environment variables. They are never returned by an API, stored in Neon, or shipped to the browser.

Before starting real mode, validate every required setting and probe the Casper RPC and facilitator:

pnpm testnet:preflight

Real mode fails closed: an incomplete x402 or reputation configuration will stop the request instead of silently producing simulated transaction hashes.

Deployment

The public deployment runs on Vercel with Neon PostgreSQL persistence. It intentionally remains in clearly labelled simulation mode until the generated testnet wallets receive CSPR/WCSPR and the reputation contract is deployed; DEMO_MODE=false is the explicit cutover switch.

  1. Create a Neon database and apply the migration.
  2. Import this repository into Vercel with root directory apps/web.
  3. Add the environment variables from .env.example.
  4. Set NEXT_PUBLIC_APP_URL to the deployed origin.
  5. Add the production OAuth callback URL to the GitHub OAuth app.
  6. Verify /api/state, /api/mcp, one auto-payment, and one approval payment.

Vercel and external monitors can use /api/health. It returns HTTP 503 when real mode is incomplete, without exposing secret values. GitHub Actions verifies the TypeScript application, security scan, Odra tests, and a reproducible optimized contract WASM build.

Reputation model

  • Provider: 60% verified buyer rating and 40% delivery success.
  • Agent: 50% payment success, 30% policy compliance, and 20% approval acceptance.
  • New subjects start at 50 / Unproven.
  • Crossing an automatic threshold is compliant; exceeding a hard allow-list, quote, reputation, or daily-budget rule is not.
  • Score weights live in the application. Raw aggregates and payment evidence live in the contract so weights can evolve without migrating history.

References

Licensed under Apache-2.0.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选