MCP API请求者
一个模型上下文协议(MCP)服务器,它使LLM能够使用自定义的头和主体发出任意的HTTP API请求(GET、POST、PUT、DELETE等)。与Claude Desktop和其他MCP兼容的AI工具配合使用。
特性
- 🌐 HTTP 操作:发出任何HTTP请求(GET、POST、PUT、DELETE、PATCH等)
- 🔧 自定义配置:完全控制标头、查询参数和请求正文
- 📄 JSON支持:JSON请求和响应体的本地处理
- 🛠 稳健的错误处理:将4xx/5xx响应作为结构化数据返回,而不是失败,允许LLM检查错误
- 🔒 安全执行:可用于测试API、Webhook和与外部服务交互
安装
使用npx(推荐)
无需安装!只需将Claude Desktop配置为使用npx:
{
"mcpServers": {
"api-requester": {
"command": "npx",
"args": [
"-y",
"github:yryuu/mcp-api-requester"
]
}
}
}本地安装
git clone
cd mcp-api-requester
npm install
npm run build配置
克劳德桌面版
编辑您的Claude Desktop配置文件:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
视窗: %APPDATA%\Claude\claude_desktop_config.json
添加服务器配置:
{
"mcpServers": {
"api-requester": {
"command": "node",
"args": ["/absolute/path/to/mcp-api-requester/dist/index.js"]
}
}
}可用工具
make_request
发出任意HTTP请求。
参数:
url(string):发出请求的完整URL。method(string):HTTP方法(GET、POST、PUT、DELETE、PATCH等)。默认为GET。headers(object,可选):HTTP标头的键值对。params(object,可选):URL查询参数的键值对。cookies(object,可选):请求中包含的cookie键值对。body(object/string,可选):请求正文。Content-Type标头应与此正文匹配。
示例(GET):
Make a GET request to https://api.example.com/users?id=123示例(POST):
POST to https://api.example.com/data with content-type application/json and body {"key": "value"}示例(Cookie):
Make a GET request to https://api.example.com/profile with cookies {"session": "abc", "theme": "dark"}发展
设置
cd mcp-api-requester
npm install构建
npm run build测试
运行附带的手动测试脚本:
npm test注:用途 tsx 直接运行TypeScript测试文件。调试
使用MCP检查器测试服务器:
npx @modelcontextprotocol/inspector node dist/index.js安全
- 警告:此工具使LLM能够向以下对象发出请求 任何 您提供的URL或它发现的URL。
- 确保仅在受信任的环境中使用此功能。
- 当要求LLM与敏感API或内部服务交互时,请务必谨慎。
许可证
麻省理工学院
作者
yryuu
