MCP服务器
1.什么是MCP(模型上下文协议)?
模型上下文协议(MCP)是模型、代理和上下文数据之间交互的标准。它由社区开发和维护。更多详细信息可以在官方存储库中找到: .
2.什么是IPFS?
星际文件系统(IPFS) 是一个分布式文件系统,可以实现分散的数据存储和共享。它用于MCP中存储数据和与数据交互,确保可靠性和容错性。
3.MCP服务器架构概述
组件:
- MCP节点 --处理MCP请求的核心服务器组件。
- IPFS --用于处理内容的分散存储系统。
- 客户端 --与MCP服务器交互以发送和接收数据。
- 克劳德 AI --用于处理和增强MCP相互作用。
组件交互:
- 客户端向MCP节点发送请求。
- MCP节点处理请求,并在必要时与IPFS交互。
- Claude AI协助处理和优化响应。
- 响应将返回给客户端。
4.部署MCP服务器
要求:
- Node.js(推荐18+版本)
- NPM或纱线
安装
安装将取决于您使用的是Claude Code还是Claude Desktop
克劳德代码
跑 claude mcp add 并按照提示提供以下信息:
Server Name: mcp-ipfs
Server Command: node
Command Arguments: node /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-ipfs-server/build/index.js克劳德桌面
将以下配置添加到 claude_desktop_config.json
{
"mcpServers": {
"ipfs-mcp": {
"command": "node",
"args": [
"/Absolute/path/to/mcp-ipfs-server/build/index.js"
]
}
}
}自动化安装和部署
使用以下bash脚本自动部署服务器:
#!/bin/bash
sudo apt update
sudo apt install -y wget tar git npm
wget https://github.com/ipfs/kubo/releases/download/v0.34.1/kubo_v0.34.1_linux-amd64.tar.gz
tar -xvzf kubo_v0.34.1_linux-amd64.tar.gz
cd kubo
sudo bash install.sh
ipfs init
sudo apt install ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 4001/tcp
sudo ufw allow 8080/tcp
sudo ufw allow 22/tcp
sudo ufw allow 5001/tcp
sudo ufw enable
sudo ufw status
# Clone the MCP server repository
git clone https://github.com/AleksanStark/mcp-ipfs-server.git
cd mcp-ipfs-server
# Install dependencies
npm install
npm install @modelcontextprotocol/sdk zod
npm install -D @types/node typescript
# Build the project
npm run build
ipfs daemon用法
要开始使用MCP,请使用以下命令启动Claude Code claude 或启动克劳德桌面。以下是可用的操作:
文件操作
- 上传文件 IPFS
- 获取文件 CID
- pin文件 CID
- 列表文件夹 按CID获取目录列表
- 取消固定文件- CID
克劳德提示示例
以下是一些如何指导Claude使用ipfs-mcp的示例:
Upload an image to IPFS:
"Please upload the file at ~/Pictures/example.jpg to my Pinata account as a private file named 'My Example Image'"
Get a file from IPFS:
"Get the file from IPFS using the CID""
Pin a file to IPFS:
"Pin the file by it's CID"
Unpin a file to IPFS:
"Unpin the file based on the CID"问题
发送给我们 电子邮件 您可能会遇到任何问题!
