关于 Perspective API Alternative (Toxicity Detection)
Perspective API Alternative 是 stdio MCP 服务,使用 Detoxify 模型而非大模型为英文文本评估毒性。它返回兼容 Perspective API 的结果,供 Agent 在发布文本前进行检查。
主要功能
- 01六类毒性属性评分
- 02逐条文本标记结果
- 03批量分析英文文本
- 04可配置属性与阈值
- 05兼容 Perspective API 格式
- 06使用 Detoxify,非大模型
适用场景
- 01Agent 发布评论前进行筛查
- 02批量检查英文文本
- 03按指定毒性阈值标记文本
MCP 相关
stdio MCP 服务提供 analyze_toxicity 工具,将文本发送至 Apify 毒性 API 并返回评分和标记结果。另提供可选的可流式 HTTP MCP 端点。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://koyourmoon--perspective-api-alternative.apify.actor/mcpclaude mcp add --transport http koyourmoon-perspective-api-alternative https://koyourmoon--perspective-api-alternative.apify.actor/mcp{"mcpServers":{"koyourmoon-perspective-api-alternative":{"type":"http","url":"https://koyourmoon--perspective-api-alternative.apify.actor/mcp"}}}在 Cursor 中打开{"servers":{"koyourmoon-perspective-api-alternative":{"type":"http","url":"https://koyourmoon--perspective-api-alternative.apify.actor/mcp"}}}在 VS Code 中打开{"mcpServers":{"koyourmoon-perspective-api-alternative":{"type":"http","url":"https://koyourmoon--perspective-api-alternative.apify.actor/mcp"}}}{"mcpServers":{"koyourmoon-perspective-api-alternative":{"serverUrl":"https://koyourmoon--perspective-api-alternative.apify.actor/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://koyourmoon--perspective-api-alternative.apify.actor/mcp需要授权工具
详细介绍
Perspective API 替代方案:毒性检测 MCP 服务
此仓库包含一个使用 stdio 传输的 MCP 服务。该服务为 AI Agent 提供一个工具:analyze_toxicity。使用此工具可在 Agent 发布文本前检查文本。
该工具会为每段文本返回 6 项 0 到 1 之间的分数,以及一个标记值:
TOXICITY、SEVERE_TOXICITY、INSULT、PROFANITY、THREAT、IDENTITY_ATTACK
这些分数由开源 Detoxify 模型生成。该模型不是大模型。因此,相同文本始终会得到相同分数。仅支持英语。
请求和响应格式与 Google Perspective API 的格式相同。Google 将于 2026 年 12 月 31 日停止 Perspective API。
服务运行方式
此仓库中的服务实现位于 server.py。它仅使用 Python 标准库(Python 3.9 或更高版本)。
- 服务从 stdin 读取 JSON-RPC 消息,并将响应写入 stdout。
- 服务自行处理
initialize、ping和tools/list。这些消息不需要令牌。 - 对于
tools/call,服务会将文本发送至 Apify 上的毒性 API,并返回分数。 - 毒性 API 运行 Detoxify 模型。每次调用的费用通过你的 Apify 账户支付。
要求
- Python 3.9 或更高版本,或 Docker
APIFY_TOKEN环境变量中设置的 Apify API 令牌
如需获取令牌,请打开 Apify Console。然后前往 Settings > API & Integrations。
安装
Python
-
克隆仓库:
git clone https://github.com/koyourmoon/perspective-api-alternative-mcp.git -
将服务添加到 MCP 客户端的配置中:
{ "mcpServers": { "perspective-api-alternative": { "command": "python", "args": ["/path/to/perspective-api-alternative-mcp/server.py"], "env": { "APIFY_TOKEN": "<APIFY_TOKEN>" } } } }
Docker
-
构建镜像:
docker build -t perspective-api-alternative-mcp . -
将服务添加到 MCP 客户端的配置中:
{ "mcpServers": { "perspective-api-alternative": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "APIFY_TOKEN", "perspective-api-alternative-mcp"], "env": { "APIFY_TOKEN": "<APIFY_TOKEN>" } } } }
工具:analyze_toxicity
| 参数 | 类型 | 描述 |
|---|---|---|
texts | 字符串数组,必填 | 1 至 100 段需要评分的英语文本 |
attributes | 字符串数组 | 要返回的属性。默认返回全部 6 项。 |
threshold | 数字 | 文本被标记时对应的 TOXICITY 分数。默认值为 0.5。 |
单段文本的结果示例:
{
"results": [
{
"text": "You are an idiot.",
"scores": { "TOXICITY": 0.98, "INSULT": 0.95, "PROFANITY": 0.62 },
"flagged": true,
"billed_units": 1
}
]
}
如果文本看起来不是英语,结果中会包含一个 warning 字段。该文本的分数不可靠。
环境变量
| 名称 | 必填 | 描述 |
|---|---|---|
APIFY_TOKEN | 是,用于 tools/call | 你的 Apify API 令牌 |
PERSPECTIVE_ALT_URL | 否 | 毒性 API 的其他 URL |
价格
- 每 1,000 个文本单位收费 $0.50。一个文本单位是指文本中每开始计数的 1,000 个字符。大多数评论为 1 个单位。
- Apify Bronze、Silver 和 Gold 计划价格更低。
- 空闲 60 秒后首次调用可能需要 10 到 30 秒(冷启动)。
远程连接(可选)
你也可以将 MCP 客户端直接连接到毒性 API。此连接不会使用 server.py。
| 项目 | 值 |
|---|---|
| 传输方式 | Streamable HTTP |
| URL | https://koyourmoon--perspective-api-alternative.apify.actor/mcp |
| 身份验证 | Authorization: Bearer <APIFY_TOKEN> |
文件
| 文件 | 内容 |
|---|---|
server.py | MCP 服务 |
Dockerfile | 服务的容器镜像 |
glama.json | Glama 的维护者数据 |
server.json | 官方 MCP Registry 的条目 |
链接
- Apify Store 页面:https://apify.com/koyourmoon/perspective-api-alternative
- 适用于大型任务的批处理 Actor:https://apify.com/koyourmoon/toxicity-detector
许可证
MIT。本项目与 Google 或 Jigsaw 无关。“Perspective API”是 Google LLC 的商标。
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。