ResilientDB MCP Server

ResilientDB MCP Server

Enables interaction with ResilientDB blockchain through smart contract operations, GraphQL queries, and key-value storage operations.

Category
访问服务器

README

ResilientDB MCP Server

A Model Context Protocol (MCP) server for interacting with ResilientDB, a high-performance blockchain platform. This server allows Large Language Models (LLMs) like Claude to interact with ResilientDB through smart contract operations and GraphQL queries.

Overview

This MCP server bridges the gap between AI agents (like Claude Desktop) and ResilientDB by providing a standardized interface for:

  • Smart Contract Operations: Compile, deploy, and execute smart contracts using ResContract CLI
  • GraphQL Operations: Create accounts, manage transactions, and query data
  • Key-Value Operations: Store and retrieve data using ResilientDB's key-value store

Features

Smart Contract Operations

  • compileContract: Compile smart contracts using ResContract CLI
  • deployContract: Deploy compiled contracts to the ResilientDB blockchain
  • executeContract: Execute contract methods (read/write operations)
  • getContractState: Retrieve the current state of a deployed contract

GraphQL Operations

  • createAccount: Create new accounts in ResilientDB
  • getTransaction: Retrieve transaction details by ID
  • postTransaction: Post new transactions to the blockchain
  • updateTransaction: Update existing transactions

Key-Value Operations

  • get: Retrieve values by key
  • set: Store key-value pairs

Installation

Prerequisites

  • Python 3.11 or higher
  • ResilientDB instance running (see ResilientDB Installation)
  • ResContract CLI installed (for smart contract operations)
  • Access to ResilientDB GraphQL endpoint

Local Installation

  1. Clone the repository:
git clone https://github.com/rahulkanagaraj786/ResilientDB-MCP.git
cd ResilientDB-MCP
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables:
cp .env.example .env
# Edit .env with your ResilientDB configuration
  1. Update .env file with your settings:
RESILIENTDB_GRAPHQL_URL=http://localhost:9000/graphql
RESCONTRACT_CLI_PATH=rescontract

Docker Installation

  1. Build the Docker image:
docker build -t mcp/resilientdb -f Dockerfile .
  1. Run the container:
docker run -i --rm mcp/resilientdb

Configuration

Environment Variables

Variable Description Default
RESILIENTDB_GRAPHQL_URL GraphQL endpoint URL http://localhost:9000/graphql
RESCONTRACT_CLI_PATH Path to ResContract CLI executable rescontract
RESILIENTDB_API_KEY Optional API key for authentication None
RESILIENTDB_AUTH_TOKEN Optional auth token None
REQUEST_TIMEOUT Request timeout in seconds 30
TRANSACTION_POLL_INTERVAL Polling interval for transactions 1.0
MAX_POLL_ATTEMPTS Maximum polling attempts 30

Usage with Claude Desktop

Add the MCP server to your Claude Desktop configuration:

  1. Open Claude Desktop settings
  2. Edit the MCP servers configuration file (usually claude_desktop.json)
  3. Add the following configuration:

For Local Installation:

{
  "mcpServers": {
    "resilientdb": {
      "command": "python",
      "args": ["/path/to/ResilientDB-MCP/server.py"],
      "env": {
        "RESILIENTDB_GRAPHQL_URL": "http://localhost:9000/graphql",
        "RESCONTRACT_CLI_PATH": "rescontract"
      }
    }
  }
}

For Docker Installation:

{
  "mcpServers": {
    "resilientdb": {
      "command": "docker",
      "args": ["run", "-i", "--rm", "mcp/resilientdb"]
    }
  }
}
  1. Restart Claude Desktop

Available Tools

createAccount

Create a new account in ResilientDB.

Parameters:

  • accountId (optional): Account ID. If not provided, server will generate one.

Example:

{
  "accountId": "my-account-123"
}

compileContract

Compile a smart contract using ResContract CLI.

Parameters:

  • contractPath (required): Path to the contract file
  • outputDir (optional): Output directory for compiled contract

Example:

{
  "contractPath": "/path/to/contract.sol",
  "outputDir": "/path/to/output"
}

