Swarm Provenance MCP
⚠️ ALPHA SOFTWARE - PROOF OF CONCEPT This software is alpha and should be considered a Proof of Concept. Use for testing and experimentation only. Not recommended for production use.
⚠️ DATA PERSISTENCE WARNING Storage on Swarm is rented storage with limited time periods. The default configuration uses very short rental periods (approximately 1 day). Do not expect uploaded data to persist longer than the rental period. Data will become unavailable when the postage stamp expires.
⚠️ TESTNET NOTICE On-chain provenance features use Base Sepolia (testnet) by default. Testnet tokens have no monetary value and testnet state may be reset at any time. Do not rely on testnet anchoring for production data integrity. No warranties of any kind are provided.
PAYMENTS This server cannot pay x402 requests. It uses the gateway's free tier (
PAYMENT_MODE=free, the default) or sends no payment header. For paid use, run a similar operation from start to end instead of this server, with one of these:
- The Swarm Provenance CLI:
swarm-prov-upload --x402. See its x402 setup guide.- The TypeScript SDK:
@datafund/swarm-provenance,ProvenanceClientwithgatewayUrland thepaymentoption. Set the payment network to the gateway's network. That option's format differs between SDK releases, so follow the README of the installed version, as shown on npm.The default gateway of the CLI and SDK charges real USDC on Base mainnet.
A Model Context Protocol (MCP) server for managing Swarm postage stamps and provenance data storage through a centralized FastAPI gateway. Enables AI agents to upload provenance data to the decentralized Swarm network for immutable storage and retrieve it by reference.
For AI agents: follow the skill in skills/swarm-provenance-mcp/SKILL.md and the safe defaults in AGENTS.md.
Overview
This MCP server provides tools for AI agents to interact with Swarm postage stamps and provenance data storage, including purchasing and extending stamps, uploading provenance data to Swarm for immutable decentralized storage, and downloading data from the network by reference. It acts as a bridge between AI agents and the swarm_connect FastAPI gateway.
Provenance & Immutable Storage
This MCP server is specifically designed for provenance data use cases, leveraging Swarm's decentralized network to provide:
- Immutable Records: Swarm addresses content by its hash, so the data stored under a reference cannot be changed.
download_datachecks content against its reference only in the cases its reference check lists - Decentralized Storage: No single point of failure or central authority
- Provenance Metadata: Support for structured provenance records with creator, timestamp, and lineage information
- Reference Check on Download:
download_datarecomputes the Swarm chunk address of content up to 4 KB and reports the content as verified only when that address equals the reference. References from/bzzuploads name a manifest and are reported as not checked; see datafund/swarm_connect#499
Features
- Purchase Stamps: Create new postage stamps with configurable duration and size
- Stamp Status: Get detailed information about specific stamps
- List Stamps: View all available postage stamps
- Extend Stamps: Extend the duration of existing stamps
- Data Upload: Upload data to Swarm network with stamp validation
- Data Download: Download data from Swarm network by reference
- Provenance Storage: Store data with provenance metadata as immutable records whose on-chain registration you can check with
verify_hash - On-Chain Verification (on by default): Check whether a data hash is registered and read its provenance record and lineage with
verify_hash,get_provenance,get_provenance_chainandlookup_by_storage_ref. They need no wallet and no gas.CHAIN_ENABLED=falseturns them off - Health Monitoring: Check gateway and Swarm network connectivity
- Chain Diagnostics: Check RPC connectivity with
chain_health(on by default) and the wallet balance withchain_balance(needsCHAIN_ENABLED=trueandPROVENANCE_WALLET_KEY) - On-Chain Anchoring (optional, needs
CHAIN_ENABLED=trueandPROVENANCE_WALLET_KEY): Register data hashes (the SHA-256 of the data) on-chain for immutable provenance records, linked to their Swarm reference - Transformation Lineage (optional): Record data transformations with
record_transformand follow the lineage of a hash withget_provenance_chain. For step-by-step workflows, see Record a Transformation, Multi-Step Pipeline and Transformation Chain in SKILLS.md - Merge Transformations (optional): Record N-to-1 merge transformations combining multiple source hashes into one with
record_merge_transform. For the workflow, see Merge Multiple Sources in SKILLS.md
Installation
Prerequisites
- Python 3.10 or higher (use
python3command) - Internet connection (uses public gateway by default)
- Optional: Self-hosted
swarm_connectgateway service (see Gateway Options below)
Network requirements
The server needs outbound HTTPS. In a sandbox with an egress allowlist, allow these hosts, or the tool calls fail with connection errors:
- The gateway:
provenance-gateway.datafund.ioby default, or the host inSWARM_GATEWAY_URL. - The chain RPC, when a chain tool or
health_checkruns (the read-only chain tools are on by default;CHAIN_ENABLED=falseturns them off). Onbase-sepolia(the default): the RPCsepolia.base.org, and the fallbacks the server tries after it, in order:base-sepolia-rpc.publicnode.com,base-sepolia.drpc.organdbase-sepolia.gateway.tenderly.co. WithCHAIN_NAME=base:mainnet.base.org,base-rpc.publicnode.comandbase.drpc.org.CHAIN_RPC_URLreplaces the primary RPC; set alone, it also drops the preset fallbacks, so the server calls only that host.CHAIN_RPC_URLS(comma-separated) replaces the fallbacks; set alone, the preset primary stays first. Set both, and the server callsCHAIN_RPC_URL, then theCHAIN_RPC_URLShosts in order. pypi.org:health_checkasks it whether a newer release exists. It waits at most 3 seconds in total (DNS, connect and the answer), then goes on without it; the answer is kept for a day, a failure for an hour. Only final releases are compared, so a development or release-candidate build gets no notice.UPDATE_CHECK=falseturns this off.uvxalso needs PyPI the first time it runs the package.
From PyPI
Listed in the MCP Registry as io.github.datafund/swarm-provenance-mcp. The registry checks the next line to confirm that this PyPI package belongs to that name:
mcp-name: io.github.datafund/swarm-provenance-mcp
The server is also listed on Glama. There you can browse its tools and quality score, and try it online with the MCP Inspector before you install it.
Run the server without installing it, with uv:
uvx swarm-provenance-mcp
Or install it:
pip install swarm-provenance-mcp
To use it in Claude Desktop, put this in claude_desktop_config.json:
{
"mcpServers": {
"swarm-provenance": {
"command": "uvx",
"args": ["swarm-provenance-mcp"]
}
}
}
Settings go in ~/.config/swarm-provenance-mcp/.env, as described under Configuration.
Maintainers: the release process is in RELEASING.md.
From source
- Clone the repository:
git clone https://github.com/datafund/swarm_provenance_MCP.git
cd swarm_provenance_MCP
- Create and activate a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the package:
pip install -e .
- Configure environment variables:
mkdir -p ~/.config/swarm-provenance-mcp
cp .env.example ~/.config/swarm-provenance-mcp/.env
# Edit that file to configure your gateway URL and defaults
Docker
Run the MCP server in a container with no local dependencies.
Registry: The pre-built image is published to GitHub Container Registry only — always use the full
ghcr.io/prefix. It is not available on Docker Hub.
Quick start (pre-built image):
docker pull ghcr.io/datafund/swarm-provenance-mcp:latest
docker run -i --rm ghcr.io/datafund/swarm-provenance-mcp
Build from source:
docker build -t swarm-provenance-mcp .
docker run -i --rm swarm-provenance-mcp
With environment variables:
docker run -i --rm \
-e SWARM_GATEWAY_URL=https://provenance-gateway.datafund.io \
-e DEFAULT_STAMP_DURATION_HOURS=25 \
-e DEFAULT_STAMP_SIZE=small \
swarm-provenance-mcp
Docker Compose:
docker compose build
docker compose run --rm swarm-provenance-mcp
Compose takes its variables from ./.env next to docker-compose.yml (for ${VAR}
substitution and as the container's env_file) and passes them to the server as
environment variables. That is Compose's own file, separate from the server's env file
described under Configuration: the container never sees
~/.config/swarm-provenance-mcp/.env on the host.
| Variable | Description | Default |
|---|---|---|
SWARM_GATEWAY_URL |
Gateway endpoint URL (http:// or https://; plain http to a remote host logs a warning) |
https://provenance-gateway.datafund.io |
DEFAULT_STAMP_DURATION_HOURS |
Default stamp duration in hours (min 24) | 25 |
DEFAULT_STAMP_SIZE |
Default stamp size: small, medium, or large |
small |
PAYMENT_MODE |
Gateway payment tier: free (3 write req/min) or empty (no payment header); other values stop the server at start-up |
free |
Configuration
Settings come from environment variables, or from an env file. The env file is never read from the working directory (whichever program launches the server controls that). It is read from, in order:
- the path in
SWARM_PROVENANCE_ENV_FILE, if set. It must be an absolute path (~/...is fine); start-up fails if it is relative or the file does not exist; - otherwise
~/.config/swarm-provenance-mcp/.env(or$XDG_CONFIG_HOME/swarm-provenance-mcp/.env), if it exists.
Real environment variables (for example an MCP client's "env" block) override the env file.
Unknown keys in the env file are ignored. If a .env in the working directory is found and
ignored, the server logs a warning at start-up.
-
SWARM_PROVENANCE_ENV_FILE: Explicit absolute path of the env file to load (see above) -
SWARM_GATEWAY_URL: URL of the swarm_connect FastAPI gateway (default:https://provenance-gateway.datafund.io). Must behttp://orhttps://with a host and, if given, a numeric port (0 to 65535), or the server does not start. Plainhttp://to a host other than this machine logs a warning at start-up and adds ahealth_checkrecommendation. TheX-Payment-Modeheader is not sent on a redirect to another origin -
DEFAULT_STAMP_DURATION_HOURS: Default stamp duration in hours, minimum 24 (default:25) -
DEFAULT_STAMP_SIZE: Default stamp size —small,medium, orlarge(default:small) -
PAYMENT_MODE: Gateway payment tier (default:free, rate limited to 3 write requests/minute). Set it to empty to send no payment header. Any other value stops the server at start-up, because this server cannot pay x402 requests
Chain Anchoring (Optional)
CHAIN_ENABLED: Which chain tools are listed. Unset (the default): the read-only toolschain_health,verify_hash,get_provenance,get_provenance_chainandlookup_by_storage_ref, which need no wallet.true: alsochain_balanceand the write toolsanchor_hash,record_transform,record_merge_transformandset_storage_ref, which needPROVENANCE_WALLET_KEY.false: no chain tools. A wallet key alone never turns on the write tools. An empty value counts as unsetCHAIN_NAME: Blockchain network —base-sepolia(testnet),base(mainnet), orlocalhost(local hardhat, chain 31337) (default:base-sepolia)PROVENANCE_WALLET_KEY: Private key for chain transactions (hex, with or without 0x prefix). A key that is set but invalid is logged as an error at start-up; the server still starts with chain writes disabled, and the write tools,chain_healthandhealth_checksay why. Read-only chain tools keep working. Use each key in one server process at a time. Two server processes that sign with the same key, for example one started by a desktop client and one by a command-line tool, can pick the same nonce, and one of the transactions then failsCHAIN_RPC_URL: Custom RPC endpoint (uses chain preset if not set). Forbase-sepoliaandbasethe endpoint must report the preset's chain ID, or the server refuses it; see Safety behaviorCHAIN_RPC_URLS: Comma-separated fallback RPC URLs, tried in order afterCHAIN_RPC_URL. The same chain ID check applies to each one; see Safety behaviorCHAIN_CONTRACT: Custom DataProvenance contract address (uses chain preset if not set).CHAIN_CONTRACT_ADDRESSis accepted too;CHAIN_CONTRACTwins if both are setCHAIN_EXPLORER_URL: Custom block explorer URL (uses chain preset if not set)CHAIN_GAS_LIMIT: Explicit gas limit for chain transactions (skips estimation if set)CHAIN_MAX_FEE_GWEI: Fee cap per gas (maxFeePerGas). Fee fields are set explicitly and a write is refused when the current fee is above the cap (default:0.5on mainnet,10on testnets)CHAIN_SESSION_BUDGET_ETH: Worst-case spend allowed per server session; each transaction reservesgas limit x max feeplus the L1 data fee allowance, and is charged its actual cost (L2 gas plus the receipt'sl1Feeon Base) once mined (default:0.002on mainnet,0.05on testnets)CHAIN_L1_FEE_ALLOWANCE_ETH: L1 data fee reserved per transaction on top of L2 gas (default:0.000001, about 100x the ~1e-8 ETH measured on Base mainnet on 2026-10-21; L2 gas there was 1e-6 to 3e-5 ETH per transaction)CHAIN_MAX_TX_PER_SESSION: Chain transactions allowed per server session (default:20on mainnet,500on testnets)CHAIN_REQUIRE_CONFIRM: Require a confirmed quote on gas-spending tools. Withoutconfirm: trueand a matchingquote_idthey send nothing and return a quote of the exact action (arguments, fee cap, remaining budget) with aquote_id: an HMAC over the tool and its validated arguments under a per-process key, single use, valid 10 minutes (default: mainnet only — any chain id other than 84532, 11155111, 31337 or 1337 counts as mainnet). See Safety behaviorMAX_STAMP_DURATION_HOURS: Maximumduration_hoursforpurchase_stamp/extend_stamp(default:8760)UPDATE_CHECK: Lethealth_checkaskpypi.orgwhether a newer release exists and, if so, add a line withuvx swarm-provenance-mcp@latest(default:true). The check waits at most 3 seconds in total (DNS, connect and the answer), keeps the answer for a day (an hour after a failure) and never failshealth_check; when it cannot reach PyPI in time it says nothing. Only final releases are compared: a running development or release-candidate build gets no notice
By default the read-only chain tools are listed: chain_health, verify_hash, get_provenance, get_provenance_chain and lookup_by_storage_ref. They work without a wallet key. With CHAIN_ENABLED=true, chain_balance and the write tools anchor_hash, record_transform, record_merge_transform and set_storage_ref are listed too; they require PROVENANCE_WALLET_KEY with a funded wallet. Blockchain dependencies (web3, eth-account) are included in the default install.
Contract versions
The DataProvenance contract has four deployments on Base Sepolia. They are named v1 to v4, in deployment order, as in the contract repository. The base-sepolia preset uses v4.
| Version | Address | Lineage support |
|---|---|---|
| v1 | 0x9a3c6F47B69211F05891CCb7aD33596290b9fE64 |
recordTransformation only. It stores the description and links no records in contract state. The link is only in the DataTransformed(originalDataHash, newDataHash, transformation) event |
| v2 | 0xD4a724CD7f5C4458cD2d884C2af6f011aC3Af80a |
All five lineage functions |
| v3 | 0xb309dDe00819668ac74075813108659d4332D2cC |
All five lineage functions |
| v4 (current) | 0x3945aDfd5Df9ab2F5cB4Ca0eb3D4384CC3650322 |
All five lineage functions |
The five lineage functions are recordTransformation, recordMergeTransformation, getTransformationParents, getChildHashes and getTransformationLinks.
Use contract v3 or v4 with this server. set_storage_ref needs contract v4. On contract v1 and v2, the tools that read a record do not work: anchor_hash, verify_hash, get_provenance, get_provenance_chain, set_storage_ref and lookup_by_storage_ref (#296).
Upgrading from a .env in the repository
Earlier versions read .env from the working directory, so the old setup was
cp .env.example .env in the repository plus "cwd": "/path/to/swarm_provenance_MCP"
in claude_desktop_config.json. That file is no longer read: after upgrading, the server
starts with the defaults (no wallet, CHAIN_ENABLED unset, so only the read-only chain tools) and only logs a warning.
- Move the file:
mkdir -p ~/.config/swarm-provenance-mcp && mv .env ~/.config/swarm-provenance-mcp/.env(or under$XDG_CONFIG_HOMEif you set it), or keep it where it is and setSWARM_PROVENANCE_ENV_FILEto its absolute path in the client's"env"block. - The
"env"block inclaude_desktop_config.jsonis unaffected and still overrides the env file. "cwd"no longer has any effect on configuration. You can remove it.
Gateway Options
Public Gateway (Recommended)
The MCP server uses the public gateway hosted by DataFund by default at https://provenance-gateway.datafund.io. This gateway provides:
- High availability and reliability
- No setup or maintenance required
- Direct access to the Swarm network
- Free to use for development and testing
Self-Hosted Gateway
You can also run your own gateway instance for:
- Custom configurations
- Private or isolated environments
- Local development
To use a self-hosted gateway:
- Clone the gateway repository:
git clone https://github.com/datafund/swarm_connect - Follow the setup instructions in that repository
- Set
SWARM_GATEWAY_URL=http://localhost:8000in your env file (~/.config/swarm-provenance-mcp/.env) or environment
Usage
Running the MCP Server
swarm-provenance-mcp
Available Tools
purchase_stamp
Purchase a new postage stamp.
Parameters:
duration_hours(int): Duration in hours, minimum 24 (optional, uses default if not provided)size(string): Stamp size —"small","medium", or"large"(optional, uses default if not provided)depth(int): Explicit depth override, 17–22, bypasses size (optional, advanced use only)label(string): Optional label for the stamp, at most 100 characters. If you omit it, the server generates a label of the formmcp-<hex>. The result shows it as "Label requested", because the gateway's answer does not confirm it;list_stampsshows the label the gateway stored
Example:
{
"name": "purchase_stamp",
"arguments": {
"duration_hours": 48,
"size": "small",
"label": "my-test-stamp"
}
}
get_stamp_status
Get detailed information about a specific stamp.
Parameters:
stamp_id(string): The batch ID of the stamp
Example:
{
"name": "get_stamp_status",
"arguments": {
"stamp_id": "000de42079daebd58347bb38ce05bdc477701d93651d3bba318a9aee3fbd786a"
}
}
list_stamps
List postage stamps. By default the result shows the 5 usable stamps with the most time left (by batchTTL, then by expiry) and a count line, for example Showing 5 of 47 stamps (12 usable). Pass all=true for the full list. With all: true it lists every stamp in the gateway's order. The hints and _next always use the full list. Expiry times are ISO 8601 UTC, for example 2026-12-02T09:11:00Z; get_stamp_status, check_stamp_health and the extend_stamp result use the same format.
Each stamp's Status uses the same rule as health_check:
Usable: usable, and itsaccessModeissharedor absent. Only these stamps work withupload_data.Not usable by this server: apoolstamp (gateway inventory), anownedstamp (registered to the wallet that paid for it) or another access mode. This server sends no wallet, so the gateway refuses its uploads.Not usable yet: a writable stamp that may still be propagating. Pollcheck_stamp_health; do not buy another.Cannot become usable: expired, about to expire, full, invalid depth, unreadable on the node, or not found on the node.Cannot be used: the batch ID is not in the expected format: a usable or pending stamp without a valid batch ID. An upload needs the ID, so the server counts it as an entry it cannot read.
_next is upload_data when a stamp is usable, check_stamp_health when a stamp is still propagating, and purchase_stamp otherwise. If the stamp list is unknown or incomplete (some entries are not in the expected format, or a usable or pending stamp has a batch ID that is not in the expected format), _next is health_check, never purchase_stamp. If no stamp is usable or pending and a stamp has an access mode the gateway does not document, _next is check_stamp_health, and the recommendation names that stamp's batch ID. If none of those stamps has a valid batch ID, no ID is named and the result does not recommend a purchase: list_stamps gives _next: health_check and health_check gives _next: list_stamps. If the same answer repeats, stop and report it to the gateway operator.
Parameters:
all(boolean): List every stamp, not only the 5 usable stamps with the most time left (default: false)
Example:
{
"name": "list_stamps",
"arguments": {"all": true}
}
extend_stamp
Extend an existing stamp with additional duration.
Parameters:
stamp_id(string): The batch ID of the stamp to extendduration_hours(int): Additional duration in hours, minimum 24
Example:
{
"name": "extend_stamp",
"arguments": {
"stamp_id": "000de42079daebd58347bb38ce05bdc477701d93651d3bba318a9aee3fbd786a",
"duration_hours": 48
}
}
upload_data
Upload data to the Swarm network with stamp validation. Returns the Swarm reference of the data. For an unsigned upload, the data hash that the chain tools take is the SHA-256 of the uploaded bytes; this tool does not return it. For a notary-signed upload it is not: see anchor_hash (this server does not compute it).
Parameters:
data(string): Data content to upload (max 4096 bytes)stamp_id(string): Batch ID of a usable stamp: one thatlist_stampsmarksUsable, or, only if none is usable and the user approved, one frompurchase_stampcontent_type(string): MIME type of the content (optional, default: "application/json")sign(string): Signing method (optional). The only accepted value is"notary"; see Signing with the notary below. Omit it for an unsigned upload. Any other value returns a validation error
Example:
{
"name": "upload_data",
"arguments": {
"data": "{\"message\": \"Hello Swarm!\"}",
"stamp_id": "000de42079daebd58347bb38ce05bdc477701d93651d3bba318a9aee3fbd786a",
"content_type": "application/json"
}
}
Signing with the notary: Set sign to "notary" to have the gateway sign the data at upload time. Call get_notary_info first to check that signing is available. With sign: "notary", data must be a JSON object with a top-level data field, for example {"data": {...}, "signatures": []}. The signatures field is optional and must be an array. The gateway adds its signature to it. sign: "notary" adds these 400 refusals to the errors of any upload:
- 400
INVALID_DOCUMENT_FORMATwhendatais not valid UTF-8 JSON, is not a JSON object with adatafield, or has asignaturesfield that is not an array. - 400
JSON_TOO_DEEPwhen objects and arrays nest deeper than the gateway's limit. The gateway measures the depth on the whole document, the{"data": ...}envelope included. The limit is 64 levels by default, and the gateway operator can change it. - 400
NOTARY_NOT_ENABLEDor 400NOTARY_NOT_CONFIGUREDwhen the notary is off.
A signing failure inside the gateway, for example an unusable notary key, returns 500, not 400.
The gateway stores the signed document as application/json, whatever content_type you send. The result reports the input size as "before signing", because the stored document is larger. The gateway's upload answer has no signature details, so the result says that a notary signature was requested and that the tool did not confirm it. To check the signature, read the signatures entry of the stored document (download_data returns it) and compare its signer with the address that get_notary_info returns.
download_data
Download data from the Swarm network using a Swarm reference. The result includes the SHA-256 of the bytes. For content stored by an unsigned upload_data, that is the data hash that the chain tools take; for a notary-signed upload it is the hash of the stored signed document, not the data hash (see anchor_hash).
Parameters:
reference(string): Swarm reference of the data to download: 64 hexadecimal characters, or 128 for an encrypted reference. Chain tools take only 64-character hashes
Result: For text and JSON content, the result has two content blocks. Read both:
- A summary with the size, the SHA-256 of the original bytes, the
Reference check:line (below), and the_nexthints. - The content, fenced as untrusted data. Control and bidirectional characters are escaped and the content is cut at about 16 KB, so this view is not byte-exact.
A client that reads only the first block gets the summary, not the payload. Binary (non-UTF-8) content returns a single block that gives the size and SHA-256 and does not include the bytes. See Safety behavior.
Reference check: the result has one Reference check: line that says what was checked.
verified: the content is at most 4096 bytes, and its single-chunk Swarm address (BMT hash) equals the 64-character reference. The bytes are the chunk that the reference names.not checked, with the reason. Nothing proves that the bytes belong to the reference:- The content's chunk address does not equal the reference. The reference is then probably a manifest. A
/bzzreference names a manifest root, whose address differs from the content's own chunk address. A Bee 2.8.2 upload recorded for the tests shows this (tests/fixtures/bee_chunks.json). The gateway stores data through Bee's/bzzendpoint, so references fromupload_datamost likely name a manifest. Only that last point comes from reading the gateway source; it was not confirmed with a live upload through the gateway. This server cannot follow a manifest to its content. A raw chunk endpoint on the gateway that would allow this is tracked in datafund/swarm_connect#499. - The content is larger than one chunk (4096 bytes).
- The reference is encrypted (128 hexadecimal characters).
- The content's chunk address does not equal the reference. The reference is then probably a manifest. A
A not checked result is not a mismatch. It means the gateway's bytes are shown as received. The result also reports the SHA-256 of the bytes, which you can compare with a hash you trust.
Example:
{
"name": "download_data",
"arguments": {
"reference": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a"
}
}
check_stamp_health
Run a health check on a specific stamp. Returns whether uploads can proceed, plus any errors or warnings with actionable suggestions.
Parameters:
stamp_id(string): The batch ID of the stamp to check
Example:
{
"name": "check_stamp_health",
"arguments": {
"stamp_id": "000de42079daebd58347bb38ce05bdc477701d93651d3bba318a9aee3fbd786a"
}
}
get_wallet_info
Get the gateway node's wallet address and BZZ balance. Useful for checking if the node has sufficient funds. Note: this is a debugging/diagnostic tool and may be removed in future versions.
Parameters: None
Example:
{
"name": "get_wallet_info",
"arguments": {}
}
get_notary_info
Check whether the notary signing service is enabled and available on the gateway.
Parameters: None
Example:
{
"name": "get_notary_info",
"arguments": {}
}
health_check
Check gateway and Swarm network connectivity status. Returns an adaptive status including stamp availability, a ready flag indicating whether uploads can proceed, and recommendations for next steps. ready is false when the gateway's Bee node reports no network (for example no connected peers), even if usable stamps exist. The output includes a Swarm network: line with the Bee node state.
Parameters: None
Example:
{
"name": "health_check",
"arguments": {}
}
chain_balance (optional — requires CHAIN_ENABLED=true and PROVENANCE_WALLET_KEY)
Check the on-chain wallet ETH balance used for provenance anchoring. Returns wallet address, balance, chain info, and actionable funding guidance when balance is low.
Parameters: None
Example:
{
"name": "chain_balance",
"arguments": {}
}
chain_health (on by default; CHAIN_ENABLED=false turns it off)
Test blockchain RPC connectivity for on-chain provenance. Returns connection status, chain name, chain ID, latest block number, and RPC response time. Does not require a wallet key.
Parameters: None
Example:
{
"name": "chain_health",
"arguments": {}
}
anchor_hash (optional — requires CHAIN_ENABLED=true and PROVENANCE_WALLET_KEY)
Register a data hash on the blockchain, creating an immutable provenance record with owner, timestamp, and data type. data_hash is the data hash: the SHA-256 of the data. storage_ref is the Swarm reference that upload_data returned; the two must differ. Example: upload_data returns a Swarm reference; for an unsigned upload, the data hash is the SHA-256 of the uploaded bytes (the SHA-256 of the original bytes line of download_data); then call anchor_hash(data_hash=<data hash>, storage_ref=<Swarm reference>). For a notary-signed upload, the data hash is the SHA-256 of the data field as canonical JSON (Python json.dumps(data, sort_keys=True, separators=(',', ':'))), the value the notary signs; this server does not compute it, and the download_data line is then the hash of the stored signed document. Costs gas. If the hash is already registered to the expected owner (owner, or the wallet address), it returns the existing record without error. With storage_ref, this holds only when the record already links the same storage reference; otherwise it returns an error that shows the existing reference. If another address owns the record, it returns an error that shows both addresses, and it sends no transaction.
Parameters:
data_hash(string, required): The data hash to anchor: the SHA-256 of the data, 64 hex characters.swarm_hash, its old name, is deprecated but still accepteddata_type(string): Data type/category (default:swarm-provenance). Must not be empty or only whitespace; at most 64 characters and 64 UTF-8 bytesowner(string): Ethereum address to register as owner (defaults to wallet address; requires delegate authorization for other addresses). The wallet's own address and the zero address are refused; a mixed-case address must have a valid EIP-55 checksumstorage_ref(string): Optional Swarm reference to link bidirectionally: the 64-character hex reference thatupload_datareturned. Enables reverse lookup vialookup_by_storage_ref. Works with or withoutowner. Withowner, the server calls theregisterDataForoverload that takes a storage reference. A reference equal todata_hashor all zeros is refusedconfirm(boolean): Set totrue, together withquote_id, to send the transaction. See Safety behaviorquote_id(string): Thequote_idfrom the quote for exactly these arguments (single use, valid for 10 minutes)
Example:
{
"name": "anchor_hash",
"arguments": {
"data_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a",
"data_type": "provenance-metadata"
}
}
verify_hash (on by default; CHAIN_ENABLED=false turns it off)
Check whether a data hash (the SHA-256 of the data) is registered on the blockchain. Returns verified status with basic provenance info (owner, timestamp, data type) if found. A record that an older workflow or the Swarm Provenance CLI anchored with a Swarm reference as its key can be checked by passing that Swarm reference. Read-only — no gas or wallet key required.
Parameters:
data_hash(string, required): The data hash to verify: the SHA-256 of the data, 64 hex characters.swarm_hash, its old name, is deprecated but still acceptedexpected_owner(string): Ethereum address the record must belong to. If the record belongs to another address, the result is an error that shows both addresses
Example:
{
"name": "verify_hash",
"arguments": {
"data_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a"
}
}
get_provenance (on by default; CHAIN_ENABLED=false turns it off)
Retrieve the full on-chain provenance record for a data hash (the SHA-256 of the data). Returns owner, registration timestamp, data type, status, transformations, and accessors. A record that an older workflow or the Swarm Provenance CLI anchored with a Swarm reference as its key can be checked by passing that Swarm reference. Read-only — no gas or wallet key required.
Parameters:
data_hash(string, required): The data hash to look up: the SHA-256 of the data, 64 hex characters.swarm_hash, its old name, is deprecated but still accepted
Example:
{
"name": "get_provenance",
"arguments": {
"data_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a"
}
}
record_transform (optional — requires CHAIN_ENABLED=true and PROVENANCE_WALLET_KEY)
Record a data transformation on-chain, linking the original data to its transformed version. Creates a verifiable lineage trail. The original hash must already be anchored. Costs gas. If the same (original → new) pair is already recorded, returns the existing link without spending gas (idempotent).
Parameters:
original_hash(string, required): The data hash of the original data: its SHA-256, 64 hex characters (must be already anchored)new_hash(string, required): The data hash of the transformed data: its SHA-256, 64 hex charactersdescription(string): Description of the transformation (max 256 chars, e.g., "Anonymized PII")restrict_original(boolean): If true, set the original data status to RESTRICTED after recording the transformation (default: false). This sends two transactions, and a quote covers bothconfirm(boolean): Set totrue, together withquote_id, to send the transaction. See Safety behaviorquote_id(string): Thequote_idfrom the quote for exactly these arguments (single use, valid for 10 minutes)
Example:
{
"name": "record_transform",
"arguments": {
"original_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a",
"new_hash": "b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abc",
"description": "Filtered for region EU",
"restrict_original": false
}
}
record_merge_transform (optional — requires CHAIN_ENABLED=true and PROVENANCE_WALLET_KEY)
Record an N-to-1 merge transformation on-chain, combining multiple source hashes into a single new hash. All source hashes must be already anchored. Costs gas. Needs contract v2 or later; see Contract versions. The default Base Sepolia contract supports merges.
Parameters:
source_hashes(array of strings, required): 2–50 data hashes of the sources to merge (the SHA-256 of each, 64 hex characters)new_hash(string, required): The data hash of the merged result: its SHA-256, 64 hex charactersdescription(string): Description of the merge transformation (max 256 chars)new_data_type(string): Data type for the merged result (default:"merged"). Must not be empty or only whitespace; at most 64 characters and 64 UTF-8 bytesconfirm(boolean): Set totrue, together withquote_id, to send the transaction. See Safety behaviorquote_id(string): Thequote_idfrom the quote for exactly these arguments (single use, valid for 10 minutes)
Example:
{
"name": "record_merge_transform",
"arguments": {
"source_hashes": [
"a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a",
"b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abc"
],
"new_hash": "c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abcde",
"description": "Merged EU and US datasets",
"new_data_type": "merged-dataset"
}
}
get_provenance_chain (on by default; CHAIN_ENABLED=false turns it off)
Follow the transformation lineage for a data hash (the SHA-256 of the data). The tool reads the links from the contract state. Shows how data evolved — from original to each derived version. Read-only — no gas or wallet key required. For the contract versions it works on, see Contract versions.
Each node in the output lists its parent hashes, and each transformation prints as an edge: Edge: <parent_hash> -> <child_hash>: "<description>".
The tool returns the nodes it could read. When the lineage is partial, the output starts with an INCOMPLETE banner and _next is get_provenance_chain. The banner lists:
- each node whose record or links could not be read, with a fixed label and the exception class name;
- each node that
max_depthstopped at, marked "not expanded" (this is not an error).
The banner ends with a Retry: line: call get_provenance_chain on the named hash, or with a larger max_depth. RPC transport errors are not reported this way: the server fails over to the next RPC endpoint, or returns a retryable error.
Parameters:
data_hash(string, required): The data hash to trace lineage for: the SHA-256 of the data, 64 hex characters.swarm_hash, its old name, is deprecated but still accepted. A record that an older workflow or the Swarm Provenance CLI anchored with a Swarm reference as its key can be checked by passing that Swarm reference.max_depth(integer): Maximum depth to traverse (default: 10, range: 1–50)
Example:
{
"name": "get_provenance_chain",
"arguments": {
"data_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a",
"max_depth": 10
}
}
set_storage_ref (optional — requires CHAIN_ENABLED=true and PROVENANCE_WALLET_KEY)
Attach a Swarm reference to an existing on-chain record, keyed by its data hash. Set-once: cannot be changed after first write. Owner-only. Useful after record_transform to link the transformed data's Swarm storage location.
Parameters:
data_hash(string, required): The data hash of the existing on-chain record: the SHA-256 of the data, 64 hex charactersstorage_ref(string, required): The Swarm reference to link: the 64-character hex reference thatupload_datareturnedconfirm(boolean): Set totrue, together withquote_id, to send the transaction. See Safety behaviorquote_id(string): Thequote_idfrom the quote for exactly these arguments (single use, valid for 10 minutes)
Example:
{
"name": "set_storage_ref",
"arguments": {
"data_hash": "a1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789a",
"storage_ref": "b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abc"
}
}
lookup_by_storage_ref (on by default; CHAIN_ENABLED=false turns it off)
Reverse lookup: find the on-chain provenance record by its Swarm reference (the linked storage_ref). Returns the linked data hash and full provenance record if found. Read-only — no gas or wallet key required.
Parameters:
storage_ref(string, required): The Swarm reference to look up, 64 hex characters
Example:
{
"name": "lookup_by_storage_ref",
"arguments": {
"storage_ref": "b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abc"
}
}
Response Format
All tool responses include structured metadata to help agents chain operations efficiently:
Success Responses
Every successful response appends workflow hints:
_next: <recommended_tool> # The logical next tool to call
_related: <tool1>, <tool2> # Other relevant tools
Hints are contextual. For example, list_stamps suggests _next: upload_data when a stamp this server can write to is usable, _next: check_stamp_health when such a stamp is still propagating, and _next: purchase_stamp otherwise. Two cases never suggest a purchase: an unknown or incomplete stamp list gives _next: health_check, and a stamp with an access mode the gateway does not document gives _next: check_stamp_health and names its batch ID. If none of those stamps has a valid batch ID, no ID is named and the result does not recommend a purchase: list_stamps gives _next: health_check and health_check gives _next: list_stamps. If the same answer repeats, stop and report it to the gateway operator.
Error Responses
Error responses include structured recovery information:
retryable: true|false # Whether retrying the same call may succeed
_next: <recovery_tool> # Tool to call for recovery
- retryable: true — transient errors (timeouts, rate limits, 502/503/504). Wait and retry. An answer from the gateway that this server cannot read (not valid JSON, incomplete, or with a corrupt encoding) is also
retryable: truefor read tools. - retryable: false — permanent errors (validation failures, unknown tools). Fix input and try a different approach.
- Outcome unknown: the request reached the gateway, but no usable answer came back, so the write may already have happened. These results are
retryable: false. They cover these cases:purchase_stampandextend_stamp: an answer that cannot be read (not valid JSON, a number too long to convert, nested too deeply, a corrupt content encoding, or an incomplete body), a read timeout, a connection dropped after the request was sent, HTTP 500, 502 or 504, and an answer that is not an object. Forpurchase_stamp, also an answer without a valid batch ID. Do not repeat the write: follow_next(list_stampsorget_stamp_status) to check whether it happened.upload_data: only an answer that cannot be read, or an answer without a valid reference. The reference is unknown. Uploading the same data again normally returns the same reference and uses stamp capacity again; for a signed upload (sign: "notary"), do not upload again, because it creates a second signed document.
- Payment required (HTTP 402) — the gateway has x402 payment enabled and refused a write (
purchase_stamp,upload_data,extend_stamp). The error shows the gateway's payment details (amount, asset, network, recipient) and the options. The details come from the x402 v2PAYMENT-REQUIREDheader when the gateway sends one, else from the response body. When the gateway offers a version other than v1, the error also names the offered versions (for examplex402 versions offered: v1 and v2). This server cannot pay x402 requests yet. The error names the paid alternative for a similar operation, run from start to end outside this server: forpurchase_stampandupload_data, the CLI (swarm-prov-upload --gateway-url <gateway URL> --x402 upload --file <path>, which buys a stamp and uploads) or the SDK (@datafund/swarm-provenance,ProvenanceClientwithgatewayUrlset to<gateway URL>and thepaymentoption; set the payment network to the gateway's network. That option's format differs between SDK releases, so follow the README of the installed version); forextend_stamp, the CLI (swarm-prov-upload --gateway-url <gateway URL> --x402 stamps extend <stamp_id> --duration-hours <hours>; the released CLI 0.12.0 cannot pay for an extension, so install the CLI from its development branch), because the SDK has no method that extends a stamp. Set the CLI's network and wallet as its docs/x402-setup.md says.
Adaptive Health Check
The health_check tool returns additional fields:
ready: true|false # Whether the system is ready for uploads
_recommendations: # Actionable suggestions (only when issues exist)
- No stamps found — purchase one before uploading
_gateway: <url> (connected|unreachable)
The output also has a Swarm network: line: connected (...), DEGRADED (...), or not reported by gateway. When it is DEGRADED, ready is false even if stamps are usable, because uploads may not propagate.
ready is true only when the server has a usable stamp it can write to: a shared stamp, or one without an accessMode (older gateways). pool stamps (gateway inventory) and owned stamps (registered to the wallet that paid for them) are counted separately, because the gateway refuses writes from this server to them. A writable stamp that is not usable yet (still propagating) leads to _next: check_stamp_health, not to a purchase.
Three more cases never lead to a purchase:
- A degraded Swarm network with a usable stamp gives
_next: health_check. Call it again after the gateway operator fixes the Bee node's network connection. - An unknown or incomplete stamp list gives
_next: list_stamps. If the same answer repeats, stop and report it to the gateway operator. - An access mode the gateway does not document, with no usable or pending stamp, gives
_next: check_stamp_health, and the recommendation names the stamp's batch ID. If none of those stamps has a valid batch ID, no ID is named and the result does not recommend a purchase:list_stampsgives_next: health_checkandhealth_checkgives_next: list_stamps. If the same answer repeats, stop and report it to the gateway operator.
Safety behavior
These behaviors apply to the chain tools that are listed: the read-only ones by default, all of them with CHAIN_ENABLED=true. The spending rules apply to the write tools, which only CHAIN_ENABLED=true lists.
Confirmed quotes for spending tools
anchor_hash, record_transform, record_merge_transform and set_storage_ref accept confirm and quote_id. A confirmed quote is required on mainnet (any chain ID other than 84532, 11155111, 31337 or 1337), or on any chain when CHAIN_REQUIRE_CONFIRM=true. CHAIN_REQUIRE_CONFIRM=false turns it off. On the testnet default it is off. When confirmation is off, there is no quote step: confirm and quote_id are ignored and an ordinary call sends the transaction directly.
When confirmation is required:
- Call the tool with its normal arguments. The server sends no transaction and returns a quote: the action, the number of transactions, the fee cap, the current fee, the remaining session budget, and a
quote_id. - Get the user's approval.
- Call the tool again with the same arguments,
confirm: true, and thequote_id.
A quote_id is valid for 10 minutes, works once, and works only for the tool and arguments it was issued for. Hash and address values are compared without regard to letter case. It is valid only in the server process that issued it, so a restart invalidates it. If confirm is true but the quote_id is missing, expired, used or for different arguments, the server sends nothing and returns a new quote. This no-send behavior applies only when confirmation is required.
Untrusted content
Text that anyone can write is treated as data, not instructions: download_data content, stamp labels, and on-chain data types and transformation descriptions. Multi-line content, such as a download, is placed in a fenced block with a warning, escaped, and capped at 16 KB. Single-line fields are quoted and capped at 200 characters. Lines in this content that look like server hints are marked as quoted. On-chain lists (transformations, accessors) show at most 50 entries.
RPC address redaction
An RPC URL can carry an API key in its path or query. Chain tool results show the configured RPC URLs as scheme, host and port only. In server logs, RPC URLs in error text are cut the same way: credentials, path and query are removed and scheme, host and port are kept. Connection labels in log messages show the host only. The gateway URL appears in the start-up log and in health_check without credentials, query or fragment. Request errors never include the gateway URL's credentials, query or fragment. Faucet and explorer links are not changed.
Chain ID pinning
For CHAIN_NAME=base-sepolia and CHAIN_NAME=base, the chain ID is fixed by the preset and never taken from the RPC. At start-up the server checks the primary RPC. If it reports another chain, the server refuses to start. Your MCP client may then show only a generic message such as "server disconnected"; the reason is in the server's stderr log. Each endpoint, including each CHAIN_RPC_URLS fallback, is also checked before its first read, and a write checks the chain ID again before signing. If every fallback is on the wrong chain, the tool returns a chain ID mismatch error. Only CHAIN_NAME=localhost with a custom RPC detects the chain ID from the RPC. Fix CHAIN_RPC_URL, CHAIN_RPC_URLS or CHAIN_NAME so they match.
Contract check
Before the first write, the server checks that CHAIN_CONTRACT (or the preset address) holds DataProvenance contract code. If every endpoint that answers reports no code, the write tools are disabled and report the reason, health_check and chain_health report it too, and the server checks again before each write. Read-only tools are not disabled by this write check and can still be called. They use the same configured contract, so they can return their own RPC or contract-read errors. If no RPC answers in time, the check runs again before the first transaction.
MCP Prompts
The server provides workflow prompts that agents can invoke via prompts/list and prompts/get. These give step-by-step instructions for common tasks:
| Prompt | Description | Arguments |
|---|---|---|
provenance-upload |
Upload data to Swarm: health check, stamp selection, upload, download to confirm | data (required), content_type (optional) |
provenance-verify |
Download existing data by reference, inspect it, and report what the reference check covered | reference (required) |
stamp-management |
Review stamp inventory, diagnose issues, recommend actions | none |
provenance-chain-workflow |
End-to-end on-chain provenance: store, anchor, and optionally record a transformation | data (required), transform_description (optional) |
MCP Resources
The server exposes on-demand knowledge resources that agents can load via resources/list and resources/read:
| Resource URI | MIME Type | Description |
|---|---|---|
provenance://skills |
text/markdown |
Provenance skills guide — concepts, critical rules, workflows, diagrams, and error recovery |
Docker
Building
docker build -t swarm-provenance-mcp .
To tag with a specific version:
docker build --build-arg VERSION=0.3.2 -t swarm-provenance-mcp:0.3.2 .
Running
The server communicates via stdio (no ports). Pass -i for interactive stdin:
docker run -i --rm swarm-provenance-mcp
Configure the gateway URL and other settings via environment variables:
docker run -i --rm \
-e SWARM_GATEWAY_URL=https://provenance-gateway.datafund.io \
-e DEFAULT_STAMP_SIZE=medium \
swarm-provenance-mcp
Claude Desktop with Docker
Add to your claude_desktop_config.json:
{
"mcpServers": {
"swarm-provenance": {
"command": "docker",
"args": ["run", "-i", "--rm", "swarm-provenance-mcp"]
}
}
}
Architecture
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI Agents │◄──►│ MCP Server │◄──►│ swarm_connect │
│ │ │ │ │ Gateway │
│ • Claude │ │ • Tool handlers │ │ │
│ • Other LLMs │ │ • Gateway client│ │ • Purchase API │
│ • Custom agents │ │ • Chain client │ │ • Status API │
└─────────────────┘ │ • Error handling│ │ • Extension API │
└────────┬────────┘ └─────────┬───────┘
│ │
┌────────▼────────┐ ┌─────────▼───────┐
│ Base Sepolia │ │ Swarm Network │
│ (DataProv. │ │ (Bee Node) │
│ Contract) │ └─────────────────┘
└─────────────────┘
Components
- MCP Server: Exposes tools via the Model Context Protocol
- Gateway Client: HTTP client for communicating with swarm_connect
- Chain Client (optional): On-chain provenance via DataProvenance smart contract on Base Sepolia
- Configuration: Environment-based settings management
- Error Handling: Comprehensive error handling and logging
Claude Desktop Integration
Setup Instructions
-
Install Claude Desktop: Download from claude.ai
-
Clone and set up this repository:
# Clone the repository
git clone https://github.com/datafund/swarm_provenance_MCP.git
# Navigate to the project directory
cd swarm_provenance_MCP
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install the package in development mode
pip install -e .
# Configure environment variables
mkdir -p ~/.config/swarm-provenance-mcp
cp .env.example ~/.config/swarm-provenance-mcp/.env
# Edit that file if you need to customize gateway URL or defaults
- Configure MCP Server: Add to Claude Desktop's configuration file:
macOS (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"swarm-provenance": {
"command": "/path/to/swarm_provenance_MCP/run.sh"
}
}
}
Linux: the macOS path above does not exist on Linux. Use the same command in the configuration file of your MCP client.
Windows (%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"swarm-provenance": {
"command": "C:\\path\\to\\swarm_provenance_MCP\\venv\\Scripts\\python.exe",
"args": ["-m", "swarm_provenance_mcp.server"]
}
}
}
Note: Replace /path/to/swarm_provenance_MCP with the actual path where you cloned the repository.
The run.sh launcher (macOS/Linux) starts the server from the repo's venv, with the repo as working directory. The working directory does not affect configuration: settings come from the env file described above, and a .env in the repository is no longer read (see Upgrading from a .env in the repository; the server logs a warning if it finds one). If the venv stops working — typically after moving or renaming the repo directory — it rebuilds it automatically. Make it executable once with chmod +x run.sh.
The rebuild installs all dependencies and can take a few minutes, longer than an MCP client waits for the server on startup. If the first launch after a move times out, run ./run.sh < /dev/null once in a terminal to finish the rebuild, then restart the client. The Windows config above does not use the launcher yet; after moving the repo on Windows, recreate the venv manually.
Alternative (if package is installed): You can use "command": "swarm-provenance-mcp" instead after running pip install -e .
With on-chain provenance
The read-only chain tools are on without any setting. To enable blockchain anchoring (the write tools), add an "env" block to the config. You can use this instead of (or alongside) the env file at ~/.config/swarm-provenance-mcp/.env:
{
"mcpServers": {
"swarm-provenance": {
"command": "/path/to/swarm_provenance_MCP/run.sh",
"env": {
"CHAIN_ENABLED": "true",
"PROVENANCE_WALLET_KEY": "0x...your_private_key_here..."
}
}
}
}
Read-only chain tools (verify_hash, get_provenance, get_provenance_chain, lookup_by_storage_ref, chain_health) are on by default and work without PROVENANCE_WALLET_KEY. Write tools (anchor_hash, record_transform, record_merge_transform, set_storage_ref) and chain_balance require a funded wallet — see Chain Anchoring for details.
Docker-based
Use Docker for a zero-install experience — no Python, venv, or pip required:
{
"mcpServers": {
"swarm-provenance": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "SWARM_GATEWAY_URL=https://provenance-gateway.datafund.io",
"ghcr.io/datafund/swarm-provenance-mcp"
]
}
}
}
The read-only chain tools are on in the image too. To enable chain anchoring (the write tools) with Docker, add the chain env vars:
{
"mcpServers": {
"swarm-provenance": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "SWARM_GATEWAY_URL=https://provenance-gateway.datafund.io",
"-e", "CHAIN_ENABLED=true",
"-e", "PROVENANCE_WALLET_KEY=0x...your_private_key_here...",
"ghcr.io/datafund/swarm-provenance-mcp"
]
}
}
}
Docker Desktop MCP Toolkit: If you use Docker Desktop with MCP Toolkit support, the server can be discovered automatically from the Docker MCP catalog.
- Restart Claude Desktop and verify the connection.
Getting Started
After setup, try these prompts in Claude Desktop to verify everything works:
Check connectivity:
"Run a health check on the Swarm gateway"
Expected: a status showing healthy, gateway URL, and response time. If chain is enabled, you'll also see RPC connectivity and wallet balance info.
List stamps:
"List all available Swarm stamps"
Expected: the usable postage stamps with the most time left and a count line, or a message that no stamps exist yet (with a suggestion to purchase one).
Full upload workflow:
"Upload the text 'Hello Swarm!' to the Swarm network"
Claude will walk through: finding a usable stamp (or, with your approval, purchasing one and waiting for it to propagate), uploading the data, and returning the Swarm reference.
Verify on-chain (if chain enabled):
"Anchor the uploaded hash on-chain and verify it"
Claude will register the hash on the blockchain and confirm the provenance record.
Troubleshooting Setup
If Claude Desktop doesn't show the Swarm tools:
- Check the config file path is correct for your OS
- Verify the
commandpath points torun.shin your clone (macOS/Linux), or to the Python executable inside your venv (Windows) - Check Claude Desktop logs: Help > Show Logs (look for MCP connection errors)
- Test manually: run
./run.sh(orswarm-provenance-mcp) in your terminal — it should start without errors and wait for MCP input. Launcher messages, including a venv rebuild, go to stderr
Development
Testing
# Install development dependencies
pip install -e .[dev]
# Run tests
pytest
# Run with coverage
pytest --cov=swarm_provenance_mcp
Docker Testing
Requires Docker daemon to be running:
# Run all Docker tests (builds image, tests MCP protocol, tool calls)
pytest tests/test_docker.py -v -m docker
# Verify manually
docker build -t swarm-provenance-mcp .
docker run -i --rm swarm-provenance-mcp # starts, waits for MCP input
docker run -i --rm -e SWARM_GATEWAY_URL=https://provenance-gateway.datafund.io swarm-provenance-mcp # env override
Code Quality
# Format code
black swarm_provenance_mcp/
# Lint code
ruff check swarm_provenance_mcp/
Editor settings
The repository commits no editor hooks, MCP servers or auto-approve settings. Shared editor settings take effect on every contributor's machine, so keep your own in per-developer configuration:
.claude/settings.local.jsonfor project hooks and permissions. It is gitignored, and so is any.claude/*.local.json.~/.claude/settings.jsonfor settings that apply to all your projects.claude mcp add --scope localor--scope userfor MCP servers, instead of a committed.mcp.json.
These files count as committed editor settings: .claude/**/*.json except *.local.json, .mcp.json, .cursor/mcp.json and .cursor/hooks.json. They must not contain:
- A
hooks,mcpServers,statusLineorapiKeyHelperkey. Each one runs a command or connects to an MCP server. - A non-empty
permissions.allow. - An
enableAllProjectMcpServersorenabledMcpjsonServerskey. - A
permissions.defaultModeother than"default".
tests/test_editor_settings.py enforces these rules.
Dependencies
-
Core Dependencies:
mcp>=1.26,<2: Model Context Protocol framework (the server is written for mcp 1.x)requests>=2.31.0,<3: HTTP client for gateway communicationpydantic>=2.0.0,<3andpydantic-settings>=2.0,<3: Data validation and settingspython-dotenv>=1.0.0,<2: Environment configurationweb3>=7,<8: Ethereum blockchain interaction for on-chain provenanceeth-account>=0.13,<0.14: Wallet and transaction signing for chain anchoringeth-utils>=5,<6: Hashing helpers (keccak) used directly by the chain module
Upper bounds are deliberate. Raise one only together with a passing test run against the new version.
-
Development Dependencies:
pytest: Testing frameworkpytest-asyncio: Async testing supportpytest-mock: Mocking utilitiesblack: Code formattingruff: Linting
Integration with AI Agents
This MCP server is designed to work with AI agents that support the Model Context Protocol. Agents can use the provided tools to:
- Manage stamp inventory: Purchase and extend stamps as needed
- Monitor usage: Check stamp status and utilization
- Optimize costs: List stamps to find the most suitable ones for tasks
- Store provenance data: Upload data with provenance metadata to immutable decentralized storage
- Retrieve records: Download records from the Swarm network by reference. Content up to 4 KB is checked against a reference that names a single chunk; see the
download_datareference check - Data lifecycle management: Handle complete provenance workflows from creation to retrieval and on-chain checks
- Track data lineage: Record transformations and trace the full provenance chain of derived data
- Automate workflows: Integrate stamp management and data storage into larger AI workflows
Troubleshooting
Common Issues
- Connection errors: Ensure the swarm_connect gateway is running and accessible
- Authentication errors: Check that the gateway doesn't require authentication
- Invalid stamp IDs: Verify stamp IDs are valid batch IDs from the Swarm network
- Timeout errors: Increase timeout values if operations are taking too long
- Chain: "wallet key not configured": Set
PROVENANCE_WALLET_KEYin the MCP client's"env"block or in the env file (~/.config/swarm-provenance-mcp/.env, see Configuration) for write operations (anchor_hash,record_transform,set_storage_ref). Read-only tools work without it. If the error says the key is not a valid private key, fix the value (64 hexadecimal characters, with or without 0x) and restart the server. - Chain: "insufficient funds": Fund your wallet with testnet ETH (Base Sepolia faucet) or bridge ETH to Base mainnet. Run
chain_balancefor guidance. - Chain: "already registered": The hash is already anchored on-chain. If the result is an error, another address owns the record. Registration is first-come, so to anchor a record you own, change the content, upload it again, and anchor the new hash. Use
get_provenanceto view the existing record. - Chain: "transformation already recorded": The
(original → new)link already exists on-chain. No gas spent — useget_provenance_chainto verify the lineage. - Chain: "too few/many sources":
record_merge_transformrequires 2–50 source hashes. Adjust thesource_hashesarray accordingly.
Logging
The server logs important events and errors. To increase logging verbosity:
import logging
logging.getLogger("swarm_provenance_mcp").setLevel(logging.DEBUG)
License
MIT License - see LICENSE file for details.
Metadata
Release files for swarm-provenance-mcp 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarm_provenance_mcp-0.3.2.tar.gz | 200.4 kB | With provenance | Details for swarm_provenance_mcp-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarm_provenance_mcp-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for swarm_provenance_mcp-0.3.2-py3-none-any.whl |
Total release size: 367.5 kB
Release files / swarm_provenance_mcp-0.3.2.tar.gz
| Download URL | swarm_provenance_mcp-0.3.2.tar.gz |
|---|---|
| Size | 200.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
460cb944243e3a757d0f8cb2729ad39c418875f7e1dd2717c1b528ef14fd0108
|
|
BLAKE2b-256 checksum How to use checksums |
b2131774e559ceaa5232ea19ced3f623f97e91a3f9526c14e9da93b4c89d85bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logRelease files / swarm_provenance_mcp-0.3.2-py3-none-any.whl
| Download URL | swarm_provenance_mcp-0.3.2-py3-none-any.whl |
|---|---|
| Size | 167.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a0c1d70ef85571ad6a0eea1a045d7e5e843b06a15281b8848064ab7b810977c
|
|
BLAKE2b-256 checksum How to use checksums |
2465d864be22c37d47e80d6682e27cd194edb69be7c2c489951572d7b32dc119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logSecurity for swarm-provenance-mcp 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for swarm_provenance_mcp-0.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.