MCP预处理工具车间
全面的 MCP兼容工具平台 为文档处理、NLP、取证、矢量数据库等提供80多种预处理和分析工具。特性 多店铺架构 (MySQL+PostgreSQL+Neo4j+Chroma+Redis+Directus)针对高并发操作和复杂证据分析进行了优化。
🎯 这个平台做什么
该平台作为 集中式工具网关 在数据流到下游系统(数据库、编排代理或最终存储)之前,会进行大量的计算工作。把它想象成“家得宝的预处理工具”——一个组织良好的工具包,代理人可以发现和使用。
核心能力
完全实施:
- 📄 文档处理 -Pandoc转换、Tesseract OCR、文本分割
- 🔍 搜索 -ripgrep/ugrep与JSON输出和JavaScript回退的集成
- 🧠 自然语言处理 -实体提取、情感分析、关键字提取、语言检测
- 🔐 法医学 -使用SHA-256哈希的加密证据保管链
- 📊 矢量数据库 -Chroma(72小时TTL工作记忆),支持pgvector
- 📚 库工具 -Cheerio、XML、JSON5、YAML、CSV、Natural.js、折衷
- 🗄️ 模式管理 -使用完整的CRUD存储和管理行为模式
- ⚙️ 设置管理 -配置LLM提供程序、数据库、工作流
部分实施(需要外部服务):
- 🤖 ML/嵌入、图形数据库(Neo4j+Graphiti)、Python桥
- 🌐 浏览器搜索(混乱/困惑)、工作流自动化(n8n)
- 📝 摘要(需要LLM API)、NotebookLM集成
📦 快速开始
先决条件
- Node.js 22+
- pnpm 10+
- (可选)ripgrep、ugrep、Pandoc、Tesseract以获得完整的插件支持
安装
# Install dependencies
pnpm install
# Push database schema
pnpm db:push
# Start development server
pnpm dev该平台将在 http://localhost:3000
环境变量
创建 .env 文件包含:
# Database
DATABASE_URL=your_database_url
# Authentication (optional)
JWT_SECRET=your_secret
OAUTH_SERVER_URL=your_oauth_url
# External APIs (optional)
BUILT_IN_FORGE_API_URL=http://your-vps
BUILT_IN_FORGE_API_KEY=your_key🏗️ 建筑
三层设计
┌─────────────────────────────────────────────────────────────┐
│ External Agents │
│ (Claude, ChatGPT, Gemini, Custom Agents) │
└────────────────────┬────────────────────────────────────────┘
│ MCP Protocol
▼
┌─────────────────────────────────────────────────────────────┐
│ MCP Gateway Layer │
│ • Tool Discovery (80+ tools across 10 categories) │
│ • Tool Invocation (execute with parameters) │
│ • Content References (SHA-256 based storage) │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Plugin Execution Layer │
│ • 26 plugin modules (13,265 lines) │
│ • JavaScript & Python providers │
│ • Content-addressed storage │
│ • Forensic chain of custody │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Storage Layer │
│ • Chroma (72-hour TTL working memory) │
│ • PostgreSQL (37 extensions: pgvector, postgis, etc.) │
│ • MySQL (structured data via Drizzle) │
│ • Neo4j + Graphiti (temporal knowledge graphs) │
│ • Directus (file vault with forensic integrity) │
│ • Redis/Dragonfly (caching) │
└─────────────────────────────────────────────────────────────┘PostgreSQL扩展(共37个)
核心(2): plpgsql、uuid ossp
密码学与安全(1): pgcrypto
矢量搜索(1): 矢量(pgvector)
文本搜索和处理(4): pg_trgm、citext、unscent、模糊格式
索引(4): btree_gin,btree_gist,bloom,hypg
数据类型(2): hstore, 树
PostGIS套件(8): postgis、postgis_raster、postgi_sfcgal、postgis.tiger_geocoder、postgis-topology、地址标准化器、地址标准数据、pgrouting
监控与审计(2): pg_stat_语句,pgaudit
作业调度(2): pg_cron、pgmq
Webhooks(1): pg_net
外部数据包装器(2): dblink、postgres_fdw
JSON验证(1): pg_json模式
公用事业(5): 小报、intarray、moddatetime、杀虫剂、TCN
Graphiti+Neo4j集成
格拉菲蒂 是一个时态知识图库,充当Neo4j之上的中间件层,提供:
- 实体提取 -自动从文本中提取
- 时间跟踪 -跟踪关系如何随时间变化
- 矛盾检测 -自动查找冲突索赔
- 社区发现 -确定相关实体的集群
- 事实版本控制 -历史关系跟踪
架构:
Graphiti Library (Middleware)
├── Entity Extractor (LLM-powered)
├── Relationship Builder
├── Temporal Tracker
├── Contradiction Detector
└── Neo4j Driver
↓
Neo4j Database🔧 API使用
MCP网关端点
该平台公开了一个具有以下端点的标准MCP网关:
1.列出可用工具
const tools = await trpc.mcp.listTools.query({
category: "document", // optional: filter by category
limit: 50
});
// Returns: [{ name, category, description, tags, inputSchema }]2.语义搜索工具
const results = await trpc.mcp.searchTools.query({
query: "extract entities from text",
topK: 10
});
// Returns: Tools ranked by relevance3.调用工具
const result = await trpc.mcp.invokeTool.mutate({
toolName: "doc.ocr_image_or_pdf",
args: {
path: "/data/document.pdf",
language: "eng"
}
});
// Returns: { success: true, data: { ... } }📚 工具类别
| 类别 | 工具计数 | 描述 |
|---|---|---|
| 文件 | 15+ | Pandoc转换、OCR、文本提取、分割 |
| 搜索 | 8+ | ripgrep、ugrep、BM25检索、相似性搜索 |
| 自然语言处理 | 12+ | 实体提取、情感、关键字、语言检测 |
| 矢量数据库 | 10+ | 色度、pgvector运算 |
| 法医学 | 6+ | 证据散列、监管链、验证 |
| 图书馆 | 15+ | Cheerio、XML、JSON5、YAML、Natural.js、折衷 |
| 差异 | 4+ | 文本比较、相似性分析 |
| 毫升 | 8+ | 嵌入、语义搜索(需要设置) |
| 图形数据库 | 6+ | Neo4j/Graphiti操作(需要设置) |
| 浏览器 | 5+ | 搜索API(需要API密钥) |
🎨 用户界面
包含的页面
- 家 (
/)-带有工具类别和快速入门的登录页面 - 设置 (
/settings)-配置LLM提供程序、数据库、工作流 - 工具 (
/tools)-交互式浏览、搜索和测试工具 - 模式库 (
/patterns)-管理行为模式(UI就绪,需要后端连接)
🗄️ 数据库模式
该平台包括18个综合表:
核心表:
users,apiKeys,apiKeyUsageLogsbehavioralPatterns,patternCategoriesworkflows,workflowTemplatessystemPrompts,severityWeights
文档智能:
documents,documentSections,documentChunksdocumentSpans,documentSummaries,documentEntities
证据管理:
evidenceChains,hurtlexTerms,mclFactors
配置:
bertConfigs,forensicResults,schemaResolvers
🧪 测试
# Run all tests
pnpm test
# Type checking
pnpm check
# Code formatting
pnpm format📖 项目结构
├── client/ # Frontend React application
├── server/ # Backend Node.js/TypeScript server
│ ├── mcp/ # MCP Gateway logic and plugins
│ └── python-tools/ # Python-based ML and NLP utilities
├── shared/ # Shared TypeScript types and constants
├── docs/ # Project documentation (organized by category)
├── deploy/ # Deployment configurations and guides
│ └── salem-trinity/ # Master 3-VPS deployment suite
├── scripts/ # Maintenance and utility scripts
├── config/ # Configuration files
├── data/ # Local data storage and SQLite databases
└── n8n-workflows/ # Exported n8n workflow definitionsMCP网关API(4个端点)
| 端点 | 目的 | 令牌效率 |
|---|---|---|
search_tools | 发现可用工具 | 返回紧凑型工具卡(名称、类别、标签) |
describe_tool | 获取完整的工具规范 | 按需加载模式和示例 |
invoke_tool | 执行工具 | 大型输出的基于引用的返回 |
get_ref | 检索内容 | 分页检索(默认4KB页面) |
内容寻址存储
所有大型工件都使用SHA-256内容哈希存储,从而实现:
- 去重:相同内容存储一次
- 分页:令牌高效检索大型结果
- 缓存:针对重复操作的内容寻址查找
人类在循环(HITL)
所有破坏性操作都需要批准:
- 拟议变更的预览
- Diff可视化
- 通过内容存储实现回滚功能
- 审核日志记录
LLM提供商支持
与提供商无关的设计支持:
- 奥拉玛 (云托管或本地)
- 双子座 (2.5 Flash/Pro)
- 开放路由 (免费型号)
- 开放人工智能 / Anthropic
- 当地BERT (句子转换)
🚀 用例
该平台可用于:
- 文件预处理 -转换、OCR和从文档中提取结构
- 法医分析 -维护加密证据链
- NLP管道 -提取实体、分析情绪、检测模式
- 向量搜索 -跨文档集合的语义搜索
- 行为分析 -检测通信中的模式
- 多代理编排 -为AI代理提供预处理工具
🔐 安全特性
- 证据保管链 -带验证的SHA-256哈希
- API密钥管理 -具有使用情况跟踪功能的加密存储
- 审计日志 -全面的活动跟踪
- 沙盒操作 -受控文件系统访问
🚢 部署架构
有关VPS部署的详细信息(salem-nexus/salem-forge),请参阅 部署.md 和 主部署指南
多VPS“三一”架构:
- VPS1(Nexus):PostgreSQL(37个扩展)、Directus、PhotoPrism、n8n、Coolify
- VPS2(Forge):LiteLLM、MetaMCP、ChromaDB(72小时TTL)、Ollama、Kasm、FerretDB
- VPS3(主):MySQL,主要应用程序后端
文档结构
项目文件分为以下几类 docs/ 目录:
📄 许可证
麻省理工学院
🤝 贡献
这是一个积极的发展项目。核心预处理功能已准备好投入生产,而外部集成(Python桥、云服务)正在开发中。
当前状态:
- ✅ 60-70%已实施(核心功能已完成)
- ✅ MCP网关功能齐全
- ✅ 26个插件,159个导出函数
- 🟡 正在进行外部服务集成
有关更多详细信息,请参阅 PROJECT_STATUS.md 对于当前的实施状态。