deployContract

Deploy a compiled smart contract to ResilientDB.

Parameters:

  • contractPath (required): Path to the compiled contract
  • accountId (optional): Account ID for deployment
  • constructorArgs (optional): Constructor arguments

Example:

{
  "contractPath": "/path/to/compiled_contract.json",
  "accountId": "my-account-123",
  "constructorArgs": ["arg1", "arg2"]
}

executeContract

Execute a method on a deployed smart contract.

Parameters:

  • contractAddress (required): Address of the deployed contract
  • methodName (required): Name of the method to execute
  • methodArgs (optional): Method arguments
  • accountId (optional): Account ID for execution
  • transactionType (optional): "call" for read operations, "send" for write operations (default: "call")

Example:

{
  "contractAddress": "0x123...",
  "methodName": "getValue",
  "transactionType": "call"
}

getTransaction

Get transaction details by transaction ID.

Parameters:

  • transactionId (required): Transaction ID to retrieve

Example:

{
  "transactionId": "tx-123456"
}

postTransaction

Post a new transaction to ResilientDB.

Parameters:

  • data (required): Transaction data as key-value pairs

Example:

{
  "data": {
    "key": "value",
    "amount": 100
  }
}

updateTransaction

Update an existing transaction.

Parameters:

  • transactionId (required): Transaction ID to update
  • data (required): Updated transaction data

Example:

{
  "transactionId": "tx-123456",
  "data": {
    "status": "completed"
  }
}

get

Retrieve a value from ResilientDB by key.

Parameters:

  • key (required): Key to retrieve

Example:

{
  "key": "my-key"
}

set

Store a key-value pair in ResilientDB.

Parameters:

  • key (required): Key to store
  • value (required): Value to store

Example:

{
  "key": "my-key",
  "value": "my-value"
}

getContractState

Get the current state of a deployed smart contract.

Parameters:

  • contractAddress (required): Address of the deployed contract

Example:

{
  "contractAddress": "0x123..."
}

Architecture

The MCP server acts as a mediator between the MCP host (Claude Desktop) and ResilientDB backend services:

┌─────────────┐         ┌──────────────┐         ┌─────────────┐
│ Claude      │────────▶│ MCP Server   │────────▶│ ResilientDB │
│ Desktop     │         │ (Python)     │         │ Backend     │
└─────────────┘         └──────────────┘         └─────────────┘
                              │
                              ├──▶ GraphQL Client
                              │    (Account, Transaction, KV ops)
                              │
                              └──▶ ResContract CLI
                                   (Smart Contract ops)

Routing Logic

The server automatically routes requests to the appropriate service:

  • Smart Contract Operations → ResContract CLI
  • Data Operations → GraphQL API
  • Hybrid Operations → Tries GraphQL first, falls back to ResContract CLI

Development

Project Structure

ResilientDB-MCP/
├── server.py              # Main MCP server implementation
├── graphql_client.py      # GraphQL client for ResilientDB
├── rescontract_client.py  # ResContract CLI client
├── config.py              # Configuration management
├── requirements.txt       # Python dependencies
├── Dockerfile             # Docker configuration
└── README.md              # This file

Running Tests

# Install test dependencies
pip install pytest pytest-asyncio

# Run tests
pytest

Contributing

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

Troubleshooting

ResContract CLI Not Found

If you get an error about ResContract CLI not being found:

  1. Ensure ResContract CLI is installed
  2. Add it to your PATH, or
  3. Set RESCONTRACT_CLI_PATH environment variable to the full path

GraphQL Connection Errors

If you encounter GraphQL connection errors:

  1. Verify ResilientDB is running
  2. Check the RESILIENTDB_GRAPHQL_URL is correct
  3. Ensure network connectivity to the GraphQL endpoint
  4. Check firewall settings

Transaction Timeouts

If transactions timeout:

  1. Increase REQUEST_TIMEOUT in .env
  2. Check ResilientDB blockchain status
  3. Verify network latency

References

License

Apache 2.0 License

Authors

Team 10 - ECS 265 Project

推荐服务器

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

官方
精选