Token导航 LogoToken导航TokenDH.com
MCP Application logo
数据服务stdio官方级别未说明来源级核验

MCP Application

MCP Server

一个基于Spring Boot的应用程序,集成了检索增强生成(RAG)和模型上下文协议(MCP),支持从文件系统、数据库、REST API和网页内容中检索信息,并结合Groq的LLM API生成响应。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
检索增强生成数据分析Java

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Mukundkumar07

提供方

Mukundkumar07

最后核验

2026/5/17 20:19

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run -p 6333:6333 qdrant/qdrant

详细介绍

RAG-MCP应用

Spring Boot应用程序实现 检索增强生成(RAG) 随着 模型上下文协议(MCP) 使用Groq的LLM API访问文件系统、数据库、RESTAPI和web内容的集成。

🌟 特性

RAG能力

  • 上下文增强的AI响应 -在生成响应之前检索相关文档
  • 向量相似性搜索 -内存中余弦相似性搜索(可升级到Qdrant)
  • 智能文档分块 -具有可配置重叠的基于句子的组块
  • 多源摄入 -文件系统、数据库、网页和API

MCP集成

  • 文件系统访问 -使用Apache Tika进行安全文件读取(PDF、DOCX、TXT、MD等)
  • 数据库查询 -PostgreSQL、MySQL、SQLite支持
  • REST API集成 -带有自定义标头的GET/POST请求
  • Web剪贴 -从网页中提取文本

AI集成

  • 格罗克API -使用llama-3.3-70b-进行快速推理
  • 嵌入生成 -384维向量(模拟,可用于真实模型)
  • 缓存 -嵌入缓存以提高性能

🚀 快速开始

先决条件

  • Java 17+
  • Maven 3.6+
  • Groq API密钥(已配置)

安装

  1. 克隆存储库
git clone https://github.com/Mukundkumar07/mcp-application.git
cd mcp-application
  1. 构建项目
mvn clean install
  1. 运行应用程序
mvn spring-boot:run

应用程序将于启动 http://localhost:8080

📖 API 文档

RAG聊天

POST http://localhost:8080/api/rag/chat
Content-Type: application/json

{
  "message": "What are the main features?",
  "topK": 5
}

文件摄入

来自文件系统:

POST http://localhost:8080/api/rag/ingest/filesystem
Content-Type: application/json

{
  "path": "my-docs",
  "filePattern": ".*\\.md"
}

来自数据库:

POST http://localhost:8080/api/rag/ingest/database
Content-Type: application/json

{
  "query": "SELECT * FROM articles",
  "connectionString": "jdbc:postgresql://localhost:5432/mydb?user=user&password=pass"
}

来自网络:

POST http://localhost:8080/api/rag/ingest/web
Content-Type: application/json

{
  "url": "https://example.com/article"
}

搜索文档

GET http://localhost:8080/api/rag/search?query=machine learning&topK=10

系统管理

# Health check
GET http://localhost:8080/api/rag/health

# Vector DB stats
GET http://localhost:8080/api/rag/stats/vector-db

# Clear database
DELETE http://localhost:8080/api/rag/clear

⚙️ 配置

编辑 src/main/resources/application.properties:

# Groq API
groq.api.key=your-groq-api-key
groq.api.model=llama-3.3-70b-versatile

# Vector Database
vector.db.enabled=false  # Set to true when using Qdrant
vector.db.host=localhost
vector.db.port=6333

# MCP Filesystem
mcp.filesystem.enabled=true
mcp.filesystem.root-path=/path/to/documents
mcp.filesystem.allowed-extensions=pdf,txt,md,docx,java,py,json,xml,html,css,js

# MCP External Resources
mcp.database.enabled=false  # Enable for database access
mcp.api.enabled=true
mcp.cloud-storage.enabled=false

# RAG Settings
rag.chunk-size=512
rag.chunk-overlap=50
rag.retrieval-top-k=5
rag.max-context-length=4000

🏗️ 建筑

┌─────────────┐
│    User     │
└──────┬──────┘
       │ HTTP
       ▼
┌─────────────────────┐
│   RAG Controller    │
└──────┬──────────────┘
       │
       ├──────────────────────┐
       │                      │
       ▼                      ▼
┌─────────────┐      ┌──────────────────┐
│ RAG Service │      │ Ingestion Service│
└──────┬──────┘      └────────┬─────────┘
       │                      │
       ├──────┬───────────────┼──────────┐
       │      │               │          │
       ▼      ▼               ▼          ▼
  ┌────────┐ ┌──────┐  ┌──────────┐ ┌─────────┐
  │Embedding│ │Vector│  │Filesystem│ │External │
  │ Service│ │  DB  │  │   MCP    │ │   MCP   │
  └────────┘ └──┬───┘  └────┬─────┘ └────┬────┘
              │             │            │
              ▼             ▼            ▼
         ┌─────────┐  ┌─────────┐  ┌─────────┐
         │ Groq API│  │  Files  │  │DB/API/Web│
         └─────────┘  └─────────┘  └─────────┘

📁 项目结构

mcp-application/
├── src/main/java/com/example/
│   ├── controller/
│   │   ├── HelloController.java       # Original Groq endpoints
│   │   └── RAGController.java         # RAG & MCP endpoints
│   ├── service/
│   │   ├── GroqService.java           # Groq API integration
│   │   ├── EmbeddingService.java      # Text embeddings
│   │   ├── VectorDatabaseService.java # Vector storage
│   │   ├── DocumentChunker.java       # Text chunking
│   │   ├── RAGService.java            # RAG orchestration
│   │   └── DocumentIngestionService.java
│   ├── mcp/
│   │   ├── FileSystemMCPServer.java   # Filesystem access
│   │   └── ExternalResourceMCPServer.java # DB/API/Web
│   ├── model/
│   │   ├── Document.java
│   │   ├── DocumentChunk.java
│   │   ├── RAGRequest.java
│   │   └── RAGResponse.java
│   └── config/
│       └── GroqConfig.java
├── src/main/resources/
│   └── application.properties
└── pom.xml

🧪 测试

1.创建测试文档

mkdir -p /path/to/documents/test
echo "Spring Boot is a Java framework." > /path/to/documents/test/spring.txt
echo "RAG combines retrieval and generation." > /path/to/documents/test/rag.txt

2.摄入文件

curl -X POST http://localhost:8080/api/rag/ingest/filesystem \
  -H "Content-Type: application/json" \
  -d '{"path": "test"}'

3.使用RAG查询

curl -X POST http://localhost:8080/api/rag/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is Spring Boot?", "topK": 3}'

🔧 高级设置

启用Qdrant矢量数据库

# Start Qdrant
docker run -p 6333:6333 qdrant/qdrant

# Update application.properties
vector.db.enabled=true

启用数据库访问

mcp.database.enabled=true

📚 依赖项

  • 弹簧靴3.2.1 -应用框架
  • 格罗克API -LLM推理
  • 阿帕奇蒂卡2.9.1 -文档解析(PDF、DOCX等)
  • OkHttp 4.12.0 -HTTP客户端
  • Qdrant客户端1.7.0 -矢量数据库(可选)
  • DJL 0.25.0 -用于嵌入的深度学习库

🤝 贡献

欢迎投稿!请随时提交拉取请求。

📝 许可证

这个项目是开源的,可以在MIT许可证下使用。

👤 作者

穆昆德·库马尔

🙏 致谢

______________________________________________________________________

建于❤️ 使用Spring Boot、RAG和MCP

目录标签

目录标签

检索增强生成数据分析Java本地部署模型上下文协议文件系统访问数据库查询RESTAPI集成

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP