Skip to main content
Glama

nwafu-mcp · Northwest A&F University Campus Information MCP Toolkit

Provides Agents deployed on any agent platform with a set of tools compliant with the MCP protocol, covering three core capabilities:

  1. Campus channel hot summary: Fetches recent hot posts from the official QQ channel of Northwest A&F University (pd.qq.com/g/inwafu1934), ranks them by interaction count, and automatically categorizes them into "Activities / Competitions / Notices / Recommendations / Tips / Help" and other categories; every important item is accompanied by the source post title and link, ensuring traceability.

  2. Official website quick query: Quickly looks up recent activities, competitions, notices, and recruitment information through the full-text indexes of the official website (www.nwafu.edu.cn) and the news network; keywords such as "College of Plant Protection" or "Academic Affairs Office" can be passed in to narrow the search scope.

  3. Cross-site custom search: Automatically splits the user's question into search terms, searches both the official website full-text index and recent campus channel posts, then merges and outputs the results; all results are formatted as readable Markdown with links to the original sources.


Features

  • Standard MCP implementation: Based on the official mcp Python SDK (FastMCP) with stdio transport, ready to connect directly to Claude Desktop, Cursor, Windsurf, and any MCP-compatible agent platform.

  • Traceable information: Every conclusion item carries the source title and original link; important information is given a dedicated "Key Reminder / Timeliness Reminder" section.

  • Smart categorization: The rule engine automatically classifies channel posts into "Recommendations / Tips / Activities / Competitions / Notices / Help" and other categories, sorted within each group by popularity (likes + weighted comments).

  • Precise keyword search: Official website queries support any keyword to narrow the scope (e.g., college name, department name, or item name).

  • Robust fault tolerance: Request timeouts, retries, randomized rate-limit delays, and Cookie expiry warnings are built in; a failure of one tool does not affect other tools.

  • Privacy compliance: Only publicly visible content is fetched, without bypassing login/permission checks; Cookies are injected via environment variables and never written into the code repository.


Related MCP server: zju-mcp

Tool List

Tool

Purpose

Key Parameters

campus_channel_summary

Smart summary of recent hot posts on the campus QQ channel (hot ranking + categorization + key information)

window_hours time window, max_posts fetch volume, top_n number of hot-ranking entries, include_comments whether to fetch hot comments

official_site_recent

Quick query and summary of recent notices/activities/competitions/recruitment on the official website

category category, keyword to narrow the scope (e.g., college name), days time range, max_results

official_site_search

Full-text search of the official website (custom keywords)

query core term, keyword additional qualifier, days, max_results

campus_question_search

Cross-site custom question search over "official website + campus channel"

question original question text, keywords optional explicit search terms, days, include_channel

All tools output Markdown text with the structure: data source, fetch time, query conditions, result list (title / date / source / summary / link), and key reminders.


How It Works

Campus QQ Channel

The Tencent Channel web client is purely front-end rendered; its public data comes from a protobuf-over-JSON gateway:

POST https://pd.qq.com/qunng/guild/gotrpc/noauth/trpc.qchannel.commreader.ComReader/<Method>
x-oidb: {"uint32_service_type": 11 时间线 | 5 评论}

Public content is anonymously readable, but the gateway requires a browser-level session Cookie (p_uin + uuid + EO-Bot-Js-Token). This tool:

  • By default, pulls the latest N posts (by publish time) from the "Post Square" sub-channel (670126629);

  • Estimates popularity with 点赞数 + 2 × 评论数 and picks the hottest posts within the window;

  • Automatically categorizes posts with a rule engine and separately highlights important information (notices/announcements/registration/deadlines/exams, etc.);

  • Optionally fetches hot comments for hot-ranking posts (GetFeedComments).

Note: The "hot sort" endpoint of GetGuildFeeds returned empty data in real-world testing, so the hot ranking uses the "recent posts × interaction count" approach, which better matches the meaning of "recently hot".

University Official Website

The university's main site and news network use 通元 CMS full-text search:

