@ktwo/mcp-curl
v1.0.2
Published
MCP server providing HTTP request tools similar to curl
Maintainers
Readme
MCP Curl Server
一个基于 Model Context Protocol (MCP) 的 HTTP 请求工具服务器,提供类似 curl 的功能,可以执行各种 HTTP 请求。
功能特性
- 支持多种 HTTP 方法:GET、POST、PUT、DELETE、PATCH、HEAD
- 自定义请求头
- 支持 JSON 和文本请求体
- 自动处理 JSON 响应
- 支持超时设置
- 支持重定向控制
- 详细的响应信息(状态码、响应头、响应体)
安装
cd mcp-curl
npm install使用方法
安装
方式 1:使用 npx(推荐)
无需安装,直接在 Claude Desktop 配置中使用:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mcp-curl": {
"command": "npx",
"args": ["-y", "@ktwo/mcp-curl"]
}
}
}方式 2:全局安装
npm install -g @ktwo/mcp-curl然后在配置中使用:
{
"mcpServers": {
"mcp-curl": {
"command": "mcp-curl"
}
}
}方式 3:本地开发
{
"mcpServers": {
"mcp-curl": {
"command": "node",
"args": ["/path/to/mcp-curl/index.js"]
}
}
}独立运行(测试)
npm start可用工具
1. http_get
执行 HTTP GET 请求,用于获取资源。
参数:
url(必需): 请求的 URL 地址headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
示例:
{
"url": "https://api.example.com/users",
"headers": {
"Authorization": "Bearer token123"
}
}2. http_post
执行 HTTP POST 请求,用于创建资源或提交数据。
参数:
url(必需): 请求的 URL 地址body(可选): 请求体,可以是对象或字符串headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
示例:
{
"url": "https://api.example.com/users",
"body": {
"name": "John Doe",
"email": "[email protected]"
},
"headers": {
"Authorization": "Bearer token123"
}
}3. http_put
执行 HTTP PUT 请求,用于更新资源。
参数:
url(必需): 请求的 URL 地址body(可选): 请求体,可以是对象或字符串headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
4. http_delete
执行 HTTP DELETE 请求,用于删除资源。
参数:
url(必需): 请求的 URL 地址headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
5. http_patch
执行 HTTP PATCH 请求,用于部分更新资源。
参数:
url(必需): 请求的 URL 地址body(可选): 请求体,可以是对象或字符串headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
6. http_head
执行 HTTP HEAD 请求,只获取响应头不获取响应体。
参数:
url(必需): 请求的 URL 地址headers(可选): 请求头对象timeout(可选): 超时时间(毫秒),默认 30000followRedirects(可选): 是否跟随重定向,默认 true
响应格式
成功响应:
{
"success": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json",
"content-length": "123"
},
"body": "响应内容",
"url": "https://api.example.com/users"
}失败响应:
{
"success": false,
"error": "错误信息",
"type": "错误类型"
}使用示例
在 Claude Desktop 中,你可以这样使用:
- 获取数据
使用 http_get 工具获取 https://jsonplaceholder.typicode.com/posts/1- 创建数据
使用 http_post 工具向 https://jsonplaceholder.typicode.com/posts 发送数据:
{
"title": "Test Post",
"body": "This is a test",
"userId": 1
}- 自定义请求头
使用 http_get 工具访问 https://api.github.com/user,
添加 Authorization 头:Bearer YOUR_TOKEN注意事项
- 自动处理 JSON 请求体和响应
- 对于非 JSON 内容类型,返回文本
- 默认添加 User-Agent: MCP-Curl/1.0
- 超时默认为 30 秒
- 自动跟随重定向(可配置)
License
MIT
