# MCP Server · 成都青年之家活动抓取器(Python)
一个基于 **Model Context Protocol (MCP)** 的服务端,抓取并解析
[成都青年之家](https://cdyouth.cdcyl.org.cn/jgc/) 的最新「精彩活动」列表,返回**结构化活动数组**。
- 语言:Python 3.9+
- 传输:**SSE(Server-Sent Events)**
- 框架:Starlette + Uvicorn
- SDK:`mcp`(官方 Python SDK)+ `FastMCP`
- 解析:httpx + BeautifulSoup4 + lxml
---
## ✨ 功能特性
- 🔍 **GET 抓取**:请求 `https://cdyouth.cdcyl.org.cn/jgc/`,直接解析首页 HTML。
- 📝 **结构化输出**:活动 ID、标题、标签、分类、时间、地址、状态、浏览量、封面图、详情链接等。
- 🧩 **MCP Tool**:`fetch_chengdu_youth_activities(limit?: int)`。
- 🔄 **SSE 传输**:提供 `/sse`(建立会话)与 `/messages`(客户端发消息)端点。
- ❤️ **健康检查**:`/healthz` 返回 200 `ok`,便于托管/监控。
---
## 📦 安装
### 方式 A:从源代码本地安装(推荐开发用)
```bash
# 创建虚拟环境(可用 uv/pipenv/venv,以下以 uv 为例)
uv venv
uv pip install -e .
Raw data
{
"_id": null,
"home_page": null,
"name": "mcp-cd-youth",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "chengdu, mcp, model context protocol, sse, youth, \u6d3b\u52a8",
"author": null,
"author_email": "fsyj123 <ycffsyj@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/9b/6d/76b2f7b465682ba559df012999984fab6089f18284804196fd81d3a52080/mcp_cd_youth-1.0.3.tar.gz",
"platform": null,
"description": "# MCP Server \u00b7 \u6210\u90fd\u9752\u5e74\u4e4b\u5bb6\u6d3b\u52a8\u6293\u53d6\u5668\uff08Python\uff09\n\n\u4e00\u4e2a\u57fa\u4e8e **Model Context Protocol (MCP)** \u7684\u670d\u52a1\u7aef\uff0c\u6293\u53d6\u5e76\u89e3\u6790\n[\u6210\u90fd\u9752\u5e74\u4e4b\u5bb6](https://cdyouth.cdcyl.org.cn/jgc/) \u7684\u6700\u65b0\u300c\u7cbe\u5f69\u6d3b\u52a8\u300d\u5217\u8868\uff0c\u8fd4\u56de**\u7ed3\u6784\u5316\u6d3b\u52a8\u6570\u7ec4**\u3002\n\n- \u8bed\u8a00\uff1aPython 3.9+\n- \u4f20\u8f93\uff1a**SSE\uff08Server-Sent Events\uff09**\n- \u6846\u67b6\uff1aStarlette + Uvicorn\n- SDK\uff1a`mcp`\uff08\u5b98\u65b9 Python SDK\uff09+ `FastMCP`\n- \u89e3\u6790\uff1ahttpx + BeautifulSoup4 + lxml\n\n---\n\n## \u2728 \u529f\u80fd\u7279\u6027\n\n- \ud83d\udd0d **GET \u6293\u53d6**\uff1a\u8bf7\u6c42 `https://cdyouth.cdcyl.org.cn/jgc/`\uff0c\u76f4\u63a5\u89e3\u6790\u9996\u9875 HTML\u3002\n- \ud83d\udcdd **\u7ed3\u6784\u5316\u8f93\u51fa**\uff1a\u6d3b\u52a8 ID\u3001\u6807\u9898\u3001\u6807\u7b7e\u3001\u5206\u7c7b\u3001\u65f6\u95f4\u3001\u5730\u5740\u3001\u72b6\u6001\u3001\u6d4f\u89c8\u91cf\u3001\u5c01\u9762\u56fe\u3001\u8be6\u60c5\u94fe\u63a5\u7b49\u3002\n- \ud83e\udde9 **MCP Tool**\uff1a`fetch_chengdu_youth_activities(limit?: int)`\u3002\n- \ud83d\udd04 **SSE \u4f20\u8f93**\uff1a\u63d0\u4f9b `/sse`\uff08\u5efa\u7acb\u4f1a\u8bdd\uff09\u4e0e `/messages`\uff08\u5ba2\u6237\u7aef\u53d1\u6d88\u606f\uff09\u7aef\u70b9\u3002\n- \u2764\ufe0f **\u5065\u5eb7\u68c0\u67e5**\uff1a`/healthz` \u8fd4\u56de 200 `ok`\uff0c\u4fbf\u4e8e\u6258\u7ba1/\u76d1\u63a7\u3002\n\n---\n\n## \ud83d\udce6 \u5b89\u88c5\n\n### \u65b9\u5f0f A\uff1a\u4ece\u6e90\u4ee3\u7801\u672c\u5730\u5b89\u88c5\uff08\u63a8\u8350\u5f00\u53d1\u7528\uff09\n```bash\n# \u521b\u5efa\u865a\u62df\u73af\u5883\uff08\u53ef\u7528 uv/pipenv/venv\uff0c\u4ee5\u4e0b\u4ee5 uv \u4e3a\u4f8b\uff09\nuv venv\nuv pip install -e .\n",
"bugtrack_url": null,
"license": null,
"summary": "MCP Server (STDIO) to fetch and parse Chengdu Youth Center activities",
"version": "1.0.3",
"project_urls": null,
"split_keywords": [
"chengdu",
" mcp",
" model context protocol",
" sse",
" youth",
" \u6d3b\u52a8"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9e85a2c02ea7180663e54e794bde203e5688d292e3aed5230dddf5e90961df2e",
"md5": "5ac549c191368f7b18f6dbdd0e234f99",
"sha256": "7d566b62781ae00d5ab5195cf71219b80f3eba16da5326a82571e5200007408f"
},
"downloads": -1,
"filename": "mcp_cd_youth-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5ac549c191368f7b18f6dbdd0e234f99",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 5640,
"upload_time": "2025-08-24T10:48:46",
"upload_time_iso_8601": "2025-08-24T10:48:46.598461Z",
"url": "https://files.pythonhosted.org/packages/9e/85/a2c02ea7180663e54e794bde203e5688d292e3aed5230dddf5e90961df2e/mcp_cd_youth-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "9b6d76b2f7b465682ba559df012999984fab6089f18284804196fd81d3a52080",
"md5": "d2433afa0c16623d4b016c7c5538ae66",
"sha256": "491220badaec67baca3ae84bd898b15a23687f768bc84f14c3f844016ef98c35"
},
"downloads": -1,
"filename": "mcp_cd_youth-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "d2433afa0c16623d4b016c7c5538ae66",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 4874,
"upload_time": "2025-08-24T10:48:47",
"upload_time_iso_8601": "2025-08-24T10:48:47.752466Z",
"url": "https://files.pythonhosted.org/packages/9b/6d/76b2f7b465682ba559df012999984fab6089f18284804196fd81d3a52080/mcp_cd_youth-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-24 10:48:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "mcp-cd-youth"
}