trackmcp
Back to directory
glincker

glin-profanity

View on GitHub

Open-source ML-powered profanity filter with TensorFlow.js toxicity detection, leetspeak & Unicode obfuscation resistance. 21M+ ops/sec, 23 languages, React hooks, LRU caching. npm & PyPI.

60 stars TypeScriptOthers Updated Sep 2, 2026
chatglinckernpmnpm-packageopen-sourceprivacytypescriptglin-profanitycontent-moderationjavascriptmachine-learningprofanity-filterpythonreact-hookstensorflow-jstoxicity-detection

Documentation

GLIN PROFANITY

The Open-Source AI Guardrail. Profanity, PII, Secrets, Soon: Prompt Injection β€” One Library, One MCP Server, Runs Offline.


πŸ“¦ Packages

This monorepo maintains the following packages:

PackageVersionDescription
glin-profanity![npm](https://www.npmjs.com/package/glin-profanity)Core profanity filter for JavaScript/TypeScript
glin-profanity![PyPI](https://pypi.org/project/glin-profanity/)Core profanity filter for Python
glin-profanity-mcp![npm](https://www.npmjs.com/package/glin-profanity-mcp)MCP server for AI assistants (Claude, Cursor, etc.)
openclaw-profanity![npm](https://www.npmjs.com/package/openclaw-profanity)Plugin for OpenClaw/Moltbot AI agents

Why Glin Profanity?

Modern AI applications need more than a word list. Users evade filters with `f4ck`, `sh1t`, and `fΥ½ck` (Cyrillic `Υ½` β†’ `u`). LLM pipelines leak PII and secrets into logs. Prompt injection slips through unguarded inboxes. Today's moderation problem is a guardrail problem β€” and most solutions leave you choosing between a Python-only library, a Llama-licensed model, or a paid cloud API.

Glin Profanity is the MIT-licensed, Node-native, MCP-first answer. It runs entirely offline, ships a 12 KB core bundle with no mandatory cloud calls, integrates with Claude/Cursor/Windsurf via 24 MCP tools out of the box, and covers 24 languages with leetspeak and Unicode homoglyph evasion detection built in. Prompt-injection, PII, and secrets scanning are all shipped today.

vs. Meta PurpleLlama β€” Python + Llama Community License, requires downloading weights, no Node support, no MCP server.

vs. ProtectAI llm-guard β€” Python-only, heavy transformer dependencies, no edge/browser runtime.

vs. Azure Content Safety β€” paid cloud API, data leaves your infra, rate-limited.

code
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           GLIN PROFANITY v3                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚   Input Text ──►  Unicode       ──►  Leetspeak    ──►  Dictionary  ──► ML  β”‚
β”‚                   Normalization      Detection         Matching        Checkβ”‚
│                   (homoglyphs)       (f4ck→fuck)       (24 langs)     (opt) │
β”‚                                                                             β”‚
β”‚   "fΥ½ck"     ──►  "fuck"        ──►  "fuck"       ──►  MATCH       ──► βœ“   β”‚
β”‚                                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Performance Benchmarks

From the CI shootout gate (`benchmarks/shootout/results.md`), Node.js v22, 20-input torture-set batches:

Libraryops/secF1 (accuracy)False-Positive Rate
glin-profanity99080.6%0.0%
obscenity5,11279.5%5.9%
bad-words24154.2%0.0%
leo-profanity338,40734.6%0.0%
@2toad/profanity839,79656.7%0.0%

glin-profanity trades raw throughput for zero false positives and the highest F1 in the field. See `benchmarks/shootout/results.md` for the full per-category breakdown.


Feature Comparison

Featureglin-profanityobscenityDetoxifyPurpleLlamallm-guard
MIT licenseYesYesApache-2.0Llama CommunityApache-2.0
Node-nativeYesYesNoNoNo
Python packageYesNoYesYesYes
MCP server (24 tools)YesNoNoNoNo
Runs fully offlineYesYesYesYes (needs weights)Yes
Leetspeak detectionYesPartialNoNoNo
Unicode homoglyph detectionYesNoNoNoNo
Multi-language support24 languagesEnglish only6 languagesEnglish onlyEnglish only
ML toxicity detectionYes (TensorFlow.js, opt-in)NoYes (PyTorch)Yes (Llama)Yes (transformers)
Edge / browser runtimeYesYesNoNoNo
Bundle size (core, minified)12 KB6 KBN/AN/AN/A
Prompt-injection detectionYes (shipped)NoNoYesYes
PII / secrets scanningYes (shipped)NoNoNoYes

Installation

JavaScript/TypeScript

bash
npm install glin-profanity

Python

bash
pip install glin-profanity

Quick Start

JavaScript

javascript
import { checkProfanity, Filter } from 'glin-profanity';

// Simple check
const result = checkProfanity("This is f4ck1ng bad", {
  detectLeetspeak: true,
  languages: ['english']
});

result.containsProfanity  // true
result.profaneWords       // ['fucking']

// With replacement
const filter = new Filter({
  replaceWith: '***',
  detectLeetspeak: true
});
filter.checkProfanity("sh1t happens").processedText  // "*** happens"

Python

python
from glin_profanity import Filter

filter = Filter({"languages": ["english"], "replace_with": "***"})

filter.is_profane("damn this")           # True
filter.check_profanity("damn this")      # Full result object

React

tsx
import { useProfanityChecker } from 'glin-profanity';

function ChatInput() {
  const { result, checkText } = useProfanityChecker({
    detectLeetspeak: true
  });

  return (
     checkText(e.target.value)} />
    {result?.containsProfanity && Clean up your language}
  );
}

Architecture

mermaid
flowchart LR
    subgraph Input
        A[Raw Text]
    end

    subgraph Processing
        B[Unicode Normalizer]
        C[Leetspeak Decoder]
        D[Word Tokenizer]
    end

    subgraph Detection
        E[Dictionary Matcher]
        F[Fuzzy Matcher]
        G[ML Toxicity Model]
    end

    subgraph Output
        H[Result Object]
    end

    A --> B --> C --> D
    D --> E --> H
    D --> F --> H
    D -.->|Optional| G -.-> H

Detection Capabilities

Leetspeak Detection

javascript
const filter = new Filter({
  detectLeetspeak: true,
  leetspeakLevel: 'aggressive'  // basic | moderate | aggressive
});

filter.isProfane('f4ck');     // true
filter.isProfane('5h1t');     // true
filter.isProfane('@$$');      // true
filter.isProfane('ph.u" "ck'); // true (aggressive mode)

Unicode Homoglyph Detection

javascript
const filter = new Filter({ normalizeUnicode: true });

filter.isProfane('fΥ½ck');   // true (Armenian 'Υ½' β†’ 'u')
filter.isProfane('shΡ–t');   // true (Cyrillic 'Ρ–' β†’ 'i')
filter.isProfane('Ζ’uck');   // true (Latin 'Ζ’' β†’ 'f')

ML-Powered Detection

javascript
import { loadToxicityModel, checkToxicity } from 'glin-profanity/ml';

await loadToxicityModel({ threshold: 0.9 });

const result = await checkToxicity("You're the worst player ever");
// { toxic: true, categories: { toxicity: 0.92, insult: 0.87, ... } }

Supported Languages

24 languages with curated dictionaries:

ArabicChineseCzechDanish
DutchEnglishEsperantoFinnish
FrenchGermanHindiHungarian
ItalianJapaneseKoreanNorwegian
PersianPolishPortugueseRussian
SpanishSwedishThaiTurkish

Documentation

DocumentDescription
Getting StartedInstallation and basic usage
API ReferenceComplete API documentation
Framework ExamplesReact, Vue, Angular, Express, Next.js
Advanced FeaturesLeetspeak, Unicode, ML, caching
ML GuideTensorFlow.js integration
ChangelogVersion history

Local Testing Interface

Run the interactive playground locally to test profanity detection:

bash
# Clone the repo
git clone https://github.com/GLINCKER/glin-profanity.git
cd glin-profanity/packages/js

# Install dependencies
npm install

# Start the local testing server
npm run dev:playground

Open http://localhost:4000 to access the testing interface with:

  • Real-time profanity detection
  • Toggle leetspeak, Unicode normalization, ML detection
  • Multi-language selection
  • Visual results with severity indicators

Use Cases

ApplicationHow Glin Profanity Helps
Chat platformsReal-time message filtering with React hook
GamingDetect obfuscated profanity in player names/chat
Social mediaScale moderation with ML-powered detection
EducationMaintain safe learning environments
EnterpriseFilter internal communications
AI/ML pipelinesClean training data before model ingestion

MCP Server for AI Assistants

Glin Profanity includes an MCP (Model Context Protocol) server that enables AI assistants like Claude Desktop, Cursor, Windsurf, and other MCP-compatible tools to use profanity detection as a native tool.

Quick Setup

Claude Desktop (`~/Library/Application Support/Claude/claude_desktop_config.json`):

json
{
  "mcpServers": {
    "glin-profanity": {
      "command": "npx",
      "args": ["-y", "glin-profanity-mcp"]
    }
  }
}

Cursor (`.cursor/mcp.json`):

json
{
  "mcpServers": {
    "glin-profanity": {
      "command": "npx",
      "args": ["-y", "glin-profanity-mcp"]
    }
  }
}

Available Tools (24)

ToolDescription
`check_profanity`Check text for profanity with detailed results
`censor_text`Censor profanity with configurable replacement
`analyze_context`Context-aware analysis with domain whitelists
`batch_check`Check multiple texts in one operation
`validate_content`Content validation with safety scoring (0-100)
`detect_obfuscation`Detect leetspeak and Unicode tricks
`get_supported_languages`List all 24 supported languages
`explain_match`Explain why text was flagged with reasoning
`suggest_alternatives`Suggest clean alternatives for profane content
`analyze_corpus`Analyze up to 500 texts for moderation stats
`compare_strictness`Compare results across strictness levels
`create_regex_pattern`Generate regex patterns for custom detection
`track_user_message`Track user messages for repeat offender detection
`get_user_profile`Get moderation profile for a specific user
`get_high_risk_users`List users with high violation rates
`reset_user_profile`Reset a user's moderation history
`stream_check`Real-time streaming profanity check
`stream_batch`Stream multiple texts with live results
`get_stream_stats`Get streaming session statistics
`check_prompt_injection`Scan text for prompt injection attacks (rule-based, 50 patterns)
`scan_secrets`Detect leaked API keys, tokens, and credentials (110 patterns + entropy)
`scan_pii`Detect PII: email, phone, SSN, credit card, IBAN, passport, and more
`redact_pii`Redact PII into reversible vault-backed placeholders
`restore_pii`Restore PII placeholders to original values via vault session

Plus 5 workflow prompts and 5 reference resources for guided AI interactions.

Example Prompts for AI Assistants

code
"Check this user comment for profanity using glin-profanity"
"Validate this blog post content with high strictness"
"Batch check these 50 messages for any inappropriate content"
"Analyze this medical text with the medical domain context"

See the full MCP documentation for setup instructions and examples.


Shipped AI Guardrails

The scanner layer is live. Import from `glin-profanity/scanners`:

js
import { PromptInjectionScanner, SecretsScanner, PiiScanner, Vault, scanAll } from 'glin-profanity/scanners';
ScannerCoverage
`PromptInjectionScanner`50 patterns across 6 attack categories
`SecretsScanner`110 patterns (AWS, GCP, Azure, GitHub, Stripe, OpenAI, Anthropic, …) + Shannon entropy
`PiiScanner`27 patterns with Luhn + IBAN mod-97 validation
`Vault`Placeholder-based redact/restore with 4 strategies
`scanAll`Composite scanner β€” runs all of the above in one call

Coming in 2026

The following capabilities are on the active roadmap.

FeatureETANotes
`glincker/glin-guard-small` on HF HubQ3 2026Our own distilled toxicity model, MIT weights, designed for edge inference
AI-slop detectionQ3 2026Pattern-based detector for generic AI-generated prose
Bluesky Ozone labeler adapterQ4 2026Drop-in labeler for AT Protocol moderation pipelines
Compliance presetsQ4 2026Pre-tuned configs for UK OSA, EU DSA, and COPPA requirements

See ROADMAP.md for the full issue backlog and contribution opportunities.


License

MIT License - free for personal and commercial use.

Enterprise licensing with SLA and support available from GLINCKER.


Contributing

See CONTRIBUTING.md for guidelines. We welcome:

  • Bug reports and fixes
  • New language dictionaries
  • Performance improvements
  • Documentation updates

Star History


Frequently asked questions

What is glin-profanity?

glin-profanity is Open-source ML-powered profanity filter with TensorFlow.js toxicity detection, leetspeak & Unicode obfuscation resistance. 21M+ ops/sec, 23 languages, React hooks, LRU caching. npm & PyPI.

How do I install glin-profanity?

Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.

Is glin-profanity open source?

Yes β€” it is hosted on GitHub at https://github.com/glincker/glin-profanity and has 60 stars.

Related MCP tools

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP