🚀 Curl的MCP服務器
Curl的MCP服務器提供了curl功能,允許AI助手直接在其環境中發起HTTP請求。

✨ 主要特性
- HTTP方法:支持GET、POST、PUT、DELETE請求。
- 文件下載:使用curl下載文件。
- 高級選項:支持自定義頭部、超時設置、重定向等。
- JSON支持:內置對POST/PUT請求的JSON數據處理。
- 用戶代理:支持自定義User - Agent字符串。
- 安全性:通過輸入驗證實現安全的子進程執行。
📦 安裝指南
方法一:NPM安裝(推薦)
npm install -g @247arjun/mcp-curl
npm install @247arjun/mcp-curl
方法二:從源代碼安裝
git clone https://github.com/247arjun/mcp-curl.git
cd mcp-curl
npm install
npm run build
npm link
方法三:直接從GitHub安裝
npm install -g git+https://github.com/247arjun/mcp-curl.git
🚀 快速開始
Claude桌面設置
將以下內容添加到Claude桌面配置文件中:
位置:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:
%APPDATA%/Claude/claude_desktop_config.json
配置:
{
"mcpServers": {
"mcp-curl": {
"command": "mcp-curl",
"args": []
}
}
}
替代方法:使用npx(無需全局安裝)
{
"mcpServers": {
"mcp-curl": {
"command": "npx",
"args": ["@247arjun/mcp-curl"]
}
}
}
本地開發設置
{
"mcpServers": {
"mcp-curl": {
"command": "node",
"args": ["/absolute/path/to/mcp-curl/build/index.js"]
}
}
}
添加配置後,重啟Claude桌面以加載MCP服務器。
💻 使用示例
發起GET請求
{
"tool": "curl_get",
"url": "https://api.example.com/users",
"headers": ["Authorization: Bearer your-token"]
}
POST JSON數據
{
"tool": "curl_post",
"url": "https://api.example.com/users",
"json_data": {
"name": "John Doe",
"email": "john@example.com"
}
}
下載文件
{
"tool": "curl_download",
"url": "https://example.com/file.zip",
"output_filename": "download.zip"
}
📚 詳細文檔
可用工具
1. curl_get
發起HTTP GET請求。
參數:
url
(字符串):發起GET請求的URL。
headers
(數組,可選):格式為'Header: Value'的HTTP頭部。
timeout
(數字,可選):請求超時時間(秒)。
follow_redirects
(布爾值,可選):是否跟隨重定向。
user_agent
(字符串,可選):自定義User - Agent字符串。
示例:
{
"url": "https://api.example.com/data",
"headers": ["Authorization: Bearer token"],
"timeout": 30,
"follow_redirects": true,
"user_agent": "MyApp/1.0"
}
2. curl_post
發起帶有數據的HTTP POST請求。
參數:
url
(字符串):發起POST請求的URL。
json_data
(對象,可選):作為POST數據發送的JSON對象。
data
(字符串,可選):POST請求體中發送的數據。
headers
(數組,可選):HTTP頭部。
content_type
(字符串,可選):Content - Type頭部。
timeout
(數字,可選):請求超時時間(秒)。
follow_redirects
(布爾值,可選):是否跟隨重定向。
示例:
{
"url": "https://api.example.com/data",
"json_data": {"key": "value"},
"headers": ["Content-Type: application/json"]
}
3. curl_put
發起HTTP PUT請求。
參數:
url
(字符串):發起PUT請求的URL。
json_data
(對象,可選):作為PUT數據發送的JSON對象。
data
(字符串,可選):PUT請求體中發送的數據。
headers
(數組,可選):HTTP頭部。
content_type
(字符串,可選):Content - Type頭部。
timeout
(數字,可選):請求超時時間(秒)。
follow_redirects
(布爾值,可選):是否跟隨重定向。
示例:
{
"url": "https://api.example.com/data/123",
"data": "raw data",
"content_type": "text/plain"
}
4. curl_delete
發起HTTP DELETE請求。
參數:
url
(字符串):發起DELETE請求的URL。
headers
(數組,可選):HTTP頭部。
timeout
(數字,可選):請求超時時間(秒)。
follow_redirects
(布爾值,可選):是否跟隨重定向。
示例:
{
"url": "https://api.example.com/data/123",
"headers": ["Authorization: Bearer token"]
}
5. curl_download
下載文件。
參數:
url
(字符串):要下載文件的URL。
output_filename
(字符串,可選):輸出文件名。
resume
(布爾值,可選):如果文件已存在,是否恢復部分下載。
timeout
(數字,可選):請求超時時間(秒)。
follow_redirects
(布爾值,可選):是否跟隨重定向。
示例:
{
"url": "https://example.com/file.zip",
"output_filename": "downloaded_file.zip",
"resume": true
}
6. curl_advanced
使用自定義參數執行curl(高級用戶)。
參數:
args
(數組):curl參數數組(不包括'curl'本身)。
示例:
{
"args": ["-X", "PATCH", "-H", "Content-Type: application/json", "-d", "{\"status\":\"updated\"}", "https://api.example.com/items/1"]
}
🔧 技術細節
開發
前提條件
- Node.js 18.0.0或更高版本。
- npm包管理器。
- curl命令行工具。
構建
npm run build
測試
手動測試服務器:
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | node build/index.js
運行測試:
npm test
代碼檢查
npm run lint
npm run lint:fix
項目結構
mcp-curl/
├── src/
│ └── index.ts # 主服務器實現
├── build/
│ └── index.js # 編譯後的JavaScript
├── test/
│ └── basic.test.js # 基本功能測試
├── examples/
│ └── test-server.js # 示例用法
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD管道
├── package.json # 項目配置
├── tsconfig.json # TypeScript配置
├── .eslintrc.json # ESLint配置
├── LICENSE # MIT許可證
├── DEPLOYMENT.md # 部署指南
├── CONTRIBUTING.md # 貢獻指南
├── CHANGELOG.md # 版本歷史
└── README.md # 本文件
驗證
測試服務器是否正常工作:
node build/index.js
故障排除
常見問題
- “Command not found”錯誤
- 確保mcp - curl已全局安裝:
npm install -g @247arjun/mcp-curl
。
- 或使用npx:
"command": "npx", "args": ["@247arjun/mcp-curl"]
。
- “Permission denied”錯誤
- 檢查文件權限:
chmod +x build/index.js
。
- 重新構建項目:
npm run build
。
- MCP服務器未在Claude中顯示
- 驗證配置文件中的JSON語法。
- 完全重啟Claude桌面。
- 檢查命令路徑是否正確。
- “curl command not found”
- 在系統上安裝curl(通常macOS/Linux預裝)。
- Windows用戶:通過包管理器安裝或從curl網站下載。
調試
通過設置環境變量啟用詳細日誌記錄:
DEBUG=1 node build/index.js
echo '{"jsonrpc": "2.0", "method": "initialize", "params": {}}' | node build/index.js
安全說明
- 對所有curl參數進行輸入驗證和清理。
- 在高級模式下限制文件操作。
- 使用spawn而不是shell實現安全的子進程執行。
- 不執行任意shell命令。
- 使用Zod模式進行輸入驗證。
📄 許可證
本項目採用MIT許可證,詳情請見LICENSE文件。