GET https://www.nwsuaf.edu.cn/cms/web/search/index.jsp
    ?query=<关键词>&siteID=<站点ID>&searchScope=0&channelID=&matchType=0
    &sortField=publishDate&order=1&date=<3|6|12>&page=<页码>
  • siteID=32e6d9be... is the main-site index (covering all colleges/departments of the university);

  • Search terms are generated by category (notices/announcements, activities/lectures/forums, competitions/contests, recruitment, etc.), merged with user keywords, and fetched page by page, parsing title, date, source, summary, and original link;

  • The default time range is the recent 90 days (mapped to the index's 3/6/12-month filters).


Quick Start (Local Run)

cd nwafu-mcp
uv sync --extra dev
uv run nwafu-export-cookies --out cookies.json

The script opens the channel page in your local Edge/Chrome to establish a session and exports the Cookie. Then write the cookie_header from cookies.json into an environment variable:

$env:PDQQ_COOKIES = "p_uin=xxx; uuid=xxx; EO-Bot-Js-Token=xxx"
# 或
$env:NWAFU_COOKIE_FILE = "F:\path\to\cookies.json"

Cookies expire (the anti-crawler token is bound to the browser instance); for cloud deployment, refresh them regularly.

2. Test the Tool Functions Directly (Without an MCP Client)

uv run python -c "
import os
os.environ['NWAFU_COOKIE_FILE'] = 'cookies.json'
from nwafu_mcp.server import official_site_recent
print(official_site_recent(category='通知', keyword='植保学院'))
"

3. Run as an MCP Server

uv run nwafu-mcp

Connecting to MCP Clients

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "nwafu-campus": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/unielevotor/nwafu-AgentPlatformMCP",
        "nwafu-mcp"
      ],
      "env": {
        "PDQQ_COOKIES": "p_uin=xxx; uuid=xxx; EO-Bot-Js-Token=xxx"
      }
    }
  }
}

Cursor / Windsurf / General Platforms (JSON Form)

{
  "mcpServers": {
    "nwafu-campus": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/unielevotor/nwafu-AgentPlatformMCP", "nwafu-mcp"],
      "env": {
        "PDQQ_COOKIES": "p_uin=xxx; uuid=xxx; EO-Bot-Js-Token=xxx",
        "PDQQ_GUILD_ID": "inwafu1934",
        "PDQQ_CHANNEL_ID": "670126629"
      }
    }
  }
}

It can also be installed with pip install git+https://github.com/unielevotor/nwafu-AgentPlatformMCP and then started directly with the nwafu-mcp command.


GitHub Deployment Steps

  1. Push to the GitHub repository (unielevotor/nwafu-AgentPlatformMCP):

git remote add origin https://github.com/unielevotor/nwafu-AgentPlatformMCP.git
git push -u origin main
  1. Make sure the repository is Public (for a private repository, the target agent platform must be able to access GitHub credentials).

  2. In the agent platform's MCP configuration, fill in the uvx --from git+... startup command above and inject environment variables such as PDQQ_COOKIES.


Environment Variables

Variable

Required

Description

PDQQ_COOKIES

Required for channel tools

QQ channel browser session Cookie

NWAFU_COOKIE_FILE

Required for channel tools

Points to the JSON exported by nwafu-export-cookies

PDQQ_GUILD_ID

No

Channel identifier, default inwafu1934

PDQQ_CHANNEL_ID

No

Sub-channel ID, default 670126629 (Post Square)

PDQQ_MIN_DELAY / PDQQ_MAX_DELAY

No

Channel request interval (seconds), default 0.3–0.8

NWAFU_TIMEOUT

No

Per-request timeout (seconds), default 30

See .env.example.


Sample Output (Excerpt)

# 🎓 西农校园频道 · 近期热门总结

> 数据来源:西北农林科技大学官方 QQ 频道 | 时间窗口:近 72 小时 | 帖子数:48

