Logo Sensitive Lexicon MCP Server

Sensitive Lexicon MCP Server

Cộng đồng
zephyrpersonal

一个基于 [Sensitive-lexicon](https://github.com/konsheng/Sensitive-lexicon) 敏感词库的 MCP (Model Context Protocol) 服务器,为LLM提供敏感词检测和过滤功能。

Nhà phát hànhzephyrpersonal
Kho mãsensitive-lexicon-mcp
Ngôn ngữJavaScript
Bản fork
2
Sao
9
Công cụ có sẵn
4
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Sensitive Lexicon MCP Server cung cấp các chức năng MCP cho các ứng dụng khách AI và tác nhân AI tương thích.

  • 4 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Mẫu cấu hình có thể sao chép ngay

    Dùng các đoạn cấu hình mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Mức độ quan tâm của cộng đồng đến kho mã

    9 sao và 2 bản fork từ kho mã được liên kết.

Sensitive Lexicon MCP Server

MCP Badge

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

功能特性

  • 敏感词检测: 检测文本中的敏感词汇
  • 敏感词过滤: 替换文本中的敏感词汇
  • 多分类支持: 支持政治、色情、暴力、广告等多种敏感词分类
  • 实时更新: 从GitHub仓库实时获取最新的敏感词库
  • 易于集成: 标准MCP协议,易于与各种LLM集成

快速开始

方式一:NPM安装(推荐)

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

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

方式二:源码安装

bash
# 克隆项目
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

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

如果是本地安装:

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

Continue.dev

在 config.json 中添加:

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

Cline (VSCode Extension)

在 VSCode 设置中添加:

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

Zed Editor

在 Zed 的 settings.json 中添加:

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 的设置中添加:

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

Custom MCP Client

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

javascript
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

python
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:

dockerfile
FROM node:18-alpine

WORKDIR /app

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

COPY dist ./dist

EXPOSE 3000

CMD ["npm", "start"]

运行容器:

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

环境变量配置

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

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

# 设置缓存大小
export SENSITIVE_CACHE_SIZE=10000

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

可用工具

1. detect_sensitive_words

检测文本中的敏感词

参数:

  • text (必需): 要检测的文本
  • categories (可选): 指定检测的分类数组

示例:

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

返回结果:

json
{
  "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 (可选): 指定过滤的分类数组

示例:

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

返回结果:

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

3. get_categories

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

返回结果:

json
{
  "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 (可选): 指定分类名称

示例:

json
{
  "category": "political"
}

返回结果:

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

使用示例

在 Claude Desktop 中使用

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

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

在 Continue.dev 中使用

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

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

在编程中集成

javascript
// 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
# 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: 非法网址

开发

bash
# 开发模式运行
npm run dev

# 类型检查
npm run type-check

# 构建
npm run build

技术栈

  • TypeScript
  • Node.js
  • Model Context Protocol (MCP) SDK
  • Sensitive-lexicon 敏感词库

许可证

MIT License

免责声明

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

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

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

Công cụ có sẵn

  • detect_sensitive_words

    Detect sensitive words in text using the Sensitive-lexicon library

  • filter_sensitive_words

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

  • get_categories

    Get list of available sensitive word categories

  • get_word_count

    Get the number of words in the sensitive word database

Dùng MCP Sensitive Lexicon MCP Server với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Sensitive Lexicon MCP Server, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Thiết lập trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Thiết lập trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh thiết lập trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Để tiến trình tiếp tục chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Để tiến trình tiếp tục chạy trong cửa sổ Terminal khi bạn dùng các công cụ MCP.
3

Thêm Sensitive Lexicon MCP Server làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Sensitive Lexicon MCP Server.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "zephyrpersonal-sensitive-lexicon-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "sensitive-lexicon-mcp"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Sensitive Lexicon MCP Server, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Sensitive Lexicon MCP Server.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện trên TypingMind dùng các công cụ MCP đã bật với mô hình AI đã chọn
Bạn có thể dùng Sensitive Lexicon MCP Server giúp tôi làm việc này không?
Sensitive Lexicon MCP Server
Được. Tôi đọc rồi.
Đây là kết quả tôi tìm được bằng Sensitive Lexicon MCP Server.

Câu hỏi thường gặp

Máy chủ MCP Sensitive Lexicon MCP Server dùng để làm gì?

Sensitive Lexicon MCP Server là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Sensitive Lexicon MCP Server với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Sensitive Lexicon MCP Server với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Sensitive Lexicon MCP Server với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Sensitive Lexicon MCP Server, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Sensitive Lexicon MCP Server với TypingMind?

Sensitive Lexicon MCP Server hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Sensitive Lexicon MCP Server cung cấp những công cụ nào trong TypingMind?

Sensitive Lexicon MCP Server cung cấp 4 công cụ MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Sensitive Lexicon MCP Server không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Sensitive Lexicon MCP Server yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