Substrate MCP Server

by ThomasMarches

13 340 downloads Not rated yet MIT

About

A Model Context Protocol (MCP) server for Substrate blockchains, written in Rust and interfacing the subxt crate.

Details

License
MIT

Explore

- Query account balances and storage dynamically
- List pallets and their entries
- Fetch and filter events and extrinsics
- Submit and watch dynamic signed transactions
- Access system and block information
- Custom RPC calls to Substrate nodes

Clone the repository and build:

git clone https://github.com/ThomasMarches/substrate-mcp-rs.git
cd substrate-mcp-rs
cargo build --release

Create a .env file in the project root with the following variables:


To start the MCP server:

sh
cargo run --release
```

The server will start and listen for MCP requests via stdio.

query_balance

Fetch the balance of an account

list_pallets

List all pallets in the runtime

list_pallet_entries

List all storage entries for a pallet

dynamic_runtime_call

Execute a runtime API call

send_dynamic_signed_transaction

Construct, sign, and send a transaction

query_storage

Query storage by pallet and entry

get_latest_events

Get all events from the latest block

find_events

Find specific events by pallet and variant

get_latest_block

Get details about the latest block

get_block_by_hash

Get block details by hash

find_extrinsics

Find extrinsics in the latest block

get_system_info

Get system info via RPC

custom_rpc

Make a custom RPC call

The server exposes a set of tools for interacting with a Substrate blockchain, including:

- query_balance: Fetch the balance of an account
- list_pallets: List all pallets in the runtime
- list_pallet_entries: List all storage entries for a pallet
- dynamic_runtime_call: Execute a runtime API call
- send_dynamic_signed_transaction: Construct, sign, and send a transaction
- query_storage: Query storage by pallet and entry
- get_latest_events: Get all events from the latest block
- find_events: Find specific events by pallet and variant
- get_latest_block: Get details about the latest block
- get_block_by_hash: Get block details by hash
- find_extrinsics: Find extrinsics in the latest block
- get_system_info: Get system info via RPC
- custom_rpc: Make a custom RPC call

See src/tooling/substrate.rs for full details and parameters.

MIT License
Rust

Trust Score

A Model Context Protocol (MCP) server for Substrate blockchains, written in Rust. This project exposes dynamic Substrate blockchain operations (querying balances, blocks, pallets, storage, events, and more) via the MCP protocol, and is fully configurable via environment variables.

Designed to interface with the subxt crate.

✨ Features

- Query account balances and storage dynamically
- List pallets and their entries
- Fetch and filter events and extrinsics
- Submit and watch dynamic signed transactions
- Access system and block information
- Custom RPC calls to Substrate nodes

🚀 Potential Use Cases

1. AI-Driven Blockchain Operations

- Integrate with LLMs (like Cursor or Claude) to allow users to ask questions in natural language (e.g., "What was the last transfer from Alice?"), which are translated into MCP tool calls.
- Build a chatbot that can answer questions, fetch balances, or explain on-chain activity using your MCP server as the backend.
- Use the MCP server to provide live updates on-chain activity, such as balance changes or transaction statuses, to development tools like VSCode, Cursor, Claude Code, etc.

2. Custom Dashboards and Monitoring

- Create custom dashboards and monitoring systems for your Substrate blockchain
- Display real-time data and analytics on your blockchain operations
- Set up alerts and notifications for critical events
- Use AI agents to detect suspicious activity by analyzing events and extrinsics in real time.

🛠️ Requirements

- Rust
- Access to a Substrate node endpoint (WebSocket)
- A valid signing keypair (as hex)
- Runtime metadata file for your target chain (see below for naming and placement)

📦 Installation

Clone the repository and build:

git clone https://github.com/ThomasMarches/substrate-mcp-rs.git
cd substrate-mcp-rs
cargo build --release

⚙️ Configuration

Create a .env file in the project root with the following variables:

```env

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.