Disclaimer: This implementation is a proof-of-concept only, should not be used in production.
A Model Context Protocol (MCP) server implementation that uses Ethereum Swarm's Bee API for storing and retrieving data.
This server implements the Model Context Protocol (MCP), a standard protocol for connecting AI systems with external tools and data sources. The Swarm MCP server provides tools to upload and download text data, storing this data on the Swarm decentralized storage network using the Bee API.
- Upload text data to Swarm through the MCP protocol
- Download text data from Swarm through the MCP protocol
- Standard MCP server interface using stdio transport
- Configurable Bee API endpoints and postage batch IDs
The server provides the following MCP tools:
Uploads text data to the Swarm network.
Parameters:
data
: String data to uploadredundancyLevel
: (Optional) Redundancy level for fault tolerance (0-4, default: 0)- 0: none
- 1: medium
- 2: strong
- 3: insane
- 4: paranoid
memoryTopic
: (Optional) If provided, uploads the data to a Swarm Feed with this topic (requiresBEE_FEED_PK
in config)
Returns:
reference
: Swarm reference hash for the uploaded data or feedurl
: URL to access the data via Bee APImessage
: Status messagetopicString
,topic
,feedUrl
: (If usingmemoryTopic
) Feed details
Retrieves text data from the Swarm network. Should be used when the data is known to be text format.
Parameters:
reference
: Swarm reference hash or feed topicisMemoryTopic
: (Optional, boolean) Set true to retrieve from a Swarm feedowner
: (Optional) Ethereum address of the feed owner
Returns:
- Retrieved text data
Uploads a file to the Swarm network.
Parameters:
data
: Base64 encoded file content or file pathisPath
: (Optional) Whether the data parameter is a file path (default: false)redundancyLevel
: (Optional) Redundancy level for fault tolerance (0-4, default: 0)
Returns:
reference
: Swarm reference hash for the uploaded fileurl
: URL to access the file via Bee APImessage
: Status message
Uploads a folder to the Swarm network.
Parameters:
folderPath
: Path to the folder to uploadredundancyLevel
: (Optional) Redundancy level for fault tolerance (0-4, default: 0)
Returns:
reference
: Swarm reference hash for the uploaded folderurl
: URL to access the folder via Bee APImessage
: Status message
Downloads folder, files, or binary data from a Swarm reference. This tool should be prioritized over download_text
if there is no assumption about the data type.
Parameters:
reference
: Swarm reference hashfilePath
: (Optional) File path to save the downloaded content (only available in stdio mode)
Returns:
- If
filePath
is not provided: List of files in the manifest - If
filePath
is provided: Content saved to specified location
- Node.js 18+ installed
- npm
- A running Bee node or access to a public Bee gateway
- A valid postage batch ID (for production use)
- Clone this repository
- Install dependencies:
npm ci
The server configuration is located in src/config.ts
:
You can customize:
- Bee API endpoint: Set to any Swarm Bee node or gateway
- Postage Batch ID: Required for uploading data to Swarm (the default ID is a placeholder for testing)
Modify these values as needed for your environment.
Run the server with hot reloading for development:
npm run dev
Run the server directly with ts-node:
npm run serve
Build and run optimized production version:
npm run build
npm start
The Swarm MCP server communicates via standard input/output (stdio) following the MCP protocol. To use it with MCP clients:
- Start the server
- Connect your MCP-compatible client to the server
- Use the provided MCP tools (
upload_text
,download_text
,upload_file
,upload_folder
,download_folder
)