Skip to main content

An MCP server for searching and retrieving articles from Google Scholar

Project description

Google Scholar MCP Server

🔍 让 AI 助手通过 MCP 协议搜索和访问 Google Scholar 学术论文。

Google Scholar MCP Server 是一个基于 Model Context Protocol (MCP) 的服务器,为 AI 助手提供搜索 Google Scholar 学术论文的能力。

✨ 核心功能

  • 🔎 论文搜索:支持关键词搜索、作者筛选、年份范围筛选
  • 📄 完整摘要:搜索单篇论文时可获取完整摘要内容
  • 🛡️ 验证码处理:优化了 scholarly 库的 CAPTCHA 验证码处理机制,遇到验证码时自动弹出浏览器窗口供手动验证
  • 📚 BibTeX 支持:可获取论文的 BibTeX 引用格式
  • 🚀 高效检索:快速获取论文元数据

🛠️ MCP 工具

search_google_scholar

搜索 Google Scholar 上的学术文章。

参数:

参数 类型 必填 说明
query string 搜索关键词(论文标题、主题或关键词)
author string 作者名称筛选
year_low int 起始年份
year_high int 结束年份
num_results int 返回结果数量(默认: 5)

返回结果:

{
  "bib": {
    "title": "论文标题",
    "author": "作者",
    "pub_year": "发表年份",
    "venue": "发表期刊/会议",
    "abstract": "摘要"
  },
  "pub_url": "论文链接",
  "num_citations": "被引用次数",
  "citedby_url": "引用链接",
  "eprint_url": "PDF 链接"
}

使用示例

关键词搜索:

result = await mcp.use_tool("search_google_scholar", {
    "query": "deep learning",
    "num_results": 5
})

带作者筛选:

result = await mcp.use_tool("search_google_scholar", {
    "query": "convolutional neural networks",
    "author": "Yann LeCun",
    "num_results": 3
})

带年份范围:

result = await mcp.use_tool("search_google_scholar", {
    "query": "transformer",
    "year_low": 2020,
    "year_high": 2024,
    "num_results": 5
})

组合搜索:

result = await mcp.use_tool("search_google_scholar", {
    "query": "neural networks",
    "author": "Geoffrey Hinton",
    "year_low": 2015,
    "year_high": 2023,
    "num_results": 10
})

🚀 快速开始

方式一:从 PyPI 安装(Coming Soon)

uv tool install google_scholar_mcp

方式二:从 GitHub 安装

uv tool install git+https://github.com/arrogant-R/google_scholar_mcp.git

方式三:本地安装

  1. 克隆仓库:
git clone https://github.com/arrogant-R/google_scholar_mcp.git
cd Google-Scholar-MCP-Server
  1. 创建虚拟环境并安装依赖:
# 使用 uv(推荐)
uv venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
uv pip install -e .

# 或使用 pip
pip install -r requirements.txt
  1. 启动服务:
# 作为模块运行
python -m google_scholar_mcp

⚙️ 配置 MCP 客户端

方式一:使用 uv(从 GitHub 安装后)

{
  "mcpServers": {
    "google-scholar": {
      "command": "uv",
      "args": [
        "tool",
        "run",
        "google_scholar_mcp"
      ]
    }
  }
}

方式二:本地开发模式(uv)

{
  "mcpServers": {
    "google-scholar": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/Google-Scholar-MCP-Server",
        "run",
        "google_scholar_mcp"
      ]
    }
  }
}

方式三:使用本地 Python

{
  "mcpServers": {
    "google-scholar": {
      "command": "/path/to/python",
      "args": [
        "/path/to/Google-Scholar-MCP-Server/google_scholar_server.py"
      ]
    }
  }
}

VS Code (GitHub Copilot)

在 VS Code 的 mcp.json 配置文件中添加:

使用 uv:

{
  "servers": {
    "google_scholar": {
      "type": "stdio",
      "command": "uv",
      "args": [
        "tool",
        "run",
        "google_scholar_mcp"
      ]
    }
  }
}

使用本地 Python:

