Skip to main content
Glama

cnki-mcp

Self-maintained CNKI MCP server in TypeScript. Pure HTTP with an in-process slider-captcha solver — no browser, no Python, no pinned SDK.

Requirements

  • Node >= 20 (NODE_USE_ENV_PROXY needs Node >= 24)

  • Egress from mainland China — the domestic CNKI site refuses cross-border access (see Network)

Related MCP server: HUST CNKI Research MCP

Quick start

git clone https://github.com/fabea87/cnki-mcp.git
cd cnki-mcp
npm install
npm run build

node dist/scripts/net-check.js                 # egress + captcha-gate check
node dist/scripts/smoke.js "corpus linguistics" # end-to-end check

Optional global install: npm install -g . provides a cnki-mcp binary.

Session, cache, and quota state live in ~/.pi/agent/state/cnki-mcp; override with CNKI_STATE_DIR.

MCP client setup

This is a stdio server. Any stdio MCP client accepts:

{ "command": "node", "args": ["/abs/path/to/cnki-mcp/dist/src/index.js"] }
// or after a global install:
{ "command": "cnki-mcp" }

Claude Desktop, Cursor, VS Code, and Codex use the same command/args under their own mcpServers / servers keys. Claude Code:

claude mcp add cnki -- node /abs/path/to/cnki-mcp/dist/src/index.js

For pi, put the same object under mcpServers.cnki in ~/.pi/agent/mcp.json, then /reload or /mcp reconnect cnki.

HTTP/SSE-only clients need a bridge:

npx -y mcp-remote@latest --transport stdio -- node /abs/path/to/cnki-mcp/dist/src/index.js

Tools

Tool

Purpose

cnki_search

Search by keyword, with search type, paging, sort, resource and year filters.

cnki_get_paper_detail

Full metadata plus GB/T 7714 / APA / BibTeX / RIS citations.

cnki_cite

Batch citations (up to 20).

cnki_warm

Re-solve the captcha and rebuild the session.

cnki_status

Session, quota, and cache status.

In list results, cited=null means zero citations (CNKI omits empty cells).

Network

Domestic CNKI (www.cnki.net, kns.cnki.net) serves mainland IPs only; overseas access requires a different, unsupported platform. A fresh session is always redirected to a slider captcha — session admission, not rate limiting. Keep CNKI on a mainland route:

rules:
  - DOMAIN-SUFFIX,cnki.net,DIRECT
  - DOMAIN-SUFFIX,cnki.com.cn,DIRECT
  - DOMAIN-SUFFIX,kns.cnki.net,DIRECT

Node's fetch ignores proxy environment variables unless enabled: set NODE_USE_ENV_PROXY=1 alongside HTTP_PROXY / HTTPS_PROXY, and keep CNKI hosts in NO_PROXY. With a system-level TUN / transparent proxy, no variables are needed (net-check reports DISABLED -> requests go out directly). If mainland egress is unavailable, run the server on a mainland machine and bridge it with mcp-remote / supergateway.

Configuration

Variable

Default

Purpose

CNKI_STATE_DIR

~/.pi/agent/state/cnki-mcp

Session, cache, quota files

CNKI_MIN_GAP_MS

2000

Minimum gap between requests

CNKI_DAILY_QUOTA

300

Rolling 24-hour request cap

CNKI_CACHE_TTL_MS

86400000

Query cache TTL

CNKI_TIMEOUT_MS

30000

Per-request timeout

CNKI_AUTO_WARM

1

Re-solve captcha on session expiry

CNKI_UA

Built-in Chrome UA

Custom User-Agent

Layout

src/index.ts     MCP tool registration (stdio)
src/cnki/        HTTP, session, captcha, search, detail, citations
src/store/       JSON cache, serial rate limiter
scripts/         smoke, net-check, paging-test, captcha probe

Limitations

  • Online-first papers have no volume/issue/pages; pass hint_journal / hint_date from the search row.

  • Paging requires page 1 first (server-side turnpage token); the client caches it.

  • Only relevance and date sorting are exposed; citation/download sorting is unverified.

  • Reference and citation lists use a separate AJAX endpoint (not implemented).

  • CNKI prohibits automated scraping; raising quotas is at your own risk.

  • stdio only; no HTTP endpoint.

Available Tools

5 tools
cnki_cite批量引文A

批量抓取多条文献并只返回引文文本(GB/T 7714 / APA / BibTeX / RIS)。可直接粘进 Zotero 或稿件。

Inputs: urls (required), style.

cnki_get_paper_detail知网文献详情A

根据详情页 URL 抓取完整元数据:题名、作者、机构、刊名/年/卷/期/页、DOI、摘要、关键词、基金、分类号,并本地生成 GB/T 7714、APA、BibTeX、RIS 引文。

Inputs: url (required), hint_date, use_cache, hint_journal.

cnki_status会话与配额状态A

显示 cookie 会话状态、今日请求配额、缓存条数与当前配置。

Inputs: no named parameters.

cnki_warm重建知网会话A

重新通过安全验证(自动解拼图滑块)并保存 cookie 会话。会话失效或换网络后调用。

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 5 tools

    Disambiguation4/5

    Each tool has a clear anchor: session warm-up, search, single-paper metadata, batch citations, and status. The only real overlap is between cnki_get_paper_detail and cnki_cite, which both fetch metadata and emit citations, but the descriptions differentiate them (single paper + full metadata vs. batch + citation text only) well enough to avoid misselection.

    Naming Consistency5/5

    All tools share the cnki_ prefix and snake_case with an action-oriented second segment (warm, search, get_paper_detail, cite, status). The pattern is predictable and readable throughout.

    Tool Count4/5

    Five tools map cleanly onto the domain's lifecycle (auth, search, detail, cite, diagnostics) with no filler. It is slightly lean — no export or batch-search variant — but nothing feels redundant.

    Completeness4/5

    The path search → detail → cite is fully covered, plus session recovery and quota introspection which are real operational needs for a scraped source. Minor gaps remain around advanced querying (author/journal filters, pagination control) and bulk export, but agents can work around them with the existing tools.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants to search CNKI (China National Knowledge Infrastructure), download PDFs, and import them into Zotero with automatic PDF attachment.
      34
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP server for deep CNKI academic search, retrieving multi-dimensional data (abstracts, keywords, references, citations, similar papers, keyword weights) and enabling citation network traversal via Playwright-based API interception.
      16
      16
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      MCP server for searching Chinese academic literature from CNKI Space, returning metadata such as title, authors, year, and links, and retrieving abstracts and degree details. Enables agents to query CNKI without an account.
      2
      2
      MIT