Skip to main content
Glama
zephyrpersonal

sensitive-lexicon-mcp

Sensitive Lexicon MCP Server

MCP Badge

一个基于 Sensitive-lexicon 敏感词库的 MCP (Model Context Protocol) 服务器,为LLM提供敏感词检测和过滤功能。

功能特性

  • 敏感词检测: 检测文本中的敏感词汇

  • 敏感词过滤: 替换文本中的敏感词汇

  • 多分类支持: 支持政治、色情、暴力、广告等多种敏感词分类

  • 实时更新: 从GitHub仓库实时获取最新的敏感词库

  • 易于集成: 标准MCP协议,易于与各种LLM集成

Related MCP server: chuangsiai-mcp

快速开始

方式一:NPM安装(推荐)

# 全局安装
npm install -g sensitive-lexicon-mcp

# 或项目本地安装
npm install sensitive-lexicon-mcp

方式二:源码安装

# 克隆项目
git clone https://github.com/zephyrpersonal/sensitive-lexicon-mcp.git
cd sensitive-lexicon-mcp

# 安装依赖
npm install

# 构建项目
npm run build

集成配置

Claude Desktop

在 Claude Desktop 的配置文件中添加:

Windows: %APPDATA%\Claude\claude_desktop_config.json macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "sensitive-lexicon": {
      "command": "npx",
      "args": ["sensitive-lexicon-mcp"]
    }
  }
}

如果是本地安装:

{
  "mcpServers": {
    "sensitive-lexicon": {
      "command": "node",
      "args": ["./path/to/sensitive-lexicon-mcp/dist/index.js"]
    }
  }
}

Continue.dev

config.json 中添加:

{
  "mcpServers": [
    {
      "name": "sensitive-lexicon",
      "command": "npx",
      "args": ["sensitive-lexicon-mcp"]
    }
  ]
}

Cline (VSCode Extension)

在 VSCode 设置中添加:

{
  "cline.mcpServers": {
    "sensitive-lexicon": {
      "command": "npx",
      "args": ["sensitive-lexicon-mcp"]
    }
  }
}

Zed Editor

在 Zed 的 settings.json 中添加:

{
  "language_models": {
    "anthropic": {
      "version": "1",
      "api_url": "https://api.anthropic.com",
      "mcp_servers": {
        "sensitive-lexicon": {
          "command": "npx",
          "args": ["sensitive-lexicon-mcp"]
        }
      }
    }
  }
}

Cursor IDE

在 Cursor 的设置中添加:

{
  "mcp.servers": {
    "sensitive-lexicon": {
      "command": "npx",
      "args": ["sensitive-lexicon-mcp"]
    }
  }
}

Custom MCP Client

如果您使用自定义的MCP客户端,可以这样连接:

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';

const transport = new StdioClientTransport({
  command: 'npx',
  args: ['sensitive-lexicon-mcp']
});

const client = new Client({
  name: "sensitive-lexicon-client",
  version: "1.0.0"
}, {
  capabilities: {}
});

await client.connect(transport);

Python MCP Client

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

async def main():
    server_params = StdioServerParameters(
        command="npx",
        args=["sensitive-lexicon-mcp"]
    )
    
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            # 初始化
            await session.initialize()
            
            # 调用工具
            result = await session.call_tool(
                "detect_sensitive_words", 
                {"text": "测试文本"}
            )
            print(result)

Docker 部署

创建 Dockerfile:

FROM node:18-alpine

WORKDIR /app

COPY package*.json ./
RUN npm ci --only=production

COPY dist ./dist

EXPOSE 3000

CMD ["npm", "start"]

运行容器:

docker build -t sensitive-lexicon-mcp .
docker run -p 3000:3000 sensitive-lexicon-mcp

环境变量配置

您可以通过环境变量自定义配置:

# 设置敏感词库更新间隔(秒)
export SENSITIVE_UPDATE_INTERVAL=3600

# 设置缓存大小
export SENSITIVE_CACHE_SIZE=10000

# 启用调试日志
export DEBUG=sensitive-lexicon:*

可用工具

1. detect_sensitive_words

检测文本中的敏感词

参数:

  • text (必需): 要检测的文本

  • categories (可选): 指定检测的分类数组

示例:

{
  "text": "这是一段测试文本",
  "categories": ["political", "violence"]
}

返回结果:

{
  "isSensitive": true,
  "sensitiveWordsCount": 2,
  "sensitiveWords": [
    {"word": "敏感词1", "category": "political"},
    {"word": "敏感词2", "category": "violence"}
  ],
  "summary": "Found 2 sensitive word(s) in the text"
}

2. filter_sensitive_words

过滤文本中的敏感词

参数:

  • text (必需): 要过滤的文本

  • replacement (可选): 替换字符串,默认为 "***"

  • categories (可选): 指定过滤的分类数组

示例:

{
  "text": "这是一段测试文本",
  "replacement": "[已屏蔽]",
  "categories": ["political"]
}

返回结果:

{
  "originalText": "这是一段测试文本",
  "filteredText": "这是一段[已屏蔽]文本",
  "isSensitive": true,
  "sensitiveWordsFound": 1,
  "sensitiveWords": [
    {"word": "测试", "category": "political"}
  ]
}

3. get_categories

获取可用的敏感词分类列表

返回结果:

{
  "categories": [
    "covid19", "gfw", "other", "subversive", 
    "advertisement", "political", "violence", 
    "livelihood", "weapons", "pornography-type", 
    "pornography", "supplementary", "corruption", 
    "tencent", "illegal-urls"
  ],
  "totalCategories": 15
}

4. get_word_count

获取敏感词库中的词汇数量

参数:

  • category (可选): 指定分类名称

示例:

{
  "category": "political"
}

返回结果:

{
  "category": "political",
  "wordCount": 1500
}

使用示例

在 Claude Desktop 中使用

配置完成后,您可以在 Claude Desktop 中直接使用:

请帮我检测这段文本是否包含敏感词:"这是一段需要检测的文本内容"
请帮我过滤这段文本中的敏感词,并用[已屏蔽]替换:"这是一段需要过滤的文本内容"

在 Continue.dev 中使用

在代码注释或文档中检测敏感词:

// 检查这个变量名是否包含敏感词
@sensitive-check 检测这个函数名:getUserPoliticalInfo

在编程中集成

// Node.js 示例
const { spawn } = require('child_process');

function detectSensitiveWords(text) {
  return new Promise((resolve, reject) => {
    const child = spawn('npx', ['sensitive-lexicon-mcp']);
    
    child.stdin.write(JSON.stringify({
      method: 'tools/call',
      params: {
        name: 'detect_sensitive_words',
        arguments: { text }
      }
    }));
    
    child.stdout.on('data', (data) => {
      resolve(JSON.parse(data));
    });
    
    child.stderr.on('data', (data) => {
      reject(new Error(data.toString()));
    });
  });
}

批量处理示例

# Python 批量处理示例
import asyncio
import json
from mcp.client.stdio import stdio_client

async def batch_check_content(texts):
    server_params = StdioServerParameters(
        command="npx",
        args=["sensitive-lexicon-mcp"]
    )
    
    results = []
    async with stdio_client(server_params) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()
            
            for text in texts:
                result = await session.call_tool(
                    "detect_sensitive_words",
                    {"text": text}
                )
                results.append({
                    "text": text,
                    "result": result
                })
    
    return results

# 使用示例
texts = ["文本1", "文本2", "文本3"]
results = asyncio.run(batch_check_content(texts))
for item in results:
    print(f"文本: {item['text']}")
    print(f"结果: {item['result']}")

敏感词分类

支持以下敏感词分类:

  • covid19: COVID-19相关

  • gfw: GFW补充词库

  • other: 其他词库

  • subversive: 反动词库

  • advertisement: 广告类型

  • political: 政治类型

  • violence: 暴恐词库

  • livelihood: 民生词库

  • weapons: 涉枪涉爆

  • pornography-type: 色情类型

  • pornography: 色情词库

  • supplementary: 补充词库

  • corruption: 贪腐词库

  • tencent: 腾讯相关

  • illegal-urls: 非法网址

开发

# 开发模式运行
npm run dev

# 类型检查
npm run type-check

# 构建
npm run build

技术栈

  • TypeScript

  • Node.js

  • Model Context Protocol (MCP) SDK

  • Sensitive-lexicon 敏感词库

许可证

MIT License

免责声明

本项目仅用于学习和研究目的。使用者需要根据当地法律法规和平台政策合规使用。敏感词的定义可能因业务场景而异,请根据具体需求进行调整。

Available Tools

4 tools
detect_sensitive_wordsB

