mcp-server-hyperledger-fabric
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-hyperledger-fabric Read asset asset1 from the asset-transfer chaincode."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Features
π Query chaincode β evaluate read-only functions, private data supported
βοΈ Invoke chaincode β submit transactions, returns txid + commit status
π§ͺ Endorse chaincode β dry-run a write without committing
π¦ Read the ledger β blocks, transactions, chaincode events
π§Ύ Structured output β every tool declares an
outputSchemaand returnsstructuredContent, so clients validate results instead of parsing textπ₯ Check peer health β height, last block, latency (no REST required)
π Chaincode API discovery β
mcp-server-hyperledger-fabric scangenerates descriptions served as MCP resourcesπ³ Docker image β isolated server with per-call stderr logging
Related MCP server: Hyperledger Fabric MCP Server
Installation
npm install -g mcp-server-hyperledger-fabricRequires Node.js β₯ 20 and a Fabric 2.5+ network with the Gateway service enabled.
Quickstart
1. Configure the network
Copy .env.example to .env in the project root and fill in your network values.
The server reads .env from its own directory automatically β no env vars to pass
from the MCP client:
cp .env.example .env # fill in your network valuesClaude Code config stays minimal:
{
"mcpServers": {
"hyperledger": {
"command": "mcp-server-hyperledger-fabric"
}
}
}Existing environment variables take precedence over .env (standard dotenv
behavior), so you can still override per-launch if needed.
To work with several networks at once, give each one its own MCP server entry
with its own env block β those values override .env. Copy
.mcp.example.json to .mcp.json (git-ignored) and fill in the paths.
2. Scan your chaincodes (recommended)
The model needs to know your chaincode's contract and method names. Generate descriptions once (see Chaincode API scan):
mcp-server-hyperledger-fabric scan ./chaincode-typescript --name asset-transfer
# β chaincode-api/asset-transfer.jsonThe server picks up ./chaincode-api by default β no extra config needed.
3. Verify
Ask the model to read something, e.g. "read asset asset1". If it finds and calls
query_chaincode, the server is working.
Configuration
All configuration comes from environment variables (see .env.example).
Variable | Required | Default | Description |
| β | β | gRPC endpoint of the gateway peer, |
| β | β | Default channel named in the server instructions sent to the client |
| β |
| Use TLS. |
| with TLS | β | Path to the peer's TLS CA cert (PEM) |
| β | β | Override TLS server name (SSH tunnel) |
| β | β | MSP ID of the identity |
| β | β | Path to the enrollment signcert (PEM) |
| β | β | Path to the private key (PEM) |
| β | β | Gateway REST API base URL (for |
| β |
| Chaincode API descriptions (file or dir) from |
| β |
| Register only read tools; |
| β |
| Log |
| β |
| Deadline for each network call |
| β |
| Dedup window for |
Tools
Tool | Description | Read-only |
| Evaluate a chaincode read function (supports private data) | β |
| Submit a transaction; returns txid + commit status (supports private data) | β (destructive) |
| Dry-run a write: endorse without committing | β |
| Block summary by number (hashes, txids) | β |
| Find a block by its data hash (block scan) | β |
| Find a transaction by ID (block scan) | β |
| Ledger height via Fabric Gateway REST API | β |
| Recent chaincode events, filterable by | β |
| Peer health: height, last block, response latency | β |
Chaincode API scan
The model needs to know a chaincode's contract and method names to call it. Instead of guessing, generate a machine-readable description from the chaincode source once:
mcp-server-hyperledger-fabric scan ./chaincode-typescript --name asset-transfer
# β chaincode-api/asset-transfer.jsonSeveral chaincodes? Scan each into the same directory β the server serves them all:
mcp-server-hyperledger-fabric scan ./cc-one --name cc-one
mcp-server-hyperledger-fabric scan ./cc-two --name cc-two
# β chaincode-api/cc-one.json, chaincode-api/cc-two.json--name is the chaincode name in Fabric; if omitted, the directory name is used.
Re-run the scan whenever the chaincode changes β the server re-reads the files on
every access, no restart needed.
The scanner reads fabric-contract-api decorators from TypeScript source:
Decorator | Meaning |
| Marks the default contract |
| Submit (write) method |
| Evaluate (read) method |
| Return type |
Only @Transaction-marked methods are exposed by the chaincode runtime, so
helpers are skipped.
The generated chaincode-api/*.json files are served to the model as MCP
resources (fabric://chaincode/<name>), so it can look up contracts and methods
itself instead of guessing. The server picks up the directory from ./chaincode-api
(or FABRIC_CHAINCODE_API); files are re-read on every access, so re-running the
scan applies without a restart.
Scan output goes to chaincode-api/ by default β a directory that is git-ignored
in this repo, so generated descriptions never get committed. Use -o <file.json>
for a single file or -o <dir> for a custom directory.
Docker (local, for logs)
The container isolates the server and prints every tool call to stderr β you see what the agent invokes and with which parameters, without reading the MCP protocol:
[mcp-server-hyperledger-fabric] query_chaincode <- {"channel":"mychannel","contract":"AssetContract","method":"GetAsset","args":["1"]}
[mcp-server-hyperledger-fabric] query_chaincode OK 12ms β {"assetId":"1","owner":"alice","value":100}
[mcp-server-hyperledger-fabric] invoke_chaincode ERROR 900ms β Fabric error: endorsement failed: chaincode errorBuild and verify:
docker compose build # build the image
docker compose run -T --rm mcp-server-hyperledger-fabric # one-off, MCP server over stdio
node scripts/docker-smoke.mjs # smoke test against a real networkPaths are not hardcoded: WALLET_DIR (where the certs live) is set in your local
.env (git-ignored), defaulting to ./wallets in the project folder.
Claude Code connects to the image via docker compose run β the compose file
carries the env file and mounts, so the client config stays path-free:
claude mcp add hyperledger -- docker compose run -T --rm mcp-server-hyperledger-fabricLogs: while a Claude Code session is open, the container is alive in Docker
Desktop β Containers tab β View β Logs (or docker logs <name>). The
container is --rm, so it is removed when the session closes, logs included.
What gets mounted (not baked into the image β no rebuild needed on edits):
Container path | From | What |
|
| certs and key (ro) |
|
| chaincode API descriptions (ro) |
Secrets live only in .env / .env.docker (both git-ignored) and never enter
the image. docker compose build is only needed when the server code changes; a
fresh chaincode scan applies without a rebuild.
Testing against the Fabric test-network
# start the test network with the asset-transfer sample
./network.sh up createChannel -c mychannel -ca
./network.sh deployCC -ccn asset-transfer -ccp ../asset-transfer-basic/chaincode-go
# export the generated identity and TLS cert
export FABRIC_PEER_ENDPOINT=localhost:7051
export FABRIC_TLS=true
export FABRIC_PEER_TLS_CERT=$PWD/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export FABRIC_MSP_ID=Org1MSP
export FABRIC_CERT=$PWD/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/cert.pem
export FABRIC_KEY=$PWD/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk
npm run devDevelopment
npm install
npm run build # tsc β dist/
npm run lint # Biome: lint + format + import order
npm run format # apply Biome fixes
npm test # node:test unit tests
npm run dev # tsx watchSecurity
This server holds a real Fabric identity (private key). Read SECURITY.md before deploying. Key points:
Secrets only via environment variables β never commit
.envor certs.TLS on by default;
FABRIC_TLS=falseis for local test-network only.All tool inputs validated with strict zod schemas.
invoke_chaincodeis marked destructive so clients confirm before writes.Business errors return
{ isError: true }β no raw stack traces.
License
Available Tools
9 toolscheck_network_statusCheck network statusARead-onlyIdempotent
Check peer health: ledger height, last block, response latency. Use before a series of calls to confirm the peer is reachable.
Inputs: channel (required), timeoutMs. Returns: height, status, lastBlock, latencyMs, +1 more
endorse_chaincodeEndorse chaincode (dry run, no commit)ARead-onlyIdempotent
Validate a chaincode transaction by endorsing it without submitting to the orderer. Nothing is committed. Use to check a write will pass before invoking.
Inputs: method (required), channel (required), chaincode (required), args, +2 more. Returns: result, transactionId
get_blockGet block by numberARead-onlyIdempotent
Read a block from the Fabric ledger by block number and return a summary (number, hashes, transactions).
Inputs: number (required), channel (required), timeoutMs. Returns: txIds, number, txCount, dataHash, +1 more
get_block_by_hashGet block by data hashARead-onlyIdempotent
Find a block by its data hash by scanning blocks forward from startBlock. Returns the block summary.
Inputs: hash (required), channel (required), maxBlocks, timeoutMs, +1 more. Returns: hash, found, txIds, number, +4 more
get_blockchain_infoGet blockchain infoARead-onlyIdempotent
Read ledger height and hashes for a channel via the Fabric Gateway REST API. Requires FABRIC_REST_URL.
Inputs: channel (required). Returns: height, currentBlockHash, previousBlockHash
get_chaincode_eventsGet chaincode eventsBRead-onlyIdempotent
Read recent chaincode events from the Fabric ledger (event name, transaction, block, payload).
Inputs: channel (required), chaincode (required), limit, eventName, +2 more. Returns: events
get_transactionGet transaction by IDARead-onlyIdempotent
Find a transaction by its ID by scanning blocks forward from startBlock. Returns the block summary containing the transaction.
Inputs: txid (required), channel (required), maxBlocks, timeoutMs, +1 more. Returns: txid, found, txIds, number, +4 more
invoke_chaincodeInvoke chaincode (submit, writes state)ADestructive
Submit a chaincode transaction that changes state. Returns transaction ID and commit status. Use only when a state change is intended. A commit-status timeout does NOT mean the transaction failed β it may still commit; check get_transaction before retrying.
Inputs: method (required), channel (required), chaincode (required), args, +2 more. Returns: note, status, successful, blockNumber, +2 more
query_chaincodeQuery chaincode (evaluate, read-only)ARead-onlyIdempotent
Evaluate a chaincode read function on Hyperledger Fabric and return its result. Use for reads, never for state changes.
Inputs: method (required), channel (required), chaincode (required), args, +2 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 9 tools
Most tools have clearly distinct purposes: read chaincode, invoke, endorse, block/transaction lookup, and event retrieval are well separated. The main overlap is between get_blockchain_info and check_network_status, both of which report ledger height/status, though one is channel-level info and the other is peer health.
All tool names use consistent snake_case with a verb_noun pattern such as get_block, query_chaincode, invoke_chaincode, and check_network_status. The convention is predictable throughout.
Nine tools is well-scoped for a Hyperledger Fabric gateway server, covering reads, writes, endorsement, events, transactions, blocks, and health checks without excessive surface area.
The set covers core ledger and chaincode operations including reads, state-changing invokes, endorsement checks, transaction lookup, block lookup, and events. Minor gaps exist around chaincode metadata, channel listing, or richer event filtering, but the main workflows are supported.
Maintenance
Related MCP Connectors
Provide AI agents and automation tools with contextual access to blockchain data including balanceβ¦
Manage your blockchain infrastructure across 80+ chains with your agents.
Read-only smart-contract security intelligence for autonomous agents.
AI agent infrastructure for discovery, authorization, execution, identity, and signed receipts.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables interaction with ResilientDB blockchain through smart contract operations, GraphQL queries, and key-value storage operations.-
- AlicenseAqualityBmaintenanceEnables AI assistants to interact with Hyperledger Fabric blockchain networks, supporting chaincode queries and invocations, block and transaction retrieval, chaincode lifecycle management, and channel operations.128 npm2ISC

Nexus MCP Serverofficial
AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with the Nexus blockchain, providing tools for querying blockchain data, smart contract calls, transaction submission, and event monitoring.6MIT- AlicenseNot gradedqualityDmaintenanceEnables AI agents to perform Web3 development operations such as toolchain diagnostics, chain registry queries and live probing, address validation, secret scanning, deployment logging, and standards searches across multiple blockchains.MIT