{
  "servers": {
    "google_scholar": {
      "type": "stdio",
      "command": "D:/path/to/python.exe",
      "args": [
        "D:/path/to/Google-Scholar-MCP-Server/google_scholar_server.py"
      ]
    }
  }
}

Claude Desktop

使用 uv(推荐):

{
  "mcpServers": {
    "google-scholar": {
      "command": "uv",
      "args": [
        "tool",
        "run",
        "google_scholar_mcp"
      ]
    }
  }
}

或使用 Python:

Mac OS:

{
  "mcpServers": {
    "google-scholar": {
      "command": "python",
      "args": ["-m", "google_scholar_mcp"]
    }
  }
}

Windows:

{
  "mcpServers": {
    "google-scholar": {
      "command": "C:\\Users\\YOUR\\PATH\\python.exe",
      "args": [
        "D:\\path\\to\\Google-Scholar-MCP-Server\\google_scholar_server.py"
      ]
    }
  }
}

Cursor

在 Settings → Cursor Settings → MCP → Add new server 中添加:

{
  "google-scholar": {
    "command": "uv",
    "args": [
      "tool",
      "run",
      "google-scholar-mcp"
    ]
  }
}

Cline

{
  "mcpServers": {
    "google-scholar": {
      "command": "uv",
      "args": [
        "tool",
        "run",
        "google-scholar-mcp"
      ]
    }
  }
}

优化

🛡️ CAPTCHA 验证码处理

本项目对 scholarly 库进行了优化,解决了遇到 Google Scholar 验证码时程序卡住的问题:

  1. 自动检测验证码:当检测到验证码时,自动弹出浏览器窗口
  2. 手动验证:在弹出的浏览器中手动完成验证
  3. Cookie 同步:验证完成后后续请求使用自动同步的 Cookie,避免频繁触发验证
  4. Cookie 持久化:将 Cookie 保存到本地文件,下次启动时自动加载,减少验证码出现频率

⚠️ 如果遇到验证码,请在弹出的浏览器窗口中手动完成验证,程序会自动等待并继续执行。

📄 完整摘要获取

当进行精确搜索(num_results=1)时,系统会自动获取论文的完整 abstract,而不仅仅是截断的摘要片段。这对于需要详细了解单篇论文内容的场景非常有用。

📁 项目结构

Google-Scholar-MCP-Server/
├── src/
│   └── google_scholar_mcp/
│       ├── __init__.py         # 包入口
│       ├── __main__.py         # 主入口
│       ├── server.py           # MCP 服务器实现
│       ├── search.py           # 搜索逻辑
│       └── scholarly/          # 修改版 scholarly 库
│           ├── _navigator.py
│           ├── _proxy_generator.py
│           ├── _scholarly.py
│           └── ...
├── requirements.txt            # 依赖列表
└── pyproject.toml              # 项目配置(支持 uv/pip 安装)

🔧 依赖

  • Python 3.10+
  • mcp
  • requests
  • beautifulsoup4
  • selenium
  • httpx
  • fake_useragent
  • 等(详见 requirements.txt)

🤝 贡献

欢迎提交 Pull Request 和 Issue!

📄 许可证

本项目采用 MIT 许可证。

⚠️ 免责声明

本工具仅供学术研究使用。请遵守 Google Scholar 的服务条款,合理使用本工具。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_scholar_mcp-0.1.0.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_scholar_mcp-0.1.0-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

Details for the file google_scholar_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: google_scholar_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.16

File hashes

Hashes for google_scholar_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e4d97c34037e81fc8ebaa662e26541d5419047b4231523d399945a295d7f539
MD5 6f20cbde9d640ee952dcddea53579ea5
BLAKE2b-256 14b8c04813b6e86a98c7e8f24cde4b32159ed9584e45612567a2671ee18ce865

See more details on using hashes here.

File details

Details for the file google_scholar_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for google_scholar_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5bec79f4ff9940877da10c9397c14f85a2bb249d4a0929c133b77949fb31ce5
MD5 9817d65c1c8ac13db3c67cc843ab7f98
BLAKE2b-256 b20ed837b667ec048486b028ec99f8f45bacd01e9d45747e8caceb18ff039564

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page