arXiv研究MCP服务器
一个全面的模型上下文协议(MCP)服务器,用于搜索和分析arXiv的学术论文,具有AI支持的相关性排名和全文提取功能。
特性
- 智能搜索:使用日期过滤和相关性排名搜索arXiv
- 全文提取:下载并提取完整的论文内容
- 缓存:智能缓存可减少API调用
- 多重集成:与Claude、LangChain、Streamlit等合作
- 批处理:高效处理多个研究课题
- API包装:REST API,便于集成
- Jupyter集成:交互式分析和可视化工具
- 相关性排名:基于TF-IDF的排名,以获得更好的结果
- PDF处理:从PDF中提取多方法文本
快速开始
安装
# Clone the repository
git clone https://github.com/borderlessboy/arxiv-research-mcp
cd arxiv-research-mcp
# Install dependencies
pip install -r requirements.txt
# Create environment configuration
# cp .env.example .env # Create .env file with your configuration基本用法
# Run the MCP server
python scripts/run_server.py
# Or use the Streamlit dashboard
streamlit run integrations/streamlit_app.pyDocker使用
该项目包括一个Dockerfile,便于容器化部署。
Docker快速入门
# Build the Docker image
docker build -t arxiv-research-mcp .
# Run the container
docker run -p 8090:8090 arxiv-research-mcp自定义配置的Docker
# Build with custom tag
docker build -t arxiv-research-mcp:latest .
# Run with custom port mapping
docker run -p 8080:8090 arxiv-research-mcp
# Run with volume for persistent cache
docker run -p 8090:8090 -v $(pwd)/cache:/app/cache arxiv-research-mcp
# Run with environment variables
docker run -p 8090:8090 \
-e CACHE_ENABLED=true \
-e CACHE_TTL_HOURS=24 \
-e LOG_LEVEL=INFO \
arxiv-research-mcpDocker Compose(推荐)
该项目包括 docker-compose.yml 文件以便于部署:
# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose down或创建自定义 docker-compose.yml:
services:
arxiv-research-mcp:
build: .
ports:
- "8090:8090"
volumes:
- ./cache:/app/cache
environment:
- CACHE_ENABLED=true
- CACHE_TTL_HOURS=24
- LOG_LEVEL=INFO
restart: unless-stopped# Start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose downDocker开发
# Build for development with all dependencies
docker build -t arxiv-research-mcp:dev .
# Run with mounted source code for development
docker run -p 8090:8090 \
-v $(pwd)/src:/app/src \
-v $(pwd)/config:/app/config \
-v $(pwd)/cache:/app/cache \
arxiv-research-mcp:dev安装选项
Docker安装(推荐)
# Quick start with Docker
docker build -t arxiv-research-mcp .
docker run -p 8090:8090 arxiv-research-mcp完整安装
pip install "arxiv-research-mcp[all]"特定组件
# API server only
pip install "arxiv-research-mcp[api]"
# Jupyter integration
pip install "arxiv-research-mcp[jupyter]"
# Dashboard
pip install "arxiv-research-mcp[dashboard]"
# LangChain integration
pip install "arxiv-research-mcp[langchain]"使用示例
1.基本MCP服务器使用
from src.server import search_arxiv_papers_tool
# Search for papers
result = await search_arxiv_papers_tool({
"query": "transformer models",
"max_results": 10,
"years_back": 4,
"include_full_text": True
})2.LangChain集成
from integrations.langchain_tool import ResearchAgent
agent = ResearchAgent()
result = agent.research_topic("quantum machine learning")3.Jupyter分析
from integrations.jupyter_helper import search_papers
# Search and analyze
helper = await search_papers("machine learning", max_results=20)
# Create visualizations
fig = helper.create_publication_timeline()
plt.show()4.流线型仪表板
streamlit run integrations/streamlit_app.py配置
创建一个 .env 使用您的设置文件:
# Server Configuration
SERVER_NAME=arxiv-research-server
LOG_LEVEL=INFO
# arXiv API Configuration
ARXIV_REQUEST_TIMEOUT=30
ARXIV_MAX_RETRIES=3
# Caching
CACHE_ENABLED=true
CACHE_TTL_HOURS=24
# Content Processing
MAX_FULL_TEXT_LENGTH=50000
DEFAULT_MAX_RESULTS=10
DEFAULT_YEARS_BACK=4api参考
MCP工具
search_arxiv_papers
搜索具有相关性排名的学术论文。
参数:
query(string):搜索查询max_results(整数,默认值:10):要返回的最大纸张数years_back(整数,默认值:4):要回溯的年份include_full_text(布尔值,默认值:true):包含全文
clear_cache
清除所有缓存的搜索结果。
get_cache_stats
获取缓存统计数据和信息。
LangChain工具
ArxivResearchTool
使用LangChain集成搜索arXiv论文。
ArxivCacheManagementTool
使用LangChain集成管理缓存。
高级功能
相关性排名
服务器使用TF-IDF矢量化和余弦相似度根据与查询的相关性对论文进行排名。
PDF处理
多种提取方法(PyPDF2、pdfplumber)可确保从PDF中提取强大的文本。
缓存系统
智能缓存减少了API调用并改进了响应时间。
批处理
使用批处理程序高效处理多个研究主题。
Docker部署
该项目包括一个生产就绪的Dockerfile,其中包含:
- 轻量级Python 3.11-slim基础镜像
- 优化层缓存以实现更快的构建
- 端口8090上预先配置的HTTP服务器
- 对持久缓存的卷支持
- 环境变量配置
发展
运行测试
pytest tests/代码质量
black src/ tests/
flake8 src/ tests/
mypy src/建筑
python setup.py buildDocker开发
# Build development image
docker build -t arxiv-research-mcp:dev .
# Run with source code mounted for development
docker run -p 8090:8090 \
-v $(pwd)/src:/app/src \
-v $(pwd)/config:/app/config \
-v $(pwd)/cache:/app/cache \
arxiv-research-mcp:dev
# Run tests in Docker
docker run arxiv-research-mcp:dev pytest tests/建筑
arxiv-research-mcp/
├── src/
│ ├── server.py # Main MCP server
│ ├── models/ # Data models
│ ├── services/ # Core services
│ └── utils/ # Utility functions
├── integrations/ # External integrations
├── scripts/ # Utility scripts
├── tests/ # Test suite
└── examples/ # Usage examples文档
有关详细文档和指南,请参阅 文件/ 目录:
- MCPO集成指南 -MCPO集成完整指南
- 端口运行指南 -如何在不同端口上运行服务器
- MCPO的自述文件 -MCPO特定文件
- Bug修复摘要 -错误修复和改进摘要
- 代码清理摘要 -代码清理和优化文档
- **** -全面的Docker部署指南
- 许可证信息 -许可证详细信息和合规指南
贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 添加新功能的测试
- 提交拉取请求
许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
故障排除
Docker问题
端口已在使用中:
# Use a different port
docker run -p 8080:8090 arxiv-research-mcp权限被拒绝:
# Run with proper permissions
sudo docker run -p 8090:8090 arxiv-research-mcp构建失败:
# Clean build
docker system prune -a
docker build --no-cache -t arxiv-research-mcp .集装箱立即退出:
# Check logs
docker logs
# Run interactively
docker run -it arxiv-research-mcp /bin/bash支持
- 问题:
- 文档:
- 讨论:
致谢
- arXiv提供学术论文数据库
- 服务器框架的MCP(模型上下文协议)
- 使用的各种库的开源社区
