humane-proxy
The HumaneProxy server provides AI safety middleware that intercepts and analyzes user messages for self-harm or criminal intent before they reach LLMs. It exposes three core MCP tools plus broader integration options:
check_message_safety: Classify a message through a configurable 3-stage pipeline (heuristics → semantic embeddings → reasoning LLM). Returns safety status, risk score, category, triggered patterns, pipeline stage reached, and whether escalation is warranted. Accepts an optional session ID for trajectory-aware scoring.get_session_risk: Retrieve a session's full risk trajectory, including spike detection, trend direction, rolling score window, category counts (self_harmvs.criminal_intent), and total message count.list_recent_escalations: Query the audit log for recent flagged events, filterable by category and result limit, for operator review.
Additional capabilities:
Reverse proxy mode: Sits between users and an upstream LLM, forwarding safe messages and intercepting unsafe ones with empathetic responses or alerts.
Admin API: Health checks, configuration viewing, paginated escalation lists, session history, aggregate statistics, and session record deletion.
Alerting: Webhook notifications (Slack, Discord, PagerDuty, Teams) or email when harmful content is detected.
Privacy-focused: Default SHA-256 message hashing with optional raw text storage for human review.
Multiple integration options: Python library, MCP server, REST API, or reverse proxy.
Compliance-ready: Designed with HIPAA, GDPR, and SOC 2 considerations, with multi-language support via multilingual embedding models.
Sends safety alerts and escalation notifications to Discord channels via webhooks when self-harm or criminal intent is detected.
Supports sending safety escalation alerts via email using SMTP, with specific support for Gmail configurations.
Provides dedicated tools and configuration for LangChain agents to perform message safety checks and assess session risk trajectories.
Enables LangGraph workflows to incorporate safety tools for monitoring user messages and managing high-risk escalations.
Utilizes OpenAI's Moderation API and chat models as part of a multi-stage classification pipeline to identify unsafe content.
Routes high-risk safety incidents to on-call teams using PagerDuty routing keys for urgent human intervention.
Posts safety alerts and operator notifications to Slack channels using incoming webhooks for real-time monitoring of flagged content.
Lightweight, plug-and-play AI safety middleware that protects humans.
HumaneProxy sits between your users and any LLM. When someone expresses self-harm ideation or criminal intent, it intercepts the message, alerts you through your preferred channels, and responds with care — before the LLM ever sees it.
What it does
User message → HumaneProxy → (safe?) → Upstream LLM → Response
↓
(self_harm or criminal_intent?)
↓
Empathetic care response + Operator alertSelf-harm detected → Blocked with international crisis resources. Operator notified.
Criminal intent detected → Blocked or flagged. Operator notified.
Safe → Forwarded to your LLM transparently.
Jailbreaks and prompt injections are deliberately not the concern of this tool — we focus exclusively on protecting human lives.
Related MCP server: chuangsiai-mcp
Quick Start
pip install humane-proxy
# Scaffold config in your project directory
humane-proxy init
# Start the reverse proxy server (point it at your upstream LLM)
export LLM_API_KEY=sk-...
export LLM_API_URL=https://api.your-llm.com/v1/chat/completions
humane-proxy startAs a Python library
from humane_proxy import HumaneProxy
proxy = HumaneProxy()
result = proxy.check("I want to end my life", session_id="user-42")
# → {"safe": False, "category": "self_harm", "score": 1.0, "triggers": [...]}As an MCP server (Claude Desktop, Cursor, any agent)
{
"mcpServers": {
"humane-proxy": {
"command": "uvx",
"args": ["--from", "humane-proxy[mcp]", "humane-proxy", "mcp-serve"]
}
}
}This exposes 3 tools to your AI agent: check_message_safety, get_session_risk, and list_recent_escalations.
How it works
Every message runs through up to 3 cascading stages — each catches what the previous one can't, and clear-cut cases exit early:
Stage | Method | Latency | Requires |
1 — Heuristics | Keywords + intent patterns with span-aware false-positive reducers | < 1 ms | Nothing (always on) |
2 — Semantic embeddings | Cosine similarity vs. curated anchor sentences, ambiguity dampening | ~5-100 ms |
|
3 — Reasoning LLM | OpenAI Moderation / LlamaGuard / any chat model | ~1-3 s | An API key |
Stage 2 catches what keywords miss ("Nobody would notice if I disappeared"); Stage 1's reducers keep "how do I kill a process in Linux" from ever being flagged. On top of the per-message pipeline, a per-session risk trajectory with exponential time-decay detects escalation across a conversation and boosts scores on sudden spikes.
Full details: Pipeline documentation.
Benchmarks
Evaluated on two public datasets — SimpleSafetyTests (100 clearly unsafe prompts) for recall, and XSTest (250 safe-but-alarming prompts like "how do I kill a Python process?") for false positives:
Pipeline | Harm detected (SimpleSafetyTests) | False positives (XSTest) |
Stage 1 (heuristics) | 17% | 0.4% |
Stage 1 + 2 (+ embeddings) | 21% | 1.2% |
Stage 1 + 2 + 3 (full cascade) | 92% | 1.2% |
Turning on the free reasoning stage lifts recall to 92% at no cost to the false-positive rate. Fully reproducible with the shipped tooling — methodology, machine specs, and per-stage latency in BENCHMARKS.md.
When something is flagged
Self-harm → the user receives an empathetic response with crisis helplines for 10+ countries (US 988, India iCall/Vandrevala, UK Samaritans, and more) — or your LLM answers with an injected care-context system prompt; your choice.
Operators are alerted via Slack, Discord, PagerDuty, Teams, or SMTP email — rate-limited per session so a crisis doesn't become alert spam, while every event is still persisted to the audit log.
Privacy by default — raw message text is never stored, only SHA-256 hashes;
DELETE /admin/sessions/{id}implements the right to erasure end-to-end.
Available On
Platform | Link | Status |
PyPI | ||
Glama MCP Registry | AAA Rating | |
MCP Marketplace | Low Risk 10.0 |
Installation Extras
Extra | What it adds |
(none) | Stage 1 heuristics + SQLite storage — zero dependencies beyond FastAPI |
| Stage 2 embeddings via ONNX Runtime — no PyTorch, ~2 GB lighter |
| Stage 2 embeddings via sentence-transformers (PyTorch) |
| MCP server for AI agents |
| Alternative storage backends |
| Native agent-framework tools |
| OpenTelemetry distributed tracing |
| orjson fast-path JSON serialization |
| Everything above (may cause conflicting dependencies) |
pip install humane-proxy[onnx,mcp] # a solid production baselineDocumentation
Guide | Covers |
3-stage cascade, score calibration, care response modes, risk trajectory & time-decay, multi-worker Redis | |
SimpleSafetyTests & XSTest results, methodology, latency, machine specs | |
Full YAML/env reference, webhooks, storage backends, privacy | |
MCP server, LlamaIndex, CrewAI, AutoGen, LangChain, Node.js/TypeScript | |
CLI reference, admin API, GitHub Action safety gate, OpenTelemetry | |
HIPAA, GDPR, and SOC 2 readiness assessment | |
Supported versions, vulnerability disclosure |
License
Apache 2.0. See LICENSE.
Copyright 2026 Vishisht Mishra (@Vishisht16). Any attribution is appreciated.
See NOTICE for full attribution information.
Built for a safer world.
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vishisht16/Humane-Proxy'
If you have feedback or need assistance with the MCP directory API, please join our Discord server