WikiArxivMCP-智能研究平台
一个全面的模型上下文协议(MCP)服务器,通过标准化的MCP接口和具有人工智能综合功能的现代web应用程序,提供对维基百科和arXiv数据的统一访问。
概述
WikiArxivMCP是一个全栈研究平台,结合了:
- MCP服务器:用于程序化访问的符合标准的模型上下文协议服务器
- Web前端:用于交互式研究的现代基于React的界面
- 人工智能集成:Gemini AI驱动的综合,提供全面的研究见解
- 统一搜索:同时查询维基百科和arXiv数据库
- 缓存系统:智能缓存可提高性能并减少API调用
建筑
系统组件
┌─────────────────────────────────────────────────────────────────┐
│ WikiArxivMCP Platform │
├─────────────────────────────────────────────────────────────────┤
│ Frontend Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ React App │ │ Vite Server │ │ Express API │ │
│ │ (Port 3002) │ │ Development │ │ (Port 3001) │ │
│ │ │ │ │ │ │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ MCP Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ MCP Server │ │ MCP Client │ │ MCP Tools │ │
│ │ (stdio) │ │ Interface │ │ & Resources │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ Service Layer │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Wikipedia │ │ arXiv │ │ HTTP Client │ │
│ │ Service │ │ Service │ │ with Caching │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ External APIs │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Wikipedia API │ │ arXiv API │ │ Gemini AI │ │
│ │ REST Endpoints │ │ XML Feed │ │ API │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────────────────────┘数据流架构
Current Implementation - MCP-Based Search Flow:
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ User Input │───▶│ Frontend │───▶│ Express API │
│ (Web Form) │ │ (React) │ │ (/api/search)│
└──────────────┘ └──────────────┘ └──────────────┘
│
▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Search │◀───│ MCP Client │◀───│ API Router │
│ Results │ │ (JSON-RPC) │ │ Layer │
└──────────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Gemini AI │ │ MCP Server │ │ Fallback │
│ Synthesis │ │ (stdio) │ │ Direct Calls │
└──────────────┘ └──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Service │ │ Wikipedia & │
│ Layer │ │ arXiv APIs │
└──────────────┘ └──────────────┘
│
▼
┌──────────────┐
│ Wikipedia & │
│ arXiv APIs │
└──────────────┘ 主要特点:
- 主要路径:Web应用程序→ API快车→ MCP客户端→ MCP服务器→ 服务→ 外部API
- 退路:如果MCP失败,则自动回退到直接服务呼叫
- 稳健的错误处理:即使MCP层遇到问题,系统仍能继续工作
MCP协议流
MCP Client Communication:
┌─────────────┐ JSON-RPC ┌─────────────┐
│ MCP Client │ ◀──────────────▶ │ MCP Server │
│ │ over stdio │ │
└─────────────┘ └─────────────┘
│ │
│ tools/call │
│ resources/read │
│ ▼
│ ┌─────────────┐
│ │ Tool │
│ │ Handlers │
│ └─────────────┘
│ │
│ ▼
│ ┌─────────────┐
│ JSON Response │ Service │
└◀───────────────────────│ Layer │
└─────────────┘安装和设置
先决条件
- Node.js(版本18或更高)
- npm或yarn包管理器
- 可选:Gemini API键用于AI合成功能
安装步骤
- 克隆并安装依赖关系
git clone
cd WikiArxivMCP
npm install- 构建MCP服务器
npm run build- 安装前端依赖项
cd frontend
npm install- 配置环境变量
创建一个 .env 前端目录中的文件:
# Optional: Gemini AI API Key for synthesis features
GEMINI_API_KEY=your_gemini_api_key_here
# Optional: Cache configuration
CACHE_SIZE=1000
CACHE_TTL_SECONDS=600从以下位置获取Gemini API密钥: https://makersuite.google.com/app/apikey
用法
Web应用程序(推荐)
- 启动后端API服务器
cd frontend
node server/index.js服务器将于启动http://localhost:3001
- 启动前端开发服务器
# In a new terminal
cd frontend
npm run dev申请将于http://localhost:3002
- 访问应用程序
打开浏览器并导航到http://localhost:3002
MCP服务器(程序化访问)
对于直接MCP客户端集成:
# Start the MCP server
npm start服务器使用模型上下文协议JSON-RPC格式通过stdio进行通信。
特性和功能
搜索功能
维基百科搜索
- 基于标题的搜索和相关性排名
- 丰富的元数据,包括描述和缩略图
- 直接页面访问和摘要检索
- 可配置的结果限制(默认:8个结果)
arXiv论文搜索
- 在论文标题、摘要和作者之间进行全文搜索
- 全面的元数据,包括作者列表、出版日期
- 直接PDF访问链接
- 类别和分类信息
- 可配置的结果限制(默认值:5个结果)
人工智能驱动的合成
当配置Gemini API密钥时,系统提供:
- 结合维基百科和arXiv资源的综合研究
- 来源引用和归因
- 结构化、可访问的解释
- 源之间的交叉引用链接
Web界面功能
搜索界面
- 维基百科和arXiv的统一搜索框
- 高级过滤选项
- 实时搜索建议
- 搜索历史管理
结果显示
- 维基百科和arXiv结果的标签界面
- 具有元数据的丰富预览卡
- 书签和共享功能
- 导出功能
AI综合视图
- Markdown格式的综合答案
- 来源归因和链接
- 复制和共享功能
api参考
MCP工具
search_wikipedia
按标题搜索维基百科文章。
请求:
{
"method": "tools/call",
"params": {
"name": "search_wikipedia",
"arguments": {
"query": "quantum computing"
}
}
}答复:
{
"content": [
{
"type": "text",
"text": "[{\"title\": \"Quantum computing\", \"description\": \"Computing using quantum phenomena\", \"url\": \"https://en.wikipedia.org/wiki/Quantum_computing\"}]"
}
]
}search_arxiv
通过查询搜索arXiv论文。
请求:
{
"method": "tools/call",
"params": {
"name": "search_arxiv",
"arguments": {
"query": "machine learning",
"max_results": 5
}
}
}答复:
{
"content": [
{
"type": "text",
"text": "[{\"id\": \"2103.12345\", \"title\": \"Advanced ML Techniques\", \"authors\": [\"John Doe\"], \"summary\": \"Paper summary...\", \"pdf\": \"http://arxiv.org/pdf/2103.12345.pdf\"}]"
}
]
}MCP资源
维基百科:/页/
检索特定的维基百科页面摘要。
URI模式: wikipedia:/page/{title}
例子: wikipedia:/page/Artificial Intelligence
arxiv:/id/
按ID检索特定的arXiv论文。
URI模式: arxiv:/id/{id}
例子: arxiv:/id/2103.12345
REST API端点
POST/api/搜索
维基百科和arXiv的统一搜索端点。
请求正文:
{
"query": "cloud computing",
"useGemini": true,
"filters": {
"resultLimit": 10,
"searchType": "all"
}
}答复:
{
"query": "cloud computing",
"wikipedia": [...],
"arxiv": [...],
"synthesis": "AI-generated comprehensive answer...",
"geminiEnabled": true
}GET/api/健康
健康检查端点。
答复:
{
"status": "ok",
"geminiEnabled": true,
"mcpConnected": true
}配置
环境变量
HTTP配置:
HTTP_USER_AGENT:外部API请求的自定义用户代理HTTP_TIMEOUT_MS:请求超时(毫秒)(默认值:10000)
缓存配置:
CACHE_SIZE:缓存项目的最大数量(默认值:1000)CACHE_TTL_SECONDS:缓存生存时间(秒)(默认值:600)
AI集成:
GEMINI_API_KEY:合成功能的Google Gemini API密钥
性能调整
缓存设置
# High-performance configuration
CACHE_SIZE=5000
CACHE_TTL_SECONDS=1800
# Memory-constrained configuration
CACHE_SIZE=100
CACHE_TTL_SECONDS=300速率限制
该系统包括内置的速率限制,以防止API滥用:
- 维基百科API:每秒10次请求
- arXiv API:每秒3个请求
- 指数回退自动重试
发展
项目结构
WikiArxivMCP/
├── src/ # MCP server source code
│ ├── index.ts # Main MCP server entry point
│ ├── wikipedia-service.ts # Wikipedia API integration
│ ├── arxiv-service.ts # arXiv API integration
│ ├── http-client.ts # HTTP client with caching
│ ├── cache-service.ts # LRU cache implementation
│ └── schemas.ts # TypeScript type definitions
├── frontend/ # Web application
│ ├── src/ # React frontend source
│ ├── server/ # Express.js backend
│ └── public/ # Static assets
├── dist/ # Compiled JavaScript output
├── package.json # Node.js dependencies and scripts
└── tsconfig.json # TypeScript configuration开发命令
# Build the MCP server
npm run build
# Development mode with auto-reload
npm run dev
# Type checking
npm run type-check
# Run tests
npm test前端开发
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Start production server
npm start错误处理
该系统包括全面的错误处理:
网络错误
- 指数回退自动重试
- 当外部API不可用时,性能会下降
- 响应缓慢的超时处理
数据验证
- 使用Zod模式进行输入验证
- 贯穿始终的类型安全数据结构
- 山宁泰安全错误消息
速率限制保护
- 针对API费率限制的内置保护
- 智能请求排队
- 用户对速率限制场景的反馈
贡献
- 分叉存储库
- 创建要素分支:
git checkout -b feature-name - 通过适当的测试进行更改
- 确保TypeScript编译:
npm run build - 提交一个带有明确描述的拉取请求
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
支持
有关问题、疑问或贡献,请参阅项目的问题跟踪器或文档。
