mcp-server-hyperledger-fabric
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
This server cannot be deployed
Maintenance
Related MCP Connectors
Provide AI agents and automation tools with contextual access to blockchain data including balanceβ¦
Read-only smart-contract security intelligence for autonomous agents.
AI agent infrastructure for discovery, authorization, execution, identity, and signed receipts.
Read-only gateway for durable agent identity, consent, recognized work, 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.123 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 interact with the GIWA blockchain, including balance queries, contract interactions, Flashblocks preconfirmations, Dojang attestations, and UP ID resolution.MIT