使用说明
MCP卷曲服务器
一种模型上下文协议(MCP)服务器,提供类似于curl的HTTP请求功能。该服务器允许AI模型发出具有完全卷曲功能的HTTP请求,包括标头、身份验证、不同的HTTP方法和响应处理。
特性
- 完全HTTP支持:GET、POST、PUT、DELETE、PATCH、HEAD和OPTIONS方法
- 标题管理:自定义标头和身份验证支持
- 申请机构:JSON、表单数据和纯文本支持
- 响应详细信息:状态代码、标头、计时和大小信息
- 重定向处理:可配置重定向
- 超时控制:可定制的请求超时
- 文件下载:下载文件的专用工具
- 错误处理:全面的错误报告
安装
npm install @atom8n/mcp-curl
MCP配置
将以下配置添加到MCP客户端:
{
"mcp-curl": {
"command": "npx",
"args": [
"@atom8n/mcp-curl"
]
}
}
可用工具
1.curl_request
使用类似curl的功能发出HTTP请求,并完全控制所有参数。
参数:
url(必填):向其发出请求的URLmethod(可选):HTTP方法-GET、POST、PUT、DELETE、PATCH、HEAD、OPTIONS(默认值:GET)headers(可选):HTTP标头作为键值对body(可选):POST、PUT、PATCH请求的请求体(字符串或对象)timeout(可选):请求超时(毫秒)(默认值:30000)followRedirects(可选):是否遵循重定向(默认:true)includeHeaders(可选):是否在输出中包含响应头(默认值:true)
2.curl_get
用于基本HTTP GET操作的简化GET请求工具。
参数:
url(必填):向其发出GET请求的URLheaders(可选):HTTP标头作为键值对timeout(可选):请求超时(毫秒)(默认值:30000)
3.curl_post
POST请求工具,具有自动JSON正文处理功能。
参数:
url(必填):向以下对象发出POST请求的URLbody(必填):作为请求体发送的JSON对象headers(可选):HTTP标头作为键值对timeout(可选):请求超时(毫秒)(默认值:30000)
4.curl_download
从URL下载文件,大文件超时时间延长。
参数:
url(必填):下载网址headers(可选):HTTP标头作为键值对timeout(可选):请求超时(毫秒)(默认值:60000)
使用示例
基本GET请求
{
"tool": "curl_get",
"parameters": {
"url": "https://api.example.com/data"
}
}
带JSON正文的POST请求
{
"tool": "curl_post",
"parameters": {
"url": "https://api.example.com/users",
"body": {
"name": "John Doe",
"email": "john@example.com"
},
"headers": {
"Authorization": "Bearer your-token-here"
}
}
}
全功能请求
{
"tool": "curl_request",
"parameters": {
"url": "https://api.example.com/upload",
"method": "PUT",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer your-token-here"
},
"body": {
"file": "data.json",
"content": "file content here"
},
"timeout": 60000,
"followRedirects": true
}
}
文件下载
{
"tool": "curl_download",
"parameters": {
"url": "https://example.com/large-file.zip",
"timeout": 120000
}
}
响应格式
所有工具都以以下格式返回响应:
HTTP 200 OK
URL: https://api.example.com/data
Time: 245ms
Size: 1024 bytes
Response Headers:
content-type: application/json
content-length: 1024
server: nginx/1.18.0
Response Body:
{"status": "success", "data": "..."}
发展
先决条件
- Node.js 18+
- TypeScript 5.6+
- npm
设置
# Clone the repository
git clone <repository-url>
cd mcp-curl
# Install dependencies
npm install
# Build the project
npm run prepare
项目结构
├── src/
│ └── index.mts # Main TypeScript source
├── lib/
│ ├── index.mjs # Compiled JavaScript
│ ├── index.mjs.map # Source map
│ └── index.d.mts # TypeScript declarations
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
└── eslint.config.mjs # ESLint configuration
构建过程
该项目使用具有以下构建配置的TypeScript:
- 目标:ES2015
- 模块:CommonJS
- 输出:
lib/目录 - 源地图:已启用
- 声明:已生成
脚本
prepare:编译TypeScript并使二进制文件可执行
依赖项
运行时依赖关系
@modelcontextprotocol/sdk:MCP服务器框架node-fetch:HTTP客户端库rimraf:文件系统实用程序spawn-rx:流程生成实用程序
开发依赖
@types/node:Node.js类型定义@types/node-fetch:节点获取类型定义shx:用于跨平台兼容性的Shell实用程序ts-node:TypeScript执行typescript:TypeScript编译器
许可证
MIT许可证-请参阅 复制 文件以获取详细信息。
贡献
请阅读 代码_OF_CONDUCT.md 我们的行为准则和贡献指南。
版本
当前版本:1.0.0
支持
对于问题和功能请求,请使用项目的问题跟踪器。
