🔍 MCP-S2xD
人工智能与人类内容来源服务器
](https://go.dev/)    
Production-ready MCP server for detecting AI-generated vs human-written content
______________________________________________________________________
✨ 特性
🛡️ 安全第一
- 速率限制(令牌桶)
- API密钥验证
- 请求大小限制
- 安全标头(CSP、XSS、CORS)
- 平滑关闭
📊 可观测性
- 结构化JSON日志记录(slog)
- 请求ID跟踪
- 指标端点
- 请求持续时间跟踪
- 工具调用统计
🔧 生产就绪
- 基于环境的配置
- 健康和准备状态探头
- 恐慌恢复中间件
- 请求超时
- SQLite持久性(可选)
🤖 AI检测
- 多信号启发式分析
- 统计检测 (熵,n元语法,突发性,Zipf)
- 风格分析
- 代码来源检测
- 批量分析
- 内容指纹识别
______________________________________________________________________
🚀 快速开始
# Clone and run
git clone https://github.com/AdhiDevX369/MCP-S2xD.git
cd MCP-S2xD
go mod tidy
go run ./cmd/server服务器启动时间 http://localhost:3000
验证安装
# Health check
curl http://localhost:3000/health
# List available tools
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'______________________________________________________________________
📡 api参考
端点
| 端点 | 方法 | 描述 |
|---|---|---|
/health | GET | 健康检查 |
/ready | GET | 准备状态探测 |
/metrics | GET | 服务器指标(请求、错误、工具调用) |
/mcp | POST | JSON-RPC 2.0 MCP端点 |
MCP方法
| 方法 | 说明 |
|---|---|
tools/list | 列出所有具有模式的可用工具 |
tools/call | 使用参数执行工具 |
示例:分析内容来源
// Request
{
"jsonrpc": "2.0",
"id": "req-42",
"method": "tools/call",
"params": {
"tool": "analyze_origin",
"input": {
"text": "Furthermore, it is important to note that the implementation follows best practices.",
"source_hint": "documentation"
}
}
}
// Response
{
"jsonrpc": "2.0",
"id": "req-42",
"result": {
"output": {
"origin": "ai_system",
"confidence": 0.85,
"explanation": "AI indicators detected: [hedging_language, uniform_sentence_length]",
"signals": ["hedging_language", "uniform_sentence_length"],
"word_count": 12,
"timestamp": "2025-11-26T09:00:00Z"
}
}
}示例:统计检测
// Request - Comprehensive statistical analysis
{
"jsonrpc": "2.0",
"id": "stat-1",
"method": "tools/call",
"params": {
"tool": "statistical_detect",
"arguments": {
"input": {
"text": "It is important to note that in the evolving landscape of AI..."
}
}
}
}
// Response
{
"jsonrpc": "2.0",
"id": "stat-1",
"result": {
"output": {
"origin": "ai_system",
"confidence": 0.78,
"weighted_score": 0.42,
"signals": ["ai_phrases", "uniform_structure", "zipf_deviation"],
"entropy_result": { "average_entropy": 3.2, "origin": "ai_system" },
"ngram_result": { "ai_phrases_found": ["it is important to note"], "origin": "ai_system" },
"burstiness_result": { "burstiness_score": 0.18, "origin": "ai_system" },
"zipf_result": { "r_squared": 0.72, "origin": "ai_system" }
}
}
}示例:熵分析
// Request
{
"jsonrpc": "2.0",
"id": "ent-1",
"method": "tools/call",
"params": {
"tool": "entropy_analyze",
"arguments": {
"input": { "text": "Your text to analyze..." }
}
}
}
// Response
{
"jsonrpc": "2.0",
"id": "ent-1",
"result": {
"output": {
"origin": "human",
"confidence": 0.72,
"char_entropy": 4.23,
"word_entropy": 4.56,
"bigram_entropy": 4.89,
"average_entropy": 4.56,
"explanation": "High entropy indicates natural human variation."
}
}
}______________________________________________________________________
🧰 工具目录
岩芯检测工具
| 工具 | 描述 | 用例 |
|---|---|---|
analyze_origin | 深度人工智能/人类检测,采用多种启发式方法 | 内容审核、作者验证 |
batch_analyze | 分析多个样本,获取汇总统计数据 | 数据集分析,批量处理 |
content_fingerprint | SHA256哈希+结构哈希 | 来源跟踪、重复数据删除 |
compare_texts | 风格相似性和来源比较 | 抄袭检测、作者匹配 |
code_origin | 专业代码分析 | 代码审查、AI辅助代码检测 |
style_profile | 生成作者身份指标 | 作家分析、风格分析 |
统计检测工具
| 工具 | 描述 | 关键指标 |
|---|---|---|
entropy_analyze | 计算文本熵模式 | 字符、单词、二元组熵 |
ngram_analyze | 检测AI短语和重复模式 | AI短语检测,n元语法频率 |
burstiness_analyze | 测量文本一致性 | 句子/单词长度差异 |
zipf_analyze | 检查自然语言分布 | Zipf的法律合规性,R²评分 |
statistical_detect | 所有统计方法的集合 | 加权多信号分析 |
实用工具
| 工具 | 说明 |
|---|---|
dummy_echo | 用于测试的回声输入 |
检测信号
Statistical Signals Heuristic Signals
───────────────────────────── ─────────────────────────────
• Low entropy (repetitive) • Uniform sentence length
• AI-typical phrases • Transition word density
• Uniform burstiness • Hedging language
• Zipf's law deviation • Structured lists
• N-gram repetition • Explicit AI mentions
Human Indicators
─────────────────────────────
• High entropy (varied)
• Natural burstiness
• Zipf-compliant distribution
• Common typos
• Informal contractions统计方法深潜
熵分析
使用香农熵在字符、单词和二元组级别测量信息密度。
- 低熵(\4.5) → 自然变化→ 人类可能
N-gram分析
检测过度使用的AI短语和重复模式。
- 扫描40多个已知的人工智能典型短语(“重要的是要注意”、“总结”等)
- 测量n克重复率
- 检测综合评分
爆裂性分析
使用变异系数衡量句子/单词长度的差异。
- 爆炸性低(\0.5) → 自然变化→ 人类可能
齐夫定律分析
自然语言遵循Zipf分布(词频≠1/秩)。
- 在对数频率图上计算线性回归
- R²\0.9 → 符合天然Zipf标准→ 人类可能
______________________________________________________________________
⚙️ 配置
通过环境变量进行的所有设置:
# Server
SERVER_PORT=:3000
SERVER_READ_TIMEOUT=10s
SERVER_WRITE_TIMEOUT=30s
SERVER_SHUTDOWN_TIMEOUT=15s
# Security
SECURITY_API_KEY_ENABLED=false
SECURITY_API_KEY=your-secret-key
SECURITY_RATE_LIMIT_RPS=100
SECURITY_MAX_REQUEST_SIZE=1048576
# Logging
LOG_LEVEL=info # debug, info, warn, error
LOG_FORMAT=json # json, text
# Database (optional)
DATABASE_PATH=data/mcp.db看 .env.example 供充分参考。
______________________________________________________________________
📁 项目结构
mcp-s2xd/
├── cmd/server/ # Entry point
├── internal/
│ ├── config/ # Environment configuration
│ ├── httpserver/ # HTTP server with middleware
│ ├── logger/ # Structured logging (slog)
│ ├── mcp/ # JSON-RPC handler
│ ├── metrics/ # Request & tool metrics
│ ├── middleware/ # Security middleware stack
│ ├── rpcerror/ # Centralized error types
│ ├── storage/ # Attestation persistence
│ └── tools/ # MCP tool implementations
├── .env.example
├── go.mod
└── README.md______________________________________________________________________
🔒 安全中间件栈
Request → Rate Limit → API Key Auth → Max Body Size → CORS → Security Headers → Handler| 中间件 | 用途 |
|---|---|
Recovery | 恐慌恢复,防止撞车 |
RequestID | X-Request-ID标头跟踪 |
Logging | 结构化请求日志记录 |
RateLimit | 令牌桶速率限制 |
APIKeyAuth | 可选API密钥验证 |
MaxBodySize | 请求大小限制 |
CORS | 跨源资源共享 |
SecurityHeaders | CSP、XSS、帧选项 |
Timeout | 请求上下文超时 |
______________________________________________________________________
📈 指标
curl http://localhost:3000/metrics{
"uptime_seconds": 3600,
"total_requests": 1250,
"total_errors": 3,
"avg_duration_ms": 2.5,
"tool_calls": {
"analyze_origin": 800,
"code_origin": 300,
"compare_texts": 150
}
}______________________________________________________________________
🤝 贡献
- 复刻仓库
- 创建要素分支:
git checkout -b feature/amazing-feature - 提交更改:
git commit -m 'Add amazing feature' - 推送到分支:
git push origin feature/amazing-feature - 打开拉取请求
______________________________________________________________________
📚 资源
协议规范
| 资源 | 描述 |
|---|---|
| 模型上下文协议 | MCP官方规范 |
| MCP TypeScript SDK | 参考实施 |
| JSON-RPC 2.0 | 传输协议规范 |
人工智能检测研究
Go文档
______________________________________________________________________
内置于❤️ 值得信赖的人工智能生态系统
](https://github.com/AdhiDevX369) 
