使用说明
通过MCP发送通用HTTP请求并获得标准化的API响应。
一种模型上下文协议(MCP)服务器,它公开HTTP/HTTPS请求执行,用于测试API、集成web服务和在代理工作流中获取远程数据。
概述
MewCP HTTP MCP服务器提供无状态、与身份无关的HTTP访问:
- 多方法请求执行(GET、POST、PUT、PATCH、DELETE、HEAD、OPTIONS)
- 使用标头、查询参数和JSON/原始正文进行灵活的请求整形
- 具有元数据、截断处理和JSON/body规范化的结构化响应有效载荷
非常适合:
- 从MCP兼容客户端调用外部REST API
- 快速测试Webhook和端点集成
- 在自动化和多代理系统中检索远程内容
认证
不需要凭据。该服务器是auth-agnostic-直接通过 headers 每个请求上的参数。
工具
http_request — Perform a generic HTTP/HTTPS request and return status, headers, and body.
执行通用HTTP/HTTPS请求并返回状态、标头和正文。
输入:
- `method` (string, required) — HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)
- `url` (string, required) — Target URL beginning with http:// or https://
- `headers` (object, optional) — Optional HTTP headers as a dict of string key/value pairs. Omit to send no custom headers.
- `params` (object, optional) — Optional query parameters as a dict; appended to the URL as ?key=value pairs. Omit to send no query string.
- `json_body` (any, optional) — Optional JSON request body (any JSON-serializable value). Mutually exclusive with `body`. Omit for requests with no body.
- `body` (string, optional) — Optional raw string request body. Mutually exclusive with `json_body`. Omit for requests with no body.
- `timeout_seconds` (number, optional, default: 30.0) — Read timeout in seconds for the HTTP request. Defaults to 30.0s if omitted. Increase for slow endpoints.
- `follow_redirects` (boolean, optional, default: true) — Whether to follow HTTP 3xx redirects automatically. Defaults to true if omitted.
- `max_response_chars` (integer, optional, default: 50000) — Maximum response body characters or bytes to return. Defaults to 50000 if omitted. Increase to retrieve larger responses.
输出 data 架构:
{
request: {
method: string;
url: string;
headers: { [key: string]: string };
params: { [key: string]: any };
timeout_seconds: number;
follow_redirects: boolean;
max_response_chars: number;
};
response: {
url: string;
status_code: number;
reason_phrase: string;
headers: { [key: string]: string };
elapsed_ms: number;
body: {
kind: string;
content: string;
truncated: boolean;
original_length: number;
json: any | null;
};
};
}
API参数参考
Response Envelope
每个工具都返回相同的顶级信封。仅 data 因工具而异。
// Success
{
"success": true,
"statusCode": 200,
"retriable": false,
"retry_after_seconds": null,
"error": null,
"data": { ... }
}
// Error
{
"success": false,
"statusCode": 400,
"retriable": false,
"retry_after_seconds": null,
"error": { "code": "VALIDATION_ERROR", "message": "{description}", "details": {} },
"data": null
}
retriable—true当可以安全重试时(速率限制,网络错误,503)。false用于验证和身份验证错误。retry_after_seconds--重试前等待秒数;仅在以下情况下出现retriable是true上游指定延迟。error.code--机器可读字符串:VALIDATION_ERROR,AUTH_ERROR,UPSTREAM_ERROR,SERVER_ERROR.
Resource Formats
URL输入:
Format: https://{host}/{path}?{query}
Example: https://api.example.com/v1/items?limit=10
响应机构(body 字段):
kind: string — "text" or "base64"
content: string — serialized body content
truncated: boolean — true if body was cut off at max_response_chars
original_length: number — full byte/character count before truncation
json: any | null — parsed JSON value if response was valid JSON, otherwise null
故障排除
Invalid URL Format
- 原因:
url不以开头http://或https:// - 解决方案:
- 提供完整的绝对URL(包括协议)
- 验证主机/路径中没有拼写错误
Unsupported HTTP Method
- 原因:
method超出允许的范围 - 解决方案:
- 使用以下选项之一:
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS - 确保方法以字符串形式传递
- 使用以下选项之一:
Conflicting Body Inputs
- 原因: 两者
json_body和body在同一请求中提供 - 解决方案:
- 使用
json_body对于JSON有效载荷 - 使用
body用于原始文本有效载荷 - 每次通话只发送一个正文字段
- 使用
Timeout or Upstream Network Errors
- 原因: 端点速度慢、网络问题或无法访问主机
- 解决方案:
- 增加
timeout_seconds对于长时间运行的端点 - 确认端点可公开访问
- 使用减少的有效负载或简化的查询参数重试
- 增加
Response Body Appears Truncated
- 原因: 超出响应大小
max_response_chars - 解决方案:
- 增加
max_response_chars如果需要更大的输出 - 从上游API请求具有过滤器/分页的较小有效载荷
- 增加
Malformed Request Payload
- 原因: JSON负载无效或缺少必填字段
- 解决方案:
- 发送前验证JSON语法
- 确保包括所有必需的工具参数
- 检查参数类型是否与预期值匹配
Resources
- HTTP方法参考(MDN) --官方方法行为文档
- HTTP状态代码(MDN) --标准HTTP响应状态参考
- httpx文档 --此服务器使用的Python HTTP客户端
- FastMCP文档 --FastMCP框架和协议使用
- FastMCP凭据 --用于凭证处理的FastMCP凭证包