FastMCP项目:ArxivExplorer
一个简单的模型上下文协议(MCP)服务器和客户端,用于探索ArXiv上最近的人工智能研究。本项目演示了如何构建和测试用于研究工具的自定义MCP服务器和客户端,重点是搜索、总结和报告ArXiv论文。
特性
- ArxivExplorer MCP服务器:提供:
- 人工智能研究主题建议资源 - 搜索ArXiv和总结论文的工具 - 通过最近的论文探索主题的提示模板
- MCP客户端:连接到服务器,列出可用的工具/资源/提示,获取主题,搜索ArXiv,总结论文,并演示提示用法。
需求
- Python 3.8+
- FastMCP 2.0
- Tavilly API密钥
安装依赖项:
pip install -r requirements.txt______________________________________________________________________
设置
1.设置Tavilly API密钥
服务器需要Tavily API密钥。将其设置为环境变量:
在Linux/macOS上:
export TAVILY_API_KEY=your_tavily_api_key在Windows(CMD)上:
set TAVILY_API_KEY=your_tavily_api_key在Windows(PowerShell)上:
$env:TAVILY_API_KEY="your_tavily_api_key"运行服务器
启动ArxivExplorer MCP服务器(默认:http://localhost:8000/mcp):
python server.py您应该看到如下输出:
✅ ArxivExplorer server initialized.
✅ Resource 'resource://ai/arxiv_topics' registered.
✅ Tools 'Search Arxiv' and 'Summarize Paper' registered.
✅ Prompt 'explore_topic_prompt' registered.
🚀 Starting ArxivExplorer Server…
(Server runs at http://localhost:8000/mcp)运行客户端
客户端连接到服务器,列出可用的工具/资源/提示,获取主题,搜索ArXiv,总结论文,并演示提示用法。
python client.py您应该看到类似于以下内容的输出:
🚀 Connecting to FastMCP server at: http://localhost:8000/mcp
🔗 Testing server connectivity...
✅ Server is reachable!
🛠️ Available tools:
[ 'search_arxiv', 'summarize_paper' ]
📚 Available resources:
[ 'resource://ai/arxiv_topics' ]
💬 Available prompts:
[ 'explore_topic_prompt' ]
📖 Fetching resource: resource://ai/arxiv_topics
Today's AI topics:
1. Transformer interpretability
2. Efficient large-scale model training
3. Federated learning privacy
4. Neural network pruning
🔍 Testing tool: search_arxiv
1. [Paper Title 1]
[Paper URL 1]
2. [Paper Title 2]
[Paper URL 2]
...
📝 Testing tool: summarize_paper
Summary of first paper:
[Summary text]
🚀 Testing prompt: explore_topic_prompt
Generated prompt:
SYSTEM: I want to explore recent work on 'Transformer interpretability'.
1. Call the 'Search Arxiv' tool to find the 5 most recent papers.
2. For each paper URL, call 'Summarize Paper' to extract its key contributions.
3. Combine all summaries into an overview report.与游标MCP集成(MCP.json设置)
要在游标中使用本地MCP服务器,请在游标设置中配置MCP端点:
- 在以下位置打开(或创建)文件
C:\Users\\.cursor\mcp.json(在Windows上)。 - 添加以下内容:
{
"ArxivExplorer": {
"url": "http://127.0.0.1:8000/mcp/"
}
}- 保存文件并重新启动Cursor(如果已打开)。
现在,Cursor将把MCP请求路由到您的本地服务器。如果需要,您可以通过向JSON添加更多键来添加更多端点。
