Perspective API Alternative (Toxicity Detection)
Perspective API Alternative: Toxicity Detection MCP Server
This repository contains an MCP server for the stdio transport. The server gives AI agents one tool, analyze_toxicity. Use the tool to examine text before an agent publishes it.
The tool returns six scores from 0 to 1 and a flagged value for each text:
TOXICITY,SEVERE_TOXICITY,INSULT,PROFANITY,THREAT,IDENTITY_ATTACK
The scores come from the open-source Detoxify model. The model is not an LLM. Thus, the same text always gets the same score. English only.
The request and response format is the same as the format of the Google Perspective API. Google stops the Perspective API on December 31, 2026.
How the server operates
The server implementation is server.py in this repository. It uses only the Python standard library (Python 3.9 or later).
The server reads JSON-RPC messages from stdin and writes the responses to stdout.
The server answers
initialize,pingandtools/listitself. These messages do not need a token.For
tools/call, the server sends the texts to the toxicity API on Apify, and returns the scores.The toxicity API runs the Detoxify model. You pay for each call through your Apify account.
Related MCP server: glin-profanity-mcp
Requirements
Python 3.9 or later, or Docker
An Apify API token in the
APIFY_TOKENenvironment variable
To get a token, open the Apify Console. Then go to Settings > API & Integrations.
Installation
Python
Clone the repository:
git clone https://github.com/koyourmoon/perspective-api-alternative-mcp.gitAdd the server to the configuration of your MCP client:
{ "mcpServers": { "perspective-api-alternative": { "command": "python", "args": ["/path/to/perspective-api-alternative-mcp/server.py"], "env": { "APIFY_TOKEN": "<APIFY_TOKEN>" } } } }
Docker
Build the image:
docker build -t perspective-api-alternative-mcp .Add the server to the configuration of your MCP client:
{ "mcpServers": { "perspective-api-alternative": { "command": "docker", "args": ["run", "-i", "--rm", "-e", "APIFY_TOKEN", "perspective-api-alternative-mcp"], "env": { "APIFY_TOKEN": "<APIFY_TOKEN>" } } } }
Tool: analyze_toxicity
Parameter | Type | Description |
| array of strings, required | 1 to 100 English texts to score |
| array of strings | Attributes to return. The default is all six. |
| number |
|
Example result for one text:
{
"results": [
{
"text": "You are an idiot.",
"scores": { "TOXICITY": 0.98, "INSULT": 0.95, "PROFANITY": 0.62 },
"flagged": true,
"billed_units": 1
}
]
}If a text looks non-English, the result has a warning field. The scores for that text are not reliable.
Environment variables
Name | Required | Description |
| Yes, for | Your Apify API token |
| No | A different URL for the toxicity API |
Prices
$0.50 for 1,000 text units. A text unit is each started 1,000 characters of a text. Most comments are 1 unit.
Lower prices for Apify Bronze, Silver and Gold plans.
The first call after an idle period of 60 seconds can take 10 to 30 seconds (cold start).
Remote connection (optional)
You can also connect your MCP client directly to the toxicity API. This connection does not use server.py.
Item | Value |
Transport | Streamable HTTP |
URL |
|
Authentication |
|
Files
File | Content |
| The MCP server |
| The container image for the server |
| The maintainer data for Glama |
| The entry for the official MCP Registry |
Links
Apify Store page: https://apify.com/koyourmoon/perspective-api-alternative
Batch Actor for large jobs: https://apify.com/koyourmoon/toxicity-detector
License
MIT. This project is not affiliated with Google or Jigsaw. "Perspective API" is a trademark of Google LLC.
Available Tools
1 toolanalyze_toxicityAnalyze toxicityARead-onlyInspect
Score English text for toxicity, severe toxicity, insults, profanity, threats and identity attacks (0-1 probabilities, same attributes as Google Perspective API). Use it to moderate user-generated content, filter LLM output, or triage comments before an agent posts them. Pass up to 100 texts at once. Read-only: it does not store or publish text. Each call is billed to your Apify account ($0.50 for 1,000 text units). The first call after an idle period can take 10 to 30 seconds. English only: non-English text gets a warning field.
| Name | Required | Description | Default |
|---|---|---|---|
| texts | Yes | Texts to score (English). One item per comment or message. | |
| threshold | No | TOXICITY score at or above which a text is marked flagged. | |
| attributes | No | Attributes to return. Defaults to all six. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already declare readOnlyHint=true and openWorldHint=false, but the description adds substantial operational context: read-only with no text storage or publication, Apify billing at $0.50 per 1,000 text units, a 10-30 second cold-start latency, a 100-text batch limit, and an English-only warning field for non-English text. These are exactly the behavioral traits an agent needs beyond the safety annotations.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is front-loaded with purpose and use cases, then moves through batch size, read-only behavior, billing, latency, and language limits. Every sentence supplies operational information an agent needs, with no filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a 3-parameter scoring tool with no output schema, the description covers the output scale, the attributes scored, usage scenarios, batch limits, read-only behavior, cost, latency, and the English-only warning field. An agent has enough context to invoke it correctly without additional documentation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents texts, threshold, and attributes. The description repeats the 100-text batch limit and English-only constraint from the schema, adding little parameter meaning beyond the structured fields; threshold behavior is left entirely to the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description opens with a specific verb ('Score') and resource ('English text') and enumerates the exact outputs: toxicity, severe toxicity, insults, profanity, threats, and identity attacks. It also states the output scale (0-1 probabilities) and names the reference API, so an agent knows precisely what the tool produces.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
It gives concrete use cases—moderating user-generated content, filtering LLM output, or triaging comments before an agent posts them—so the agent knows when the tool is appropriate. It does not state when not to use it or name alternatives, but there are no sibling tools, so this is clear context without exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.1.0- First observed
analyze_toxicity
TDQS
Scored across 1 tool
With only one tool, there is no possibility of misselection or overlap with a sibling tool. The single tool's purpose (toxicity scoring) is unambiguous and clearly stated.
The lone name 'analyze_toxicity' follows a clean verb_noun snake_case convention. With a single tool there is no opportunity for inconsistent conventions.
A single tool is defensible for a narrow API wrapper, and batching up to 100 texts per call covers the main use case. However, one tool is the thinnest possible surface, leaving no separate operations for things like model/attribute discovery or quota checks.
The scoring operation itself is complete: multi-attribute probabilities, batching, and clear read-only semantics cover the moderation workflow. Minor gaps exist around attribute/language enumeration and rate-limit or quota visibility, but agents can work around these.
Maintenance
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
Free, no-key MCP server: token estimates, JSON Schema conversion, MCP configs, tool search.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
AlicenseNot gradedqualityCmaintenanceProvides advanced evaluation tools for assessing AI safety, alignment, and performance of LLM outputs. Enables programmatic evaluation of quality, safety metrics like toxicity and PII detection, and operational metrics including carbon footprint and cost estimation.4Apache 2.0- AlicenseNot gradedqualityCmaintenanceContent moderation and profanity detection MCP server with 19 tools, 24 language support, leetspeak/Unicode obfuscation detection, context-aware analysis, batch processing, and user tracking for AI-powered content safety.12 npm65MIT
- AlicenseNot gradedqualityDmaintenanceA minimal MCP server with four tools (add, greet, text_stats, divide) demonstrating typed parameters, structured outputs, and error handling over stdio transport.MIT
- AlicenseNot gradedqualityDmaintenanceConfigurable MCP server that lets you define LLM-powered tools via JSON, enabling easy integration of multiple models (GPT, Gemini, Claude, etc.) as MCP tools without writing Python code.6MIT