🪐 Mcp Ipfs 伺服器 (storacha.network) 🛰️
概覽
什麼是 MCP IPFS?
MCP IPFS(星際文件系統)是一種去中心化的存儲協議,旨在使網絡更快、更安全和更開放。它允許用戶以分散的方式存儲和共享文件,確保數據不依賴於單一的伺服器或位置。通過利用點對點網絡,MCP IPFS 增強了數據的可用性和對審查的抵抗力。
MCP IPFS 的特點
- 去中心化:與傳統的文件存儲系統不同,MCP IPFS 不依賴於中央伺服器。這降低了數據丟失和審查的風險。
- 內容尋址:文件是通過其內容而不是位置來識別的。這意味著即使文件被移動,仍然可以使用其唯一標識符訪問。
- 版本控制:MCP IPFS 支持版本控制,允許用戶輕鬆跟踪更改並恢復到先前版本的文件。
- 高效數據分發:該協議通過同時從多個來源獲取文件來優化數據傳輸,提高下載速度。
- 互操作性:MCP IPFS 可以與各種應用程序和平台集成,使其在不同用例中具有多功能性。
如何使用 MCP IPFS
- 安裝:首先在您的設備上安裝 MCP IPFS 軟件。這通常可以通過包管理器或從官方網站下載二進制文件來完成。
- 初始化:安裝後,使用命令行界面初始化您的 IPFS 節點。這會設置您的本地存儲庫並將您連接到 IPFS 網絡。
- 添加文件:使用命令
ipfs add <file>
將文件上傳到 IPFS 網絡。這會為每個文件生成一個唯一的哈希值,稍後可以用來檢索它。 - 檢索文件:要訪問文件,使用命令
ipfs cat <hash>
,將<hash>
替換為文件的唯一標識符。 - 分享文件:將生成的哈希值與他人分享,允許他們直接從 IPFS 網絡訪問該文件。
常見問題
問:使用 MCP IPFS 相對於傳統文件存儲的好處是什麼?
答:MCP IPFS 提供了增強的安全性、更快的數據檢索和更強的抵抗數據丟失和審查的能力,這得益於其去中心化的特性。
問:MCP IPFS 適合大型文件嗎?
答:是的,MCP IPFS 設計上能有效處理大型文件,通過將其分割成較小的塊並在網絡中分發。
問:我可以使用 MCP IPFS 存儲私密數據嗎?
答:雖然 MCP IPFS 主要是一個公共網絡,但您可以在上傳之前對文件進行加密以確保隱私。
問:MCP IPFS 如何處理數據冗餘?
答:數據冗餘是通過其去中心化架構實現的,許多節點可以存儲同一文件的副本,即使某些節點離線也能確保可用性。
問:使用 MCP IPFS 是否需要費用?
答:使用 MCP IPFS 是免費的,但如果您選擇運行自己的節點或使用第三方服務進行託管,可能會產生與基礎設施相關的費用。
詳細
🪐 MCP IPFS Server (storacha.network) 🛰️
A Node.js server implementing the Model Context Protocol (MCP) for interacting with the storacha.network platform via the w3
command-line interface (@web3-storage/w3cli
).
This server empowers language models 🤖 and other MCP clients to manage storacha.network spaces, upload/download data, manage delegations, and perform various other tasks by seamlessly wrapping w3
commands.
✨ Features
- Wraps the
w3
CLI for native integration with storacha.network. - Provides MCP tools covering a wide range of
w3
functionality:- 🔑 Authentication & Agent:
w3_login
,w3_reset
,w3_account_ls
(for checking authorization) - 📦 Space Management:
w3_space_ls
,w3_space_use
,w3_space_info
,w3_space_add
,w3_space_provision
(Note:w3_space_create
must be run manually due to interactive prompts) - 💾 Data Management:
w3_up
,w3_ls
,w3_rm
- 🔗 Sharing:
w3_open
(generates w3s.link URL) - 🤝 Delegations & Proofs:
w3_delegation_create
,w3_delegation_ls
,w3_delegation_revoke
,w3_proof_add
,w3_proof_ls
- 🔐 Keys & Tokens:
w3_key_create
,w3_bridge_generate_tokens
- ⚙️ Advanced Storage (
w3 can ...
): Blob, CAR, Upload, Index, Access Claim, Filecoin Info management - 💳 Account & Billing:
w3_plan_get
,w3_coupon_create
,w3_usage_report
- 🔑 Authentication & Agent:
🛠️ Prerequisites
- Node.js: Version 22.0.0 or higher (
node -v
). w3
CLI: The server executesw3
commands directly. Ensure@web3-storage/w3cli
is installed globally and configured:npm install -g @web3-storage/w3cli w3 login <your-email@example.com> # Follow email verification steps
- Environment Variable: The
w3_login
tool requires theW3_LOGIN_EMAIL
environment variable to be set to the same email used forw3 login
.
🏗️ Project Structure
The codebase is organized as follows:
src/
├── index.ts # Main server entry point, MCP setup, request routing
├── schemas.ts # Zod schemas defining input arguments for each tool
├── tool_handlers.ts # Implementation logic for each MCP tool
├── utils.ts # Helper functions (e.g., running w3 commands, parsing JSON)
└── utils/
└── logger.ts # Basic logger configuration
🚀 Usage with MCP Clients
This server can be used with any MCP-compatible client. You need to configure your client to connect to this server.
Example: NPX (Recommended for simple local use)
This assumes npm
and the prerequisites are met.
{
"mcpServers": {
"ipfs": {
"command": "npx",
"args": ["-y", "mcp-ipfs"],
"env": {
"W3_LOGIN_EMAIL": "your-email@example.com"
}
}
}
}
Example: Docker
Build the image first (see Build section) or use the pre-built image alexbakers/mcp-ipfs
.
{
"mcpServers": {
"mcp-ipfs": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/path/to/your/project:/path/to/your/project",
"-e",
"W3_LOGIN_EMAIL",
"alexbakers/mcp-ipfs"
],
"env": {
"W3_LOGIN_EMAIL": "your-email@example.com"
}
}
}
}
📝 Note on Paths:
Several w3
commands require absolute filesystem paths (e.g., w3_up
, w3_delegation_create --output
, w3_proof_add
, w3_can_blob_add
, w3_can_store_add
).
- NPX: Provide absolute paths from your host machine.
- Docker: Provide absolute paths inside the container. If interacting with files from your host (e.g., uploading), you must mount the relevant host directory into the container using the
-v
flag (e.g.,-v /Users/me/project:/Users/me/project
) and then use the container path (e.g.,/Users/me/project/my_file.txt
) in the tool arguments.
📦 Build
Clone the repository and install dependencies:
git clone https://github.com/alexbakers/mcp-ipfs.git
cd mcp-ipfs
npm install
Build the TypeScript code:
npm run build
You can then run the server directly:
### Ensure W3_LOGIN_EMAIL is set in your environment
export W3_LOGIN_EMAIL="your-email@example.com"
node dist/index.js
Or publish it (if you have the rights):
npm publish
🐳 Docker Build
Build the Docker image:
### Build locally (replace with your username/repo and desired tag)
docker build -t alexbakers/mcp-ipfs .
📜 License
This MCP server is licensed under the MIT License. See the LICENSE file for details.
伺服器配置
{
"mcpServers": {
"mcp-ipfs": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--alexbakers--mcp-ipfs--mcp-ipfs",
"npm run start"
],
"env": {}
}
}
}