Detect sensitive words in text using the Sensitive-lexicon library

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesThe text to check for sensitive words
categoriesNoOptional: specific categories to check (e.g., ["political", "violence"])

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description bears full responsibility for behavioral disclosure. It mentions detection using a library but does not specify the return format, side effects, or whether it is read-only.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that efficiently communicates the core purpose without extraneous details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple with two parameters, and the description provides minimal context. However, it omits details about the return value, which may reduce completeness for an agent needing to interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already describes both parameters with 100% coverage. The description adds no extra meaning beyond the schema, so a baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool detects sensitive words in text and specifies the library used. It distinguishes from siblings like filter_sensitive_words and get_categories by its focus on detection.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like filter_sensitive_words. The description lacks context about appropriate usage scenarios or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

filter_sensitive_wordsB

Filter sensitive words from text by replacing them with a replacement string

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesThe text to filter
replacementNoString to replace sensitive words with (default: "***")***
categoriesNoOptional: specific categories to filter (e.g., ["political", "violence"])

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It states replacement but omits details: case sensitivity, what happens with no matches, whether it modifies original text, or if all categories are used when not specified. Minimal behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One sentence (12 words) with no filler. Action, resource, and mechanism are front-loaded. Every word contributes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema, but description does not mention what is returned (presumably filtered text). Sibling tools exist but no guidance on workflow. For a 3-parameter tool with optional categories, this incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds no new meaning beyond schema: 'replacement string' is already in schema for replacement param. No extra clarity for categories or text.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Filter sensitive words from text by replacing them with a replacement string'. It distinguishes from siblings: detect_sensitive_words detects only, get_categories lists categories, get_word_count counts words. Verb+resource is specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives. The description does not mention prerequisites, exclusions, or context. Implicitly, it is for cleaning text, but explicit comparison to siblings is missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_categoriesB

Get list of available sensitive word categories

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose any behavioral traits beyond the obvious retrieval action. It adds no information about side effects, permissions, or other important behaviors.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, straightforward sentence that is concise and front-loaded. However, it could be slightly more informative without sacrificing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has no parameters and no output schema, the description is adequate but minimal. It does not explain what a 'category' looks like or any constraints, which could cause confusion.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

There are no parameters, so the baseline score is 4. The description does not need to add parameter semantics since none exist.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('list of available sensitive word categories'), and it distinguishes this tool from its siblings which handle detection, filtering, and counting of sensitive words.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like detect_sensitive_words or filter_sensitive_words, and lacks any context or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_word_countB

Get the number of words in the sensitive word database

ParametersJSON Schema
NameRequiredDescriptionDefault
categoryNoOptional: get count for specific category only

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must disclose behavioral traits. It only states what the tool does, but fails to mention whether it is a read-only operation, what the count format is (e.g., unique or total words), or any authentication requirements. This lack of detail requires the agent to infer too much.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no unnecessary words. It is appropriately sized for a simple tool, though it could benefit from slight restructuring to include usage context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is adequate for a simple tool with one optional parameter and no output schema. However, it lacks explanation of the return value (e.g., integer count) and does not help the agent differentiate from siblings, making it minimally complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage (the parameter 'category' is described as 'Optional: get count for specific category only'). The tool description does not add additional meaning beyond the schema, so it meets the baseline expectation but adds no extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get the number of words in the sensitive word database' clearly specifies the action (get) and the resource (number of words). It is precise and distinguishes itself from sibling tools like detect_sensitive_words and get_categories, which have different purposes.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as detect_sensitive_words or filter_sensitive_words. It also does not explain when to use the optional category parameter, leaving the agent without context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a clear, non-overlapping purpose: detect sensitive words, filter them, retrieve categories, and get word count. No ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern using snake_case, e.g., detect_sensitive_words and get_categories.

Tool Count5/5

Four tools is an appropriate scope for a sensitive lexicon server, covering detection, filtering, and metadata without bloat.

Completeness4/5

The set covers core operations (detection, filtering, metadata). Missing may be lexicon management (add/remove words), but not essential for delivery.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time content safety protection for large language models by detecting and preventing risks in both input and output content across multiple dimensions including compliance, ethics, and security.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time content security for large language models by identifying and intercepting risks across compliance, ethics, and safety dimensions. It enables secure input and output monitoring through a customizable policy engine using an SSE-based interface.
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    AI-powered sensitive info detection and masking MCP server supporting 14+ types with regex, checksum, and optional LLM semantic detection, enabling flexible masking strategies like mask, replace, hash, and redact.
    6
    MIT

Latest Blog Posts

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/zephyrpersonal/sensitive-lexicon-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server