Hyperledger Fabric MCP Server
A Model Context Protocol (MCP) server that enables AI assistants to interact with Hyperledger Fabric blockchain networks.
Features
Query Chaincode - Execute read-only queries on smart contracts
Invoke Chaincode - Submit transactions to the blockchain
Get Block Info - Retrieve detailed information about specific blocks
Get Blockchain Info - Get network statistics (block height, hashes)
Get Transaction History - View history for specific assets
List Enrolled Identities - View wallet identities
Chaincode Lifecycle Management - Query installed, approved, and committed chaincodes
Commit Readiness Check - Verify chaincode definitions before committing
Channel Management - List channels and get channel information
Multiple Transport Modes - Supports both stdio and HTTP/SSE (for web clients)
Prerequisites
Node.js v18+
A running Hyperledger Fabric network
Valid connection profile JSON
Enrolled user identity (certificate + private key)
Installation
Configuration
Option 1: Environment Variables
Copy the template and configure:
Edit .env with your settings:
Option 2: Claude Desktop Config
Add environment variables directly in claude_desktop_config.json:
Wallet Setup
Create a wallet from your certificate and private key:
Or set environment variables and run:
Build & Run
Stdio Mode (Default)
HTTP Mode (for Web Clients)
Run the MCP server as an HTTP server with SSE support:
Available Tools
1. invoke_chaincode
Submit a transaction to the blockchain.
Parameters:
function(string): Chaincode function nameargs(array): Arguments to pass
Example:
2. query_chaincode
Query the blockchain (read-only).
Parameters:
function(string): Chaincode function nameargs(array): Arguments to pass
Example:
3. get_block_info
Get information about a specific block.
Parameters:
blockNumber(number): The block number to retrieve
4. get_blockchain_info
Get blockchain statistics including total blocks and hashes.
Parameters: None
5. get_transaction_history
Get transaction history for an asset (requires chaincode support).
Parameters:
assetId(string): The asset ID
6. list_enrolled_identities
List all identities in the wallet.
Parameters: None
7. get_installed_chaincodes
Get list of chaincodes installed on the peer.
Parameters: None
8. get_approved_chaincode
Get the approved chaincode definition for an organization.
Parameters:
chaincodeName(string): The name of the chaincode
9. get_committed_chaincode
Get the committed chaincode definition on the channel.
Parameters:
chaincodeName(string): The name of the chaincode
10. check_commit_readiness
Check if a chaincode definition is ready to be committed.
Parameters:
chaincodeName(string): The name of the chaincodesequence(number): The sequence number of the chaincode definitionversion(string): The version of the chaincode
11. list_channels
List all channels the peer has joined.
Parameters: None
12. get_channel_info
Get information about a specific channel.
Parameters:
channelName(string): The name of the channel
Example Usage with AI Assistant
Project Structure
Troubleshooting
"Identity not found in wallet"
Run npm run create-wallet with your credentials.
"Cannot find module" error
Ensure you've run npm run build and the path in config is absolute.
Connection errors
Verify your connection profile paths and that the Fabric network is running.
Usage
Using npx (without installing)
Installing locally
Using SSE
License
ISC
This server cannot be installed