这是一个专为 Cursor 实现的 Model Control Protocol (MCP),它能借助多个学术搜索引擎开展科学搜索,有效解决在编码过程中查找学术资料的难题,为开发者提供了极大的便利。
⚠️ 重要提示
由 AI 编码实现振动。
要使用科学搜索 MCP for Cursor,您可以按以下步骤操作:
git clone https://github.com/yourusername/cursor-scientific-search.git
cd cursor-scientific-search
pip install -r requirements.txt
python scientific_search_mcp.py
git clone https://github.com/yourusername/cursor-scientific-search.git
cd cursor-scientific-search
pip install -r requirements.txt
# 用于 arXiv 搜索
pip install arxiv
# 用于 Google Scholar
pip install scholarly
# 用于 PubMed
pip install pymed
# 用于 Semantic Scholar(需要 Tor)
pip install requests[socks]
Semantic Scholar 的搜索使用 Tor 来绕过速率限制和 IP 封锁。要使用此功能:
sudo apt install tor(Debian/Ubuntu)或 sudo pacman -S tor(Arch)brew install torsudo systemctl start tor 或 sudo service tor startbrew services start tornc -z localhost 9050 && echo "Tor 正在运行"
在不同引擎上搜索科学论文:
# 在 arXiv 上搜索量子计算论文
results = await mcp_scientific_search_search_scientific(
query="quantum computing",
engine="arxiv"
)
# 在 PubMed 上搜索 COVID-19 研究
results = await mcp_scientific_search_search_scientific(
query="COVID-19 treatment",
engine="pubmed"
)
# 在 Google Scholar 上搜索人工智能论文
results = await mcp_scientific_search_search_scientific(
query="artificial intelligence",
engine="gScholar"
)
# 在 Semantic Scholar 上搜索自然语言处理
results = await mcp_scientific_search_search_scientific(
query="natural language processing",
engine="semScholar"
)
from typing import Dict, Any
def print_result(result: Dict[str, Any]) -> None:
"""打印搜索结果的元数据."""
print(f"标题:{result['title']}")
print(f"作者:{result['authors']}")
print(f"摘要:{result['abstract']}")
print(f"出版物:{result.get('publication', 'N/A')}")
print(f"DOI:{result.get('doi', 'N/A')}")
print(f"链接:{result['url']}\n")
# 示例用法
results = await mcp_scientific_search_search_scientific(
query="machine learning",
engine="arxiv"
)
for result in results:
print_result(result)
运行以下代码获取搜索结果并打印:
from mcpScientificSearch import MPSSearcher
import asyncio
async def main():
async with MPSSearcher() as searcher:
# 在 arXiv 上搜索量子计算论文
arxiv_results = await searcher.search(
query="quantum computing",
engine="arxiv"
)
print("arXiv 结果:")
for result in arxiv_results:
print(f"标题:{result['title']}")
print(f"作者:{result['authors']}\n")
# 在 Google Scholar 上搜索人工智能论文
gscholar_results = await searcher.search(
query="artificial intelligence",
engine="gScholar"
)
print("Google Scholar 结果:")
for result in gscholar_results:
print(f"标题:{result['title']}")
print(f"作者:{result['authors']}\n")
if __name__ == "__main__":
asyncio.run(main())
⚠️ 重要提示
- Google Scholar 速率限制:请勿在短时间内进行大量请求,以免触发 Google 的速率限制。
- Tor 稳定性:确保 Tor 服务正在运行,否则 Semantic Scholar 请求可能会失败。
解决方法:
可能原因: