🚀 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文件。