feat: initialize MCP RAG Prompts server with embedding management

- Add package.json for project configuration and dependencies.
- Create src/index.ts as the entry point for the MCP server.
- Implement vectorStore for managing embeddings with local and cloud providers.
- Add embeddingProviders for local and cloud-based embedding services (OpenAI, Aliyun, SiliconFlow).
- Define types for prompts and embeddings in types.ts.
- Implement searchPersona tool for semantic search of expert personas.
- Create test.ts for validating vector storage and search functionality.
- Configure TypeScript with tsconfig.json for strict type checking and module resolution.
This commit is contained in:
lirui
2026-02-04 01:14:58 +08:00
commit 4693ebcf83
14 changed files with 4088 additions and 0 deletions

53
.env.example Normal file
View File

@@ -0,0 +1,53 @@
# ============================================================
# MCP RAG Prompts - Embedding 配置
# 复制此文件为 .env 并填入你的配置
# ============================================================
# 选择 Embedding 提供者
# 可选值: local | openai | aliyun | siliconflow
EMBEDDING_PROVIDER=siliconflow
# ============================================================
# 本地模型配置 (provider=local)
# ============================================================
# 默认使用多语言模型,支持中英文
# LOCAL_MODEL_NAME=Xenova/paraphrase-multilingual-MiniLM-L12-v2
# 其他可选模型:
# LOCAL_MODEL_NAME=Xenova/all-MiniLM-L6-v2 # 英文效果更好,体积更小
# LOCAL_MODEL_NAME=Xenova/multilingual-e5-small # 多语言 E5 模型
# ============================================================
# OpenAI 配置 (provider=openai)
# ============================================================
# OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
# OPENAI_BASE_URL=https://api.openai.com/v1
# OPENAI_EMBEDDING_MODEL=text-embedding-3-small
# 可选模型:
# text-embedding-3-small (1536维便宜)
# text-embedding-3-large (3072维更精准)
# text-embedding-ada-002 (1536维旧版)
# ============================================================
# 阿里云百炼 DashScope 配置 (provider=aliyun)
# ============================================================
# DASHSCOPE_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
# ALIYUN_EMBEDDING_MODEL=text-embedding-v3
# 可选模型:
# text-embedding-v3 (最新版,推荐)
# text-embedding-v2 (旧版)
# text-embedding-v1 (更旧)
# ============================================================
# SiliconFlow 硅基流动配置 (provider=siliconflow)
# ============================================================
SILICONFLOW_API_KEY=sk-fwemdoaytkxelpbjlnohiqvkeqjxxraoduadokrpvtynxoej
SILICONFLOW_EMBEDDING_MODEL=Qwen/Qwen3-Embedding-8B
# 可选模型 (开源模型,性价比高):
# BAAI/bge-m3 # 多语言,效果很好
# BAAI/bge-large-zh-v1.5 # 中文专用
# BAAI/bge-large-en-v1.5 # 英文专用
# nomic-ai/nomic-embed-text-v1.5 # 多语言