About Openai LLM MCP RAG Js
Openai LLM MCP RAG Js is an MCP server published by sunpcm in the AI category: this repository is a 100% TypeScript powerhouse that takes "RAG" (Retrieval-Augmented Generation) to the next level! It's like a brainy librarian on caffeine—fetching knowledge, augmenting it, and generating magic, all while staying strongly typed. 🚀.
The repository has 2 stars and 2 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/sunpcm/openai-llm-mcp-rag-jsThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Openai LLM MCP RAG Js
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 5 days ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- !License declaredNo license file. Legally you have no right to use it in a product.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- ✓Dependencies pinnedA lockfile pins dependency versions.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
LLM-MCP-RAG-JS
提示: 如果需要 Python 版本的实现,请访问 LLM-MCP-RAG-Python。 Python版本具有更好的扩展性,可以更好的集成rag/Vector DB/ComfyUI
项目架构
项目采用模块化设计,主要包含以下核心组件:
目录结构
src/
├── core/ # 核心业务逻辑
├── protocol/ # MCP 协议实现
├── retrieval/ # 文档检索相关实现
├── utils/ # 工具函数
└── config/ # 配置文件
核心组件
-
MCP Service (
src/protocol/MCPService.ts)- 负责与 MCP 服务器的通信
- 管理工具注册和调用
- 实现了重试机制和错误处理
-
Document Retrieval (
src/retrieval/)- 实现文档检索功能
- 支持文档的加载和向量化
- 提供相似度搜索
-
RAG Agent (
src/core/)- 协调 MCP 服务和文档检索
- 处理用户查询
- 生成上下文增强的响应
技术栈
- 运行时环境: Node.js
- 开发语言: TypeScript
- 包管理器: pnpm
- 主要依赖:
@modelcontextprotocol/sdk: MCP 协议实现openai: OpenAI API 客户端zod: 类型验证dotenv: 环境变量管理
配置和运行
环境要求
- Node.js >= 18
- pnpm >= 10.6.3
安装依赖
pnpm install
环境变量配置
创建 .env 文件并配置以下环境变量:
EMBEDDING_BASE_URL=https://oneapi.biubiuniu.com
EMBEDDING_KEY=your_embedding_api_key
OPENAI_BASE_URL=https://oneapi.biubiuniu.com
OPENAI_API_KEY=your_llm_api_key
开发运行
# 开发模式
pnpm dev
# 构建
pnpm build
# 生产运行
pnpm start
待改进方向
-
错误处理优化
- 实现更细粒度的错误类型
- 添加错误重试策略配置
- 改进错误日志记录
-
性能优化
- 实现文档缓存机制
- 优化向量检索性能
- 添加批处理支持
-
可观测性
- 添加详细的日志记录
- 实现性能指标收集
- 添加监控接口
使用示例
import { MCPService } from './protocol/MCPService';
import { DocumentRetriever } from './retrieval/DocumentRetriever';
import { RAGAgent } from './core/RAGAgent';
// 初始化服务
const mcpService = new MCPService('my-service', 'mcp-server');
await mcpService.initialize();
// 初始化文档检索
const retriever = new DocumentRetriever();
await retriever.loadDocuments('./knowledge');
// 创建 RAG Agent
const agent = new RAGAgent(mcpService, retriever);
// 处理查询
const response = await agent.process('你的问题');
本项目部分代码参考了 KelvinQiu802/llm-mcp-rag,在此表示感谢。# LLM-MCP-RAG
README fetched from the repository 5 days ago. The original is authoritative.