Shark MCP - AI Agent Microloan Server

Shark MCP - AI Agent Microloan Server

Enables AI agents to request and manage microloans for HTTP 402 Payment Required transactions. Provides automated underwriting, credit management, and USDC disbursement with progressive credit limits based on repayment history.

Category
访问服务器

README

Shark MCP - AI Agent Microloan Server

An MCP (Model Context Protocol) server for providing microloans to AI agents for x402 transactions. Built with FastAPI and FastMCP, this server enables AI agents to request small loans to pay for HTTP 402 Payment Required transactions.

Features

  • Agent Registration: Whitelist-based registration with wallet address verification
  • Microloan Processing: Automated underwriting and disbursement for small loans (<$1 initially)
  • x402 Integration: Automatic payment of x402 transactions on behalf of agents
  • Credit Management: Progressive credit limits based on repayment history
  • Risk Assessment: Comprehensive credit scoring and risk evaluation
  • Automated Collections: Overdue loan detection and collection processes
  • MCP Tools: Rich set of tools for AI agents to interact with the loan system

MCP Tools Available

  • request_loan(wallet_address, amount, purpose?, x402_url?) - Request a microloan
  • check_credit_limit(wallet_address) - Check available credit and limits
  • repay_loan(loan_id, amount, payment_hash?) - Repay a loan
  • get_loan_status(loan_id) - Get detailed loan information
  • list_agent_loans(wallet_address) - List all loans for an agent
  • register_agent(wallet_address, signature, message?) - Register as a new agent

Quick Start

1. Setup Database

# Create PostgreSQL database
createdb shark_mcp

# Copy environment file
cp .env.example .env
# Edit .env with your database credentials

2. Configure Alchemy for USDC Transfers

To enable real USDC transfers (instead of mock transactions), you need to configure Alchemy:

  1. Get an Alchemy API Key:

    • Sign up at Alchemy
    • Create a new app for Ethereum mainnet
    • Copy your API key
  2. Set up a Vault Wallet:

    • Create a new Ethereum wallet to hold USDC for disbursements
    • Fund it with USDC and some ETH for gas fees
    • Export the private key
  3. Configure Environment Variables:

    # Add to your .env file
    ALCHEMY_API_KEY=your_alchemy_api_key_here
    VAULT_PRIVATE_KEY=your_vault_private_key_here
    
  4. Update USDC Contract Address:

    • In src/shark_mcp/mcp_server.py, replace the placeholder USDC contract address with the real one:
    # Real USDC address on Ethereum mainnet
    usdc_contract_address = "0xA0b86a33E6441b8C4C8C8C8C8C8C8C8C8C8C8C8C"
    

Note: The system uses web3.py with Alchemy's HTTP provider for blockchain interactions. Without these configurations, the system will use mock transactions for demonstration purposes.

3. Install Dependencies

pip install -e .

4. Run Database Migrations

alembic upgrade head

5. Start the Server

# Development
python -m shark_mcp.main

# Production
uvicorn shark_mcp.main:app --host 0.0.0.0 --port 8000

6. Access MCP Server

The MCP server is available at: http://localhost:8000/mcp

API documentation: http://localhost:8000/docs

Architecture

Core Components

  • Agent Management: Registration, whitelisting, and wallet verification
  • Loan Processing: Underwriting, disbursement, and repayment tracking
  • Credit Assessment: Risk scoring and credit limit progression
  • Collection System: Automated overdue detection and collection
  • x402 Integration: Automatic payment of HTTP 402 transactions

Database Models

  • Agent: Stores agent information and credit profiles
  • Loan: Individual loan records with status tracking
  • Transaction: Payment and repayment transaction history
  • AuditLog: Comprehensive audit trail for all actions

Credit Tiers

Tier Min Successful Loans Max Credit Limit
Starter 0 $1.00
Bronze 3 $2.50
Silver 10 $5.00
Gold 25 $10.00
Platinum 50 $25.00
Diamond 100 $50.00

Usage Example

For AI Agents

# Register as an agent
result = await mcp.call_tool("register_agent", {
    "wallet_address": "0x1234...",
    "signature": "0xabcd...",
    "message": "Register for Shark MCP microloans"
})

# Check credit limit
credit_info = await mcp.call_tool("check_credit_limit", {
    "wallet_address": "0x1234..."
})

# Request a loan for x402 transaction
loan = await mcp.call_tool("request_loan", {
    "wallet_address": "0x1234...",
    "amount": 0.50,
    "purpose": "Payment for API access",
    "x402_url": "https://api.example.com/data"
})

# Repay the loan
repayment = await mcp.call_tool("repay_loan", {
    "loan_id": loan["loan_id"],
    "amount": 0.50,
    "payment_hash": "0x5678..."
})

For Administrators

# Whitelist an agent
curl -X POST "http://localhost:8000/api/v1/agents/whitelist" \
  -H "Content-Type: application/json" \
  -d '{"wallet_address": "0x1234...", "admin_id": "admin123"}'

# Get collection report
curl "http://localhost:8000/api/v1/admin/collection-report"

Development

Running Tests

pytest

Code Formatting

black src/
ruff check src/

Type Checking

mypy src/

Security

  • All agents must provide cryptographic signatures proving wallet ownership
  • Whitelist-based access control for loan eligibility
  • Comprehensive audit logging for all operations
  • Automated risk assessment and credit scoring
  • Progressive credit limits based on payment history

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选