home / mcp / hyperledger fabric mcp server
Provides programmatic access to Hyperledger Fabric networks for querying chaincode, invoking transactions, and retrieving blockchain data via an MCP API.
Configuration
View docs{
"mcpServers": {
"adityajoshi12-fabric-mcp-server": {
"url": "http://localhost:3000/mcp",
"headers": {
"MCP_PORT": "3000",
"FABRIC_MSP_ID": "Org1MSP",
"MCP_TRANSPORT": "stdio",
"FABRIC_CHANNEL": "mychannel",
"FABRIC_USER_ID": "appUser",
"FABRIC_CHAINCODE": "basic",
"FABRIC_WALLET_PATH": "/path/to/wallet",
"FABRIC_CONNECTION_PROFILE": "/path/to/connection-profile.json"
}
}
}
}You run a Hyperledger Fabric MCP Server to let AI assistants interact with your Fabric network. It enables querying chaincode, submitting transactions, retrieving block and network information, managing channels and chaincode definitions, and listing identities. This guide shows practical steps to install, configure, and use the server in both local (stdio) and HTTP/SSE modes.
Connect to the MCP server using a client that supports the MCP protocol. You can run the server in stdio mode for local development or in HTTP mode to serve web clients via SSE. Once running, you can perform actions such as querying chaincode, invoking transactions, inspecting blocks, and enumerating channels or identities. Use the available tool endpoints to interact with the Hyperledger Fabric network without writing low-level SDK calls.
# Prerequisites
Node.js v18+
A running Hyperledger Fabric network
A valid connection profile JSON
An enrolled user identity (certificate + private key)
# 1) Install dependencies
npm install
# 2) Build the TypeScript sources
npm run build
# 3) Optionally run in development mode (auto-reloads)
npm run dev
# 4) Start in stdio mode (default)
npm start
# 5) Start in HTTP mode with SSE (explicit transport)
MCP_TRANSPORT=http MCP_PORT=8080 npm start
```
Type a single command for the final start sequence you prefer; the example above shows both a local stdio start and an HTTP server start. Ensure your Fabric network is running and your wallet contains an enrolled user."Configure the server by supplying environment variables that point to your Fabric channel, chaincode, wallet, and connection profile. The following environment variables are used by the server:
- FABRIC_CHANNEL: the channel name to target (e.g., mychannel) - FABRIC_CHAINCODE: the chaincode name (e.g., basic) - FABRIC_MSP_ID: your org MSP ID (e.g., Org1MSP) - FABRIC_WALLET_PATH: path to the wallet directory - FABRIC_CONNECTION_PROFILE: path to the Fabric connection profile JSON - FABRIC_USER_ID: enrolled user ID (e.g., appUser) - MCP_TRANSPORT: transport mode, either stdio or http (default is stdio) - MCP_PORT: port to listen on when using HTTP transport" ,
- Stdio mode is the default for local development and debugging. It communicates directly via the process I/O and does not require network configuration. - HTTP mode enables web clients to connect over SSE. Start the server with MCP_TRANSPORT=http and set MCP_PORT to the listening port (for example 8080)."
If you need to switch transports, stop the server, set MCP_TRANSPORT to http or stdio, and restart. Ensure your connection profile paths and wallet paths are correct so the server can locate identities and network details.
Submit a transaction to the blockchain by invoking a chaincode function with arguments.
Query the blockchain to read data via a chaincode function with arguments.
Retrieve information about a specific block by number.
Return overall blockchain statistics such as height and hashes.
Obtain the history of transactions for a given asset or key.
List identities present in the wallet.
List chaincodes installed on the peer.
Fetch the approved chaincode definition for an organization.
Fetch the committed chaincode definition on the channel.
Check if a chaincode definition is ready to be committed.
List the channels the peer has joined.
Get information about a specific channel.