## 🔥 热度榜
1. **中元节鬼是真的多啊…**(👍7 · 💬1 · 08-27)
   来源:[中元节鬼是真的多啊](https://pd.qq.com/g/inwafu1934/post/...)

## 🏆 竞赛(2)
- **关于举办2026年创新创业大赛的通知**(👍5 · 💬2 · 08-26)
  来源:[…](https://pd.qq.com/g/inwafu1934/post/...)

## ⚠️ 重点信息(建议优先查看)
- [关于选课时间安排的通知](https://pd.qq.com/g/inwafu1934/post/...)
# 📢 西北农林科技大学官网 · 近期信息查询

> 查询条件:分类=通知 | 关键词=植保学院 | 时间范围:近 90 天 | 结果数:12

1. **关于举办2026年植保论坛系列学术报告会(十七)的通知**(2026-08-26 · 植物保护学院)
   [查看原文](https://ppc.nwafu.edu.cn/xzbg/...)

Compliance and Usage Recommendations

  • Only fetch publicly visible content; never bypass login, paywall, or permission checks.

  • Random UA, random delays, and failure retries are built in. Do not reduce the delays for high-frequency scraping when deploying, and comply with the target platform's terms of service and applicable regulations such as the Personal Information Protection Law.

  • For important information (registration deadlines, exam arrangements, etc.), always refer to the official source; tool output is for quick reference only.

  • Channel Cookies contain session identifiers; never commit them to a public repository — always inject them via environment variables.


FAQ

Symptom

Resolution

Channel tool reports "Cookie not configured"

Run nwafu-export-cookies --out cookies.json locally, then configure the environment variables

Channel tool reports retcode=150/4000

Cookie expired or anti-crawler token missing; re-export them

Official website query returns empty results

Widen days, remove the keyword, or switch category, then retry

No Edge/Chrome in the cloud

Install playwright and run python -m playwright install chromium, or periodically export the Cookie locally and inject it

Directory Structure

src/nwafu_mcp/
  server.py          MCP 服务器与四个工具定义
  qq_channel.py      QQ 频道数据层(时间线/热评)
  official_site.py   官网全文检索数据层
  classify.py        帖子分类与热度评分
  format.py          Markdown 报告排版
  config.py          环境变量与默认配置
  export_cookies.py  本地导出频道 Cookie 的 CLI
tests/               单元测试
scripts/mcp_smoke.py 端到端 MCP 冒烟测试(连接 stdio server 并调用全部工具)

Available Tools

4 tools
campus_channel_summaryA

抓取西北农林科技大学官方 QQ 频道(https://pd.qq.com/g/inwafu1934)近期帖子,按互动量(点赞+评论)排名出热度榜,并自动归类为活动/竞赛/通知/推荐/贴士/求助/其他,输出 Markdown 总结;每条重要信息都附来源帖子标题与链接。

Inputs: top_n, max_posts, window_hours, comment_top_n, +1 more. Returns: result

official_site_recentA

查询西北农林科技大学官网(https://www.nwafu.edu.cn/)最近的活动、竞赛、通知、招聘等官方信息并输出 Markdown 总结。支持传入关键词(如学院名)缩小检索范围,例如 keyword='植保学院' 只返回植保学院相关通知。

Inputs: days, keyword, category, max_results. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool targets a fairly distinct retrieval need: QQ channel hot summaries, official-site recent info, official-site full-text search, and cross-source question search. The only mild overlap is between official_site_recent and official_site_search, but their descriptions make the difference clear enough.

    Naming Consistency4/5

    Tool names are consistently lowercase snake_case and follow recognizable source prefixes like campus_* and official_site_*. However, suffixes mix result-oriented terms (summary, recent) with action terms (search), so they do not follow a strict verb_noun pattern throughout.

    Tool Count5/5

    Four tools is well-scoped for a campus information retrieval server. Each tool covers a distinct retrieval workflow without redundancy, and the set is neither too thin nor overloaded for its stated purpose.

    Completeness4/5

    The set covers recent official announcements, full-text official-site search, QQ channel hot content, and a combined question-based search across both sources. A dedicated channel-only keyword search is missing, but campus_question_search partially fills that gap, so the surface is reasonably complete.

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      A
      quality
      D
      maintenance
      Enables interaction with Zhejiang University's learning platform (学在浙大 / 智云课堂) via MCP tools, allowing natural language commands to check todos, view schedules, fetch lecture transcripts, and submit homework.
      7
      9
      -
    • A
      license
      A
      quality
      B
      maintenance
      Provides Google search, URL extraction, and academic paper inline extraction without API keys, enabling search and content retrieval from a single MCP server.
      5
      593 npm
      MIT
    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables searching the Xiangtan University Computer Science College official website, retrieving article content and attachments, and listing common sections through a Cloudflare-hosted MCP server.
      -