Skip to main content
Glama
enterprise-knowledge-integrator

enterprise-knowledge-integrator

by Enesp4rl4k

🧠 Enterprise Knowledge Integrator

将企业私有数据(PDF、Excel、Word、SQL)连接到 LLM 与 AI 智能体,内置 PII 脱敏、混合搜索与 MCP 服务器。

License: MIT Python 3.9+ FastAPI Model Context Protocol PRs Welcome

实时仪表盘 • 快速上手 • MCP 服务器设置 • 架构 • API 参考


🌟 为什么选择 Enterprise Knowledge Integrator?

企业的知识分散在 PDF 政策文档、Excel/CSV 财务模型、合同和 ERP 笔记中。将这些数据直接输入 LLM 往往会导致 PII 泄露、数字幻觉和上下文丢失。

Enterprise Knowledge Integrator 是一个开源、轻量级、即插即用的中间件,可将您公司的原始文件转换为干净、带引用且安全的上下文,供任何 LLM 或 AI 智能体使用。


Related MCP server: nacre

✨ 核心特性

  • 📄 表格感知 ETL(Excel 与 CSV):将电子表格行转换为 Markdown 表格和语义行分组,使 LLM 永远不会对行号或公式产生幻觉。

  • 🛡️ 内置 PII 与密钥脱敏器:在嵌入或提示注入之前自动检测并掩码 TCKN、IBAN、信用卡号、税号(VKN)、电话号码和 API 密钥。

  • ⚡ 混合检索(向量 + Okapi BM25 + RRF):使用倒数排名融合(RRF)将密集嵌入与稀疏关键词匹配相结合,对财务代码和数字实现 100% 准确率。

  • 👥 基于角色的访问控制(RBAC):强制执行文档密级(Public、Internal、Confidential、Restricted)和部门过滤。

  • 🔍 引用与幻觉验证器:自动将生成的 LLM 答案与源文档进行核对,并计算置信度分数。

  • 🔄 目录自动监视器:监控您的文件夹/云盘挂载,并自动重新索引新增或修改的文件。

  • 🔌 通用网关:

    • Model Context Protocol(MCP),适用于 Cursor、Claude Desktop、Antigravity。

    • FastAPI REST API,带 Swagger UI。

    • 交互式 Web 仪表盘(零额外依赖)。

    • LangChain / LangGraph 工具适配器。


🏛️ 系统架构

graph TD
    subgraph Ingestion ["1. Multi-Source Ingestion & ETL"]
        F1["📄 Documents (PDF, Word, Markdown)"]
        F2["📊 Tabular (Excel, CSV)"]
        F3["🗄️ Notes & Text Snippets"]
        F1 & F2 & F3 --> PII["🛡️ PII Masker (TCKN, IBAN, Cards)"]
        PII --> Chunk["✂️ Semantic & Parent-Child Chunker"]
    end

    subgraph Storage ["2. Storage & Hybrid Search Engine"]
        Chunk --> V["V-Store: Cosine Dense Embeddings"]
        Chunk --> B["BM25: Sparse Keyword Index"]
        V & B --> RRF["🎯 Reciprocal Rank Fusion (RRF)"]
    end

    subgraph Governance ["3. Security & Governance"]
        RRF --> RBAC["👥 RBAC & Clearance Filter"]
        RBAC --> Val["🔍 Citation & Grounding Validator"]
    end

    subgraph Interfaces ["4. LLM & Agent Gateways"]
        Val --> MCP["⚡ MCP Server (Claude Desktop / Cursor)"]
        Val --> API["🌐 FastAPI REST API (/api/v1/context)"]
        Val --> UI["🖥️ Modern Web Dashboard (/dashboard)"]
        Val --> SDK["💼 LangChain / LangGraph Adapter"]
    end

⚡ 60 秒快速上手

1. 安装

git clone https://github.com/your-username/enterprise-knowledge-integrator.git
cd enterprise-knowledge-integrator
pip install -r requirements.txt

2. 启动 Web 仪表盘与 API

python -m knowledge_integrator.interfaces.api.app

在浏览器中打开 http://localhost:8088/dashboard 以访问可视化控制面板。


💻 CLI 用法

摄取文本/政策说明:

python -m knowledge_integrator.interfaces.cli.main ingest-text \
  --title "2025 Travel Policy" \
  --content "Daily travel allowance is 2,500 TL. Stays above 5,000 TL require CFO approval." \
  --category "policy"

摄取文件或目录(PDF、Excel、CSV、Word、Markdown):

python -m knowledge_integrator.interfaces.cli.main ingest ./company_docs/ --category "finance"

搜索知识库:

python -m knowledge_integrator.interfaces.cli.main query "What is the travel budget limit?"

列出已索引文档:

python -m knowledge_integrator.interfaces.cli.main list

⚡ Model Context Protocol(MCP)服务器

将您的企业知识直接连接到 Claude Desktop、Cursor IDE 或 Antigravity。

将此添加到您的 claude_desktop_config.json 或 cursor settings:

{
  "mcpServers": {
    "company-knowledge": {
      "command": "python",
      "args": ["-m", "knowledge_integrator.interfaces.cli.main", "serve-mcp"]
    }
  }
}

可用 MCP 工具:

  • search_company_knowledge:对私有公司文档执行混合搜索。

  • get_company_context:返回干净、带引用的上下文,可直接用于提示注入。

  • list_company_documents:列出所有已索引的来源和元数据。

  • ingest_company_note:动态保存新的政策或知识片段。


🌐 REST API 参考

方法

端点

描述

POST

/api/v1/ingest/file

上传并索引文件(PDF、Excel、CSV、Word、MD)

POST

/api/v1/ingest/text

摄取原始企业笔记或规则

POST

/api/v1/context

获取带引用的、可直接用于 LLM 的上下文块

POST

/api/v1/search

搜索排序后的分块(混合)

GET

/api/v1/documents

列出所有已索引文档

DELETE

/api/v1/documents/{id}

删除文档及所有关联的嵌入

交互式 Swagger 文档位于:http://localhost:8088/docs


🤖 Python 与 LangChain / LangGraph 集成

from knowledge_integrator import KnowledgeEngine
from knowledge_integrator.agentic_cfo_adapter import AgenticCFOKnowledgeAdapter

# 1. Initialize engine
engine = KnowledgeEngine()

# 2. Ingest document
engine.ingest_file("budget_2025.xlsx", category="finance")

# 3. Retrieve LLM context
ctx = engine.get_context_for_llm("What was the Q3 software budget?")
print(ctx.context_text)

# 4. Use as a LangChain / LangGraph Tool for AI Agents
adapter = AgenticCFOKnowledgeAdapter(engine)
agent_tool = adapter.as_langchain_tool()

🐳 Docker 部署

docker-compose up -d

🧪 运行测试

python -m pytest knowledge_integrator/tests/ -v

📄 许可证

本项目采用 MIT 许可证授权 — 详情请参阅 LICENSE 文件。

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables document ingestion, semantic search, and retrieval-augmented generation via MCP tools and REST API, using vector embeddings and intelligent chunking.
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Provides a self-hosted knowledge index with document-level permissions, enabling AI agents to retrieve exactly the documents they are authorized to see via MCP. Supports OAuth 2.1, custom embedding models, and runs inside your network.
    23 npm
    2
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to query and manage a document knowledge base via MCP, with RAG-powered search and grounded answers with citations.
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to securely search and list internal company documents via MCP tools, so they can answer employee questions based on current internal documentation.
    -