Walrus MCP Server 是为 Walrus 去中心化存储协议打造的 MCP 服务器,它能实现去中心化存储操作,与区块链集成,为开发者提供便捷的工具和良好的开发体验,有效连接 AI 助手和 Walrus 去中心化存储网络。
git clone https://github.com/MotionEcosystem/walrus-mcp.git
cd walrus-mcp
npm install
npm run build
将以下内容添加到你的 Claude Desktop 配置中:
{
"mcpServers": {
"walrus": {
"command": "node",
"args": ["path/to/walrus-mcp/dist/index.js"],
"env": {
"WALRUS_AGGREGATOR_URL": "https://aggregator-devnet.walrus.space",
"WALRUS_PUBLISHER_URL": "https://publisher-devnet.walrus.space"
}
}
}
}
// 存储文本数据
await tool_call("store_blob", {
data: "SGVsbG8sIFdhbHJ1cyE=", // Base64 编码的 "Hello, Walrus!"
epochs: 10
})
// 存储文件
await tool_call("store_blob", {
data: "/path/to/file.jpg",
epochs: 5
})
// 获取数据块内容(Base64 格式)
const blob = await tool_call("get_blob", {
blobId: "0xabc123..."
})
// 获取数据块元数据
const info = await tool_call("get_blob_info", {
blobId: "0xabc123..."
})
console.log(info.size, info.certified, info.endEpoch)
// 获取 Walrus 网络健康状态
const status = await resource_read("walrus://status")
console.log(status.epoch, status.networkSize)
// 获取当前客户端配置
const config = await resource_read("walrus://config")
console.log(config.aggregatorUrl, config.publisherUrl)
git clone https://github.com/MotionEcosystem/walrus-mcp.git
cd walrus-mcp
npm install
npm run build
基于 .env.example 创建 .env 文件:
# 必需:Walrus 网络端点
WALRUS_AGGREGATOR_URL=https://aggregator-devnet.walrus.space
WALRUS_PUBLISHER_URL=https://publisher-devnet.walrus.space
# 可选:自定义系统对象 ID
WALRUS_SYSTEM_OBJECT=0x37c0e4d7b36a2f64d51bba262a1791f844cfd88f19c35b5ca709e1a6991e90dc
# 可选:用于交易签名的钱包
WALRUS_WALLET_PATH=/path/to/your/wallet.json
// 存储文本数据
await tool_call("store_blob", {
data: "SGVsbG8sIFdhbHJ1cyE=", // Base64 编码的 "Hello, Walrus!"
epochs: 10
})
// 存储文件
await tool_call("store_blob", {
data: "/path/to/file.jpg",
epochs: 5
})
// 获取数据块内容(Base64 格式)
const blob = await tool_call("get_blob", {
blobId: "0xabc123..."
})
// 获取数据块元数据
const info = await tool_call("get_blob_info", {
blobId: "0xabc123..."
})
console.log(info.size, info.certified, info.endEpoch)
// 获取 Walrus 网络健康状态
const status = await resource_read("walrus://status")
console.log(status.epoch, status.networkSize)
// 获取当前客户端配置
const config = await resource_read("walrus://config")
console.log(config.aggregatorUrl, config.publisherUrl)
服务器针对常见场景提供了全面的错误处理:
所有检索到的数据块均以 Base64 编码字符串形式返回,以确保不同数据类型的一致处理。
⚠️ 重要提示
- 所有存储在 Walrus 中的数据块都是公开且可被发现的。
- 未加密时请勿存储敏感或机密信息。
- 对于私有数据,可考虑使用客户端加密。
- 处理前请验证所有输入。
https://aggregator-devnet.walrus.spacehttps://publisher-devnet.walrus.space0x37c0e4d7b36a2f64d51bba262a1791f844cfd88f19c35b5ca709e1a6991e90dc若要使用测试网络,请更新环境变量:
WALRUS_AGGREGATOR_URL=https://aggregator-testnet.walrus.space
WALRUS_PUBLISHER_URL=https://publisher-testnet.walrus.space
启用详细日志记录:
DEBUG=walrus-mcp:* npm run dev
我们欢迎贡献!请按以下步骤操作:
| 脚本 | 描述 |
|---|---|
npm run dev |
启动开发服务器 |
npm run build |
构建生产版本 |
npm run start |
启动生产服务器 |
npm run lint |
运行 ESLint |
npm run type-check |
运行 TypeScript 类型检查 |
npm run format |
使用 Prettier 格式化代码 |
Walrus MCP Server 通过模型上下文协议(MCP)在 AI 助手和 Walrus 去中心化存储网络之间搭建桥梁。
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ AI Assistant │ │ Walrus MCP │ │ Walrus Network │
│ (Claude, etc.) │◄──►│ Server │◄──►│ (DevNet) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Sui Blockchain │
│ (Metadata) │
└─────────────────┘
本项目采用 MIT 许可证,详情请参阅 LICENSE 文件。