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. - Query account balances and storage dynamically - List pallets and their
Add this skill
npx mdskills install ThomasMarches/substrate-mcp-rsWell-documented MCP server providing comprehensive Substrate blockchain tools with clear setup
1# Substrate MCP Server23[](LICENSE)4[](https://www.rust-lang.org/)56[](https://archestra.ai/mcp-catalog/thomasmarches__substrate-mcp-rs)78A Model Context Protocol [(MCP)](https://modelcontextprotocol.io/introduction) 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.910Designed to interface with the [subxt](https://github.com/paritytech/subxt) crate.1112## โจ Features1314- Query account balances and storage dynamically15- List pallets and their entries16- Fetch and filter events and extrinsics17- Submit and watch dynamic signed transactions18- Access system and block information19- Custom RPC calls to Substrate nodes2021## ๐ Potential Use Cases22231. AI-Driven Blockchain Operations2425 - 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.26 - Build a chatbot that can answer questions, fetch balances, or explain on-chain activity using your MCP server as the backend.27 - 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.28292. Custom Dashboards and Monitoring3031 - Create custom dashboards and monitoring systems for your Substrate blockchain32 - Display real-time data and analytics on your blockchain operations33 - Set up alerts and notifications for critical events34 - Use AI agents to detect suspicious activity by analyzing events and extrinsics in real time.3536## ๐ ๏ธ Requirements3738- Rust39- Access to a Substrate node endpoint (WebSocket)40- A valid signing keypair (as hex)41- Runtime metadata file for your target chain (see below for naming and placement)4243## ๐ฆ Installation4445Clone the repository and build:4647```sh48git clone https://github.com/ThomasMarches/substrate-mcp-rs.git49cd substrate-mcp-rs50cargo build --release51```5253## โ๏ธ Configuration5455Create a `.env` file in the project root with the following variables:5657```env58# WebSocket endpoint for the Substrate node59RPC_URL=wss://your-node-url.example.com6061# Signing keypair as hex (32 bytes, e.g. output of subkey inspect-key --scheme Sr25519)62SIGNING_KEYPAIR_HEX=your_signing_keypair_hex_here63```6465### Generating a Signing Keypair6667You can generate a keypair and get the secret seed in hex using [subkey](https://paritytech.github.io/polkadot-sdk/master/subkey/index.html):6869```sh70subkey generate --scheme Sr25519 --output-type Json71```7273Use the `secretSeed` field (strip the 0x prefix if present) for `SIGNING_KEYPAIR_HEX`.7475### Obtaining and Placing Runtime Metadata7677Export the runtime metadata from your node and place it at `artifacts/metadata.scale`:7879```sh80subxt metadata -f bytes > artifacts/metadata.scale81```8283**Important:** The file must be named `metadata.scale` and located in the `artifacts/` directory before building. The build will fail if this file is missing or misnamed.8485## โถ๏ธ Usage8687To start the MCP server:8889```sh90cargo run --release91```9293The server will start and listen for MCP requests via stdio.9495## ๐๏ธ Integrating with Cursor9697To use this MCP server with [Cursor](https://www.cursor.so/), you need to add it to your Cursor MCP configuration. This allows Cursor to discover and interact with your Substrate MCP server.98991. Build your server in release mode:100101 ```sh102 cargo build --release103 ```1041052. Locate the path to the built binary (typically `target/release/substrate-mcp-rs`).1061073. In your project (or global) `.cursor/mcp.json` file, add an entry for your server. For example:108109 ```json110 {111 "mcpServers": {112 "substrate-mcp-rs": {113 "command": "$PROJECT_ROOT_ABSOLUTE_PATH/target/release/substrate-mcp-rs",114 "args": []115 }116 }117 }118 ```119120 - Replace the `command` path with the absolute path to your built binary if it differs.1211224. Restart Cursor. It should now detect and connect to your Substrate MCP server, making its tools available for use.123124For more details, see the [Cursor documentation](https://docs.cursor.com/context/model-context-protocol) or the [Model Context Protocol introduction](https://modelcontextprotocol.io/introduction).125126## ๐งฐ Available Tools127128The server exposes a set of tools for interacting with a Substrate blockchain, including:129130- `query_balance`: Fetch the balance of an account131- `list_pallets`: List all pallets in the runtime132- `list_pallet_entries`: List all storage entries for a pallet133- `dynamic_runtime_call`: Execute a runtime API call134- `send_dynamic_signed_transaction`: Construct, sign, and send a transaction135- `query_storage`: Query storage by pallet and entry136- `get_latest_events`: Get all events from the latest block137- `find_events`: Find specific events by pallet and variant138- `get_latest_block`: Get details about the latest block139- `get_block_by_hash`: Get block details by hash140- `find_extrinsics`: Find extrinsics in the latest block141- `get_system_info`: Get system info via RPC142- `custom_rpc`: Make a custom RPC call143144See [`src/tooling/substrate.rs`](src/tooling/substrate.rs) for full details and parameters.145146## ๐๏ธ Project Structure147148- `src/main.rs`: Entry point, sets up logging and starts the MCP server149- `src/tooling/`: Contains the Substrate tool implementation150- `artifacts/`: Place your runtime metadata file here as `metadata.scale` (required before building)151152## ๐ Next Steps and Goals153154- [ ] Add E2E tests155- [ ] Add Unit tests156- [ ] Add more tools157158## ๐ค Contributing159160Contributions are welcome! Please open issues or pull requests. For larger changes, open an issue first to discuss your proposal.161162- Follow Rust best practices and ensure code is documented163- Run `cargo fmt` and `cargo clippy` before submitting164- Add tests where possible165166## ๐ License167168MIT169
Full transparency โ inspect the skill content before installing.