Skip to main content
Glama
manufacturing-graphrag
by anils123

制造可追溯性智能平台

基于 GraphRAG 的智能体 AI 平台,用于制造可追溯性,使用 Neo4j、Amazon Bedrock 和 MCP。

架构

┌─────────────────────────────────────────────────────────────────────┐
│                    INGESTION & ENRICHMENT LAYER                      │
│  Connectors → Chunking → Embeddings → Entity Extraction →           │
│  Entity Resolution → Graph Construction                              │
└──────────────────────────┬──────────────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────────────┐
│                    KNOWLEDGE GRAPH (Neo4j)                           │
│  Product → Requirement → Component → TestCase → TestRun →           │
│  Defect → ChangeRequest                                              │
└──────────────────────────┬──────────────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────────────┐
│                    RETRIEVAL LAYER                                   │
│  VectorRetriever │ GraphRAGRetriever │ NL2CypherRetriever │ Hybrid  │
└──────────────────────────┬──────────────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────────────┐
│                    AGENT LAYER                                       │
│  LangGraph Agent (plan→retrieve→reason→validate→respond)            │
│  Strands Agent (tool-calling with 5 specialized graph tools)        │
└──────────────────────────┬──────────────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────────────┐
│                    INTERFACE LAYER                                   │
│  FastAPI REST │ MCP Server (Claude Desktop / Cursor compatible)     │
└─────────────────────────────────────────────────────────────────────┘

Related MCP server: RAG MCP Server

快速开始

1. 先决条件

  • Neo4j 5.x(带 APOC 插件)

  • Python 3.11+

  • 具有 Bedrock 访问权限的 AWS 凭证(Claude 3.5 Sonnet + Titan Embed v2)

2. 设置

cd manufacturing-graphrag
python -m venv .venv
.venv\Scripts\activate          # Windows
pip install -r requirements.txt
python -m spacy download en_core_web_sm
copy .env.example .env          # Edit with your credentials

3. 启动 Neo4j(Docker)

docker-compose up neo4j -d

4. 填充知识图谱

set PYTHONPATH=src
python scripts/seed_data.py

5. 启动平台

# API server
python main.py api

# MCP server (for Claude Desktop)
python main.py mcp

# Both
python main.py all

6. 摄取文档

python scripts/ingest.py path/to/spec.pdf path/to/requirements.csv

API 端点

方法

端点

描述

GET

/health

健康检查

GET

/graph/stats

按标签统计节点数量

POST

/ingest/file

上传并摄取文档

POST

/ingest/record

摄取结构化 API 记录

POST

/query

混合 GraphRAG 查询

POST

/agent/langgraph

LangGraph 推理智能体

POST

/agent/strands

Strands 工具调用智能体

GET

/traceability/defect/{id}

完整缺陷可追溯链

GET

/traceability/product/{id}

产品可追溯性摘要

示例查询

# Hybrid GraphRAG query
curl -X POST http://localhost:8000/query \
  -H "Content-Type: application/json" \
  -d '{"question": "What components are affected by the thermal runaway defect?"}'

# LangGraph agent — multi-step reasoning
curl -X POST http://localhost:8000/agent/langgraph \
  -d '{"question": "Trace the full impact chain of DEF-001 and identify all change requests needed"}'

# Strands agent — tool-calling
curl -X POST http://localhost:8000/agent/strands \
  -d '{"question": "Which critical defects are blocking the EV BMS release?"}'

# Defect traceability
curl http://localhost:8000/traceability/defect/DEF-002

MCP 集成(Claude Desktop)

将 config/claude_desktop_mcp.json 的内容复制到你的 Claude Desktop claude_desktop_config.json 中。

可用的 MCP 工具:

  • ask_manufacturing_ai — 混合 GraphRAG 问答

  • semantic_search — 向量相似性搜索

  • graph_trace — 图遍历检索

  • natural_language_to_cypher — 自然语言转 Cypher

  • get_defect_chain — 完整缺陷可追溯性

  • get_requirement_traceability — 需求覆盖

  • product_health_dashboard — 产品指标

知识图谱模式

(Product)-[:HAS_REQUIREMENT]->(Requirement)
(Component)-[:IMPLEMENTS]->(Requirement)
(TestCase)-[:VALIDATES]->(Requirement)
(TestRun)-[:INSTANCE_OF]->(TestCase)
(TestRun)-[:FOUND_IN]->(Defect)
(Defect)-[:AFFECTS]->(Component)
(Defect)-[:TRIGGERS_CHANGE]->(ChangeRequest)
(ChangeRequest)-[:MODIFIES]->(Component)
(Document)-[:CONTAINS_CHUNK]->(Chunk)
(Chunk)-[:MENTIONS]->(any entity)

运行测试

set PYTHONPATH=src
pytest tests/ -v

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables storage and retrieval of knowledge in a graph database format, allowing users to create, update, search, and delete entities and relationships in a Neo4j-powered knowledge graph through natural language.
    5
    -
  • A
    license
    C
    quality
    D
    maintenance
    Combines a knowledge graph with RAG (Retrieval-Augmented Generation) capabilities for semantic code indexing and search. Enables creating entity relationships, managing observations, and performing semantic searches across indexed codebases.
    13
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Transforms code repositories and development documentation into a queryable Neo4j knowledge graph, enabling AI assistants to perform intelligent code analysis, dependency mapping, impact assessment, and automated documentation generation across 15+ programming languages.
    7
    -