博客RSS服务器

一个最小化的模型上下文协议(MCP)服务器,提供博客RSS/Atom订阅源的工具,包括列出文章、获取文章内容、返回最近文章、基本博客信息以及按需搜索文章内容。

  • by S1R15H
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 S1R15H/blog-mcp-server

使用说明

🌟博客RSS MCP服务器

一个最小化的模型上下文协议(MCP)服务器,提供了用于处理博客RSS/Atom订阅源的工具。它能够列出帖子、获取帖子内容、返回最新帖子、提供基本博客信息,并且可以根据需求搜索帖子内容。

这里面有什么

  • main_server.py — 配备工具的MCP服务器:
    • list_blog_posts() → [{标题, 标识符(URL),发布日期}]
    • get_blog_post(slug) → {slug(别名), url(网址), content(内容)}(内容从页面HTML中提取,优先考虑 )
    • get_recent_posts(count=5) → 最近帖子(简单倒序)
    • get_blog_info() → 博客元数据
    • search_full_text(query) → 按需搜索(逐条获取帖子并直接搜索文本)
  • run_local_tests.py — 快速本地烟雾测试,用于测试工具而无需启动MCP服务器。
  • Dockerfile — 用于运行服务器的容器镜像。
  • requirements.txt — Python 依赖项。

要求

  • Python 3.10+
  • 推荐:使用虚拟环境(例如。, .venv)

安装依赖项:

pip install -r requirements.txt

注:适用于 Python 3.13+ feedparser 导入已移除的stdlib模块 cgi; 此仓库包含 python-legacy-cgi 在要求中确保兼容性。

配置

根据需要设置环境变量:

  • RSS_FEED_URL (必填)→ 您的RSS/Atom订阅源的完整URL(例如。, https://example.com/feed.xml)
  • MCP_TRANSPORT (可选)→ stdio (默认), sse或者 streamable-http
  • MCP_MOUNT_PATH (可选)→ 适用于相应传输的挂载路径

示例:

export RSS_FEED_URL="https://www.sirishgurung.com/rss.xml"
export MCP_TRANSPORT=stdio

在本地运行(MCP服务器)

python main_server.py

使用虚拟环境(venv):

.venv/bin/python main_server.py

本地冒烟测试(无需MCP客户端)

.venv/bin/python run_local_tests.py

该脚本将打印博客信息,列出帖子,获取单个帖子的内容,并执行一个简单的按需搜索。

Docker

构建镜像:

docker build -t blog-rss-mcp:latest .

使用stdio传输运行(适用于启动容器并通过stdio进行通信的MCP客户端):

docker run --rm -i \
	-e RSS_FEED_URL="https://www.sirishgurung.com/rss.xml" \
	-e MCP_TRANSPORT=stdio \
	blog-rss-mcp:latest

使用基本HTTP传输运行(可选):

docker run -d \
	-e RSS_FEED_URL="https://www.sirishgurung.com/rss.xml" \
	-e MCP_TRANSPORT=streamable-http \
	-e MCP_MOUNT_PATH="/mcp" \
	-p 5000:5000 \
	--name blog-rss-mcp \
	blog-rss-mcp:latest

使用Claude客户端设置Docker Desktop

前提条件:已安装Docker Desktop并启用了MCP Toolkit。已安装Claude桌面版。

  1. 构建一个Docker镜像首先,使用提供的项目文件(Dockerfile、Python服务器等)构建一个名为blog-mcp-server的本地Docker镜像。
docker build -t blog-rss-mcp:latest .
  1. 定义工具你创建一个 ~/.docker/mcp/catalogs/custom.yaml 作为“目录”的文件。此文件定义了新的“博客”工具,列出了其所有功能(如list_blog_posts、get_blog_posts等),并告诉系统使用您刚刚构建的Docker镜像。
yamlversion: 2
name: blog-mcp-server
displayName: Blog RSS MCP Server
registry:
  blog-rss-mcp:
    description: "Local MCP server exposing blog RSS tools (list_blog_posts, get_blog_post, get_recent_posts, get_blog_info, search_full_text)."
    title: "Blog RSS MCP Server"
    type: server
    dateAdded: "2025-10-23T00:00:00Z"
    image: blog-mcp-server:latest
    ref: ""
    readme: "README.md"
    toolsUrl: ""
    source: ""
    upstream: ""
    icon: ""
    tools:
      - name: list_blog_posts
      - name: get_blog_post
      - name: get_recent_posts
      - name: get_blog_info
      - name: search_full_text
    metadata:
      category: productivity
      tags:
        - blog
        - rss
        - mcp
        - search
      owner: local
    env:
      - name: RSS_FEED_URL
        description: "URL to the blog RSS feed (required)."
        required: true
      - name: MCP_TRANSPORT
        description: "Transport used by FastMCP. Use 'stdio' for local client-managed lifecycle."
        default: "stdio"
      - name: MCP_MOUNT_PATH
        description: "Optional mount path for transports like SSE."
        default: ""

  1. 注册该工具你编辑 ~/.docker/mcp/registry.yaml 文件用于在MCP(模型-组件-处理器)系统中正式注册新的博客工具。
registry:
  blog-rss-mcp:
    ref: ""
  1. 配置Claude桌面版你编辑主文件 claude_desktop_config.json,以指示 Claude 应用程序加载你新的自定义 catalog 文件 custom.yaml。
    • macOS:~/Library/Application Support/Claude/claude_desktop_config.json(中文可表述为:在 macOS 系统中,路径为:用户目录/Library/Application Support/Claude/claude_desktop_config.json)
    • Windows:%APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json 翻译为中文是:“Linux:~/.config/Claude/claude_desktop_config.json”(注:这里的路径通常表示用户主目录下的.config/Claude目录中的claude_desktop_config.json文件,但中文翻译中路径通常保持原样,不进行意译)。不过,为了更自然地表达,也可以稍作调整为:“在Linux系统中,文件路径为:~/.config/Claude/claude_desktop_config.json”

你也可以找到一个 编辑配置 在“设置”->“开发者”窗口中的选项。 这一步需要将文件路径添加到命令参数中,并确保您的主目录路径正确无误。

{
    "mcpServers": {
      "mcp-toolkit-gateway": {
        "command": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "-v", "/var/run/docker.sock:/var/run/docker.sock",
          "-v", "[YOUR_HOME]/.docker/mcp:/mcp",
          "docker/mcp-gateway",
          "--catalog=/mcp/catalogs/docker-mcp.yaml",
          "--catalog=/mcp/catalogs/custom.yaml",
          "--config=/mcp/config.yaml",
          "--registry=/mcp/registry.yaml",
          "--tools-config=/mcp/tools.yaml",
          "--transport=stdio"
        ]
      }
    }
  }
  1. 重启并测试重启Claude桌面应用程序后,新的博客功能将可用。您可以向Claude提出“获取最近的博客”或“列出所有博客”的请求来测试这些功能

输出样本

注意事项与故障排除

  • 你可以在 Dockerfile 中将你的 RSS 链接添加到 RSS_FEED_URL 中,以将其设为默认值。
  • 日志输出到标准错误(stderr);标准输入输出(stdio)传输消息输出到标准输出(stdout)(对MCP客户端是安全的)。
  • 如果在最小基础镜像中HTTPS源无法获取,请在容器中安装系统CA证书。
  • 如果 mcp.run() 版本之间的签名更改,请检查 FastMCP.run 在您已安装的包中进行相应调整,并据此修改调用。