cnki-mcp

cnki-mcp

Enables AI assistants to search CNKI (China National Knowledge Infrastructure), download PDFs, and import them into Zotero with automatic PDF attachment.

Category
Visit Server

README

cnki-mcp

CI License: MIT Python 3.10+

把中国知网(CNKI)的**文献检索 → PDF 下载 → 导入 Zotero(自动迁移并关联 PDF)**封装成 MCP 工具,供 Claude 等 AI 助手一键调用。

An MCP server that lets an AI assistant search CNKI (China National Knowledge Infrastructure), download article PDFs, and import them into Zotero with the PDF automatically attached.

✨ 功能

  • 检索 CNKI 学术期刊/学位论文(表单交互,绕开失效的 URL 参数检索)
  • 下载 单篇或批量 PDF/CAJ 到本地
  • 导入 Zotero:优先本地 connector(localhost:23119),把 PDF 直接上传并关联为子附件;Zotero 未运行时降级云 API(仅元数据)
  • 登录态持久化:Cookie 保存/恢复,几小时内免重复登录
  • 一键批量cnki_batch 串起 检索→下载→导入→清理暂存

🧰 MCP 工具

工具 说明
cnki_login_status 检查机构登录状态
cnki_open_login_page 打开登录页,等待手动完成机构登录并保存 Cookie
cnki_save_cookies 手动保存当前 Cookie
cnki_search 按关键词检索期刊论文
cnki_download_pdf 下载单篇 PDF/CAJ
cnki_import_to_zotero 把元数据列表导入 Zotero(可带 pdf_path 自动关联 PDF)
cnki_batch 一键:检索 → 下载 → 导入 Zotero

📦 环境要求

  • Python 3.10+(MCP SDK 要求)
  • Playwright + 系统 Chrome(或内置 Chromium)
  • 有效的 CNKI 机构访问权限(校园网/VPN/机构账号)
  • 可选:Zotero 7+ 桌面端(用于 PDF 自动关联)

🚀 安装

方式 A:pip 安装(推荐,提供 cnki-mcp 命令)

# 从 GitHub 直接安装(或 pip install cnki-mcp 若已上 PyPI)
pip install git+https://github.com/wuruiqi/cnki-mcp.git
python -m playwright install chromium   # 若无系统 Chrome

安装后即有 cnki-mcp 控制台命令,启动 stdio MCP 服务器。

方式 B:克隆源码

git clone https://github.com/wuruiqi/cnki-mcp.git
cd cnki-mcp
pip install -r requirements.txt
python -m playwright install chromium
cp .env.example .env                     # 按需修改配置

注册到 MCP 客户端

pip 安装后(用 cnki-mcp 命令,最简洁):

{
  "mcpServers": {
    "cnki": { "type": "stdio", "command": "cnki-mcp" }
  }
}

uvx 免安装运行

{
  "mcpServers": {
    "cnki": {
      "type": "stdio",
      "command": "uvx",
      "args": ["--from", "git+https://github.com/wuruiqi/cnki-mcp.git", "cnki-mcp"]
    }
  }
}

克隆源码方式(直接指向 server.py):

{
  "mcpServers": {
    "cnki": {
      "type": "stdio",
      "command": "python",
      "args": ["/abs/path/to/cnki-mcp/server.py"]
    }
  }
}

⚙️ 配置(.env)

所有项均可选,路径默认相对项目根目录。详见 .env.example

变量 默认 说明
ZOTERO_LOCAL_API http://127.0.0.1:23119 Zotero 本地 connector 地址
ZOTERO_API_KEY / ZOTERO_LIB_ID 仅离线降级到云 API 时需要
PDF_DIR ./downloads PDF 暂存目录
PROFILE_DIR ./.browser_profile 浏览器持久化目录
COOKIE_FILE ./.cnki_cookies.json Cookie 存储文件
DELETE_PDF_AFTER_IMPORT true 成功关联 Zotero 后删除暂存 PDF

📖 使用流程

  1. cnki_login_status 查登录态;未登录则 cnki_open_login_page,在弹出的浏览器里完成机构登录(机构登录 → 校外登录 → 学校 → 账号密码 → 接受条款),脚本自动存 Cookie。
  2. cnki_search "粮情监测 物联网" 检索。
  3. cnki_batch "粮情监测 物联网" 一键检索+下载+导入 Zotero。

⚠️ 说明与限制

  • PDF 自动关联需 Zotero 桌面端在运行(走本地 connector);未运行则降级为仅写元数据。
  • 若系统配置了 HTTP 代理,访问 Zotero 本地端口需绕过代理 —— 本项目已用 httpx(trust_env=False) 处理。
  • 仅供个人学习研究用途,请遵守 CNKI 服务条款与所在机构的使用规定。

🛠 开发

诊断脚本见 tests/inspect_* / probe_*):CNKI 改版导致选择器失配时,运行它们 dump 实时 DOM 重新定位。实测要点记录在 CLAUDE.md

License

MIT

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured