Skip to main content
Glama
fanfou-mcp

fanfou-mcp

by kingcos

title: 饭否 MCP 服务器 emoji: 🍚 colorFrom: blue colorTo: purple sdk: gradio sdk_version: "5.36.2" app_file: app.py pinned: false

饭否 MCP 服务器

基于 FastMCP 构建的饭否(Fanfou)MCP 服务器,提供饭否相关的工具和服务。

Publish to PyPI

Deploy on Spaces

Related MCP server: DDG MCP Server

功能特性

  • 🛠️ 基于 FastMCP 框架构建

  • 🔧 提供饭否相关的工具函数

  • 📡 支持 MCP (Model Context Protocol) 协议

  • 🌐 支持 SSE (Server-Sent Events) 方式连接

  • 🐍 使用 Python 3.11+ 开发

演示效果

Claude 中使用效果:

Claude 中使用 fanfou-mcp 演示

Cursor 中使用效果:

Cursor 中使用 fanfou-mcp 演示

快速开始

前提条件

  • Python 3.11+

  • uv 包管理器(用于 uvx 命令)

  • 饭否账号和 API 密钥

客户端配置

MCP 配置

方式1:使用 SSE 方式(基于 Huggingface)

{
  "mcpServers": {
    "fanfou-mcp": {
      "url": "https://kingcos-fanfou-mcp.hf.space/gradio_api/mcp/sse",
      "headers": {
        "X-Fanfou-Api-Key": "your_api_key_here",
        "X-Fanfou-Api-Secret": "your_api_secret_here",
        "X-Fanfou-OAuth-Token": "your_oauth_token_here",
        "X-Fanfou-OAuth-Token-Secret": "your_oauth_token_secret_here"
      }
    }
  }
}

Huggingface 项目地址: https://huggingface.co/spaces/kingcos/fanfou-mcp

注意,首次登录可使用用户名密码,以获取 OAuth Token 与 OAuth-Token-Secret,例如:

{
  "mcpServers": {
    "fanfou-mcp": {
      "url": "https://kingcos-fanfou-mcp.hf.space/gradio_api/mcp/sse",
      "env": {
        "X-Fanfou-Api-Key": "your_api_key_here",
        "X-Fanfou-Api-Secret": "your_api_secret_here",
        "X-Fanfou-Username": "your_username_here",
        "X-Fanfou-Password": "your_password_here"
      }
    }
  }
}

方式2:使用 STDIO 方式

{
  "mcpServers": {
    "fanfou-mcp": {
      "command": "uvx",
      "args": ["fanfou-mcp"],
      "env": {
        "FANFOU_API_KEY": "your_api_key_here",
        "FANFOU_API_SECRET": "your_api_secret_here",
        "FANFOU_OAUTH_TOKEN": "your_oauth_token_here",
        "FANFOU_OAUTH_TOKEN_SECRET": "your_oauth_token_secret_here"
      }
    }
  }
}

如果遇到导入错误,请使用强制更新版本:

{
  "mcpServers": {
    "fanfou-mcp": {
      "command": "uvx",
      "args": ["--force-reinstall", "fanfou-mcp"],
      "env": {
        "FANFOU_API_KEY": "your_api_key_here",
        "FANFOU_API_SECRET": "your_api_secret_here",
        "FANFOU_OAUTH_TOKEN": "your_oauth_token_here",
        "FANFOU_OAUTH_TOKEN_SECRET": "your_oauth_token_secret_here"
      }
    }
  }
}

注意,首次登录可使用用户名密码,以获取 OAuth Token 与 OAuth-Token-Secret,例如:

{
  "mcpServers": {
    "fanfou-mcp": {
      "command": "uvx",
      "args": ["fanfou-mcp"],
      "env": {
        "FANFOU_API_KEY": "your_api_key_here",
        "FANFOU_API_SECRET": "your_api_secret_here",
        "FANFOU_USERNAME": "your_username_here",
        "FANFOU_PASSWORD": "your_password_here"
      }
    }
  }
}

方式3:本地开发模式

{
  "mcpServers": {
    "fanfou-mcp": {
      "command": "uv",
      "args": ["--directory", "/path/to/your/fanfou-mcp", "run", "python", "main.py"],
      "env": {
        "FANFOU_API_KEY": "your_api_key_here",
        "FANFOU_API_SECRET": "your_api_secret_here",
        "FANFOU_OAUTH_TOKEN": "your_oauth_token_here",
        "FANFOU_OAUTH_TOKEN_SECRET": "your_oauth_token_secret_here"
      }
    }
  }
}

配置说明:

  • 推荐使用方式1:uvx 会自动从 PyPI 下载和运行最新版本,无需本地安装

  • 方式1(SSE):基于 Huggingface 部署的 Web 服务,通过 HTTP 头传递认证信息,支持多用户隔离

  • 缓存问题:如果遇到导入错误,可能是 uvx 缓存了旧版本,请在配置中将 "args": ["fanfou-mcp"] 改为 "args": ["--force-reinstall", "fanfou-mcp"] 来强制更新

  • OAuth Token 方式:避免每次都需要登录,更安全便捷

  • 首次使用:如果没有 OAuth Token,系统会自动生成并显示 OAuth Token,然后再切换

  • 本地开发:如果你需要修改代码或调试,可以使用方式3

  • 请将环境变量中的占位符替换为你的实际饭否 API 凭据

可用工具

本服务器提供以下工具:

认证相关

  • generate_oauth_token - 生成 OAuth Token

时间线相关

  • get_home_timeline - 获取首页时间线

  • get_user_timeline - 获取用户时间线

  • get_public_timeline - 获取公开时间线

用户和内容相关

  • get_user_info - 获取用户信息

  • get_status_info - 获取饭否内容详情

互动相关

  • manage_favorite - 管理收藏状态

  • manage_friendship - 管理关注状态

发布相关

  • publish_status - 发布文字内容

  • publish_photo - 发布图片内容

  • delete_status - 删除内容

详细的 API 文档请参考:API 文档

文档

许可证

本项目采用 MIT 许可证。详见 LICENSE 文件。

Available Tools

11 tools
delete_statusA

删除饭否内容

调用饭否 API 的 /statuses/destroy.json 接口删除指定的饭否内容。 注意:只能删除自己发布的内容。

Args: status_id: 要删除的饭否内容的 ID confirm: 是否确认删除(二次确认参数)

Returns: 删除结果字典,包含: - 删除 ID: 被删除消息的 ID - 删除结果: 删除是否成功的描述信息 - 重要提示: 关于删除操作的提醒信息

或者确认信息字典,包含:
- 需要确认: 是否需要用户确认
- 内容预览: 要删除的内容预览
- 确认提示: 如何进行确认的说明

Inputs: status_id (required), confirm. Returns: object

generate_oauth_tokenA

生成 OAuth Token

使用用户名密码通过 x_auth 方式生成 OAuth Token,用于后续免密登录。 生成的 Token 会在控制台输出,用户需要手动保存到环境变量中。

环境变量要求:

  • FANFOU_API_KEY: 饭否应用的 API Key

  • FANFOU_API_SECRET: 饭否应用的 API Secret

  • FANFOU_USERNAME: 饭否用户名

  • FANFOU_PASSWORD: 饭否密码

Returns: 包含 OAuth Token 信息的字典,包括 oauth_token 和 oauth_token_secret

Inputs: no named parameters. Returns: object

get_home_timelineA

获取当前用户首页关注用户及自己的饭否时间线

调用饭否 API 的 /statuses/home_timeline.json 接口获取当前用户的首页时间线, 包含用户关注的所有人的最新消息。

注:通常用户询问「我的饭否」时,指的是该时间线,除非用户明确指出「某个用户的饭否」。

Args: count: 获取数量,默认 5 条 max_id: 返回列表中内容最新 ID,用于分页获取更早的内容

Returns: 首页时间线列表,每个元素包含: - 饭否内容: 消息文本内容(HTML 格式) * 转发:以「转@」开头,后跟用户链接,如 转@kingcos,其中 href 中的是用户 ID,inner Text 是被转发用户的显示名称,一条饭否可能有多个转发 * 话题:以「#」包围,如 #正在播放#,其中 q/ 后面的是话题名,一条饭否可能有多个话题 * 审核状态:如果内容末尾显示「【审核中】」,表示该内容正在审核中 - 发布 ID: 消息的唯一标识符 - 发布时间: 消息发布时间,需转为北京时间 - 发布者: 发布者的用户名 - 发布者 ID: 发布者的用户 ID - 图片链接: 如果包含图片,则提供图片链接

Inputs: count, max_id. Returns: result

get_public_timelineA

获取公开时间线

调用饭否 API 的 /statuses/public_timeline.json 接口获取饭否全站最新的公开消息, 这些是所有用户可见的公开饭否内容。

当提供搜索关键词时,会调用 /search/public_timeline.json 接口进行搜索。

Args: count: 获取数量,默认 5 条 max_id: 返回列表中内容最新 ID,用于分页获取更早的内容 q: 搜索关键词,如果为空则获取普通公开时间线;如果不为空则搜索包含该关键词的公开消息

Returns: 公开时间线列表,每个元素包含: - 饭否内容: 消息文本内容(HTML 格式) * 转发:以「转@」开头,后跟用户链接,如 转@kingcos,其中 href 中的是用户 ID,inner Text 是被转发用户的显示名称,一条饭否可能有多个转发 * 话题:以「#」包围,如 #正在播放#,其中 q/ 后面的是话题名,一条饭否可能有多个话题 * 审核状态:如果内容末尾显示「【审核中】」,表示该内容正在审核中 - 发布 ID: 消息的唯一标识符 - 发布时间: 消息发布时间,需转为北京时间 - 发布者: 发布者的用户名 - 发布者 ID: 发布者的用户 ID - 图片链接: 如果包含图片,则提供图片链接

Inputs: count, max_id, q. Returns: result

get_status_infoA

获取某条饭否内容的具体信息

调用饭否 API 的 /statuses/show/id.json 接口获取指定饭否内容的详细信息。

Args: status_id: 饭否内容的 ID

Returns: 饭否内容的详细信息字典,包含: - 饭否内容: 消息文本内容(HTML 格式) * 转发:以「转@」开头,后跟用户链接,如 转@kingcos,其中 href 中的是用户 ID,inner Text 是被转发用户的显示名称,一条饭否可能有多个转发 * 话题:以「#」包围,如 #正在播放#,其中 q/ 后面的是话题名,一条饭否可能有多个话题 * 审核状态:如果内容末尾显示「【审核中】」,表示该内容正在审核中 - 发布 ID: 消息的唯一标识符 - 发布时间: 消息发布时间,需转为北京时间 - 发布者: 发布者的显示名称 - 发布者 ID: 发布者的用户 ID - 是否收藏: 当前用户是否收藏了该消息 - 是否是自己: 是否是当前用户发布的消息 - 发布位置: 消息发布的地理位置 - 回复信息: 如果是回复消息,包含被回复的状态 ID、用户 ID 和用户名 - 图片base64: 如果包含图片,则提供图片的 base64 编码(data URL 格式) - 图片链接: 如果包含图片,则提供原始图片链接作为备用

Inputs: status_id (required). Returns: object

get_user_infoA

获取用户信息

调用饭否 API 的 /users/show.json 接口获取指定用户的详细信息。 如果 user_id 为空,则获取当前登录用户的信息。

Args: user_id: 用户 ID,如果为空则获取当前用户信息

Returns: 用户信息字典,包含: - 用户 ID: 用户的唯一标识符 - 用户名: 用户名 - 位置: 用户所在位置 - 性别: 用户性别 - 生日: 用户生日 - 描述: 用户个人描述 - 头像: 用户头像链接 - 链接: 用户个人网站链接 - 是否加锁: 账号是否受保护 - 粉丝数: 被关注数量 - 朋友数: 互相关注数量 - 收藏数: 收藏的消息数量 - 发布数: 发布的消息数量 - 照片数: 发布的照片数量 - 是否关注: 当前用户是否关注该用户 - 注册时间: 账号注册时间 - 最新状态: 用户最新发布的消息信息

Inputs: user_id. Returns: object

get_user_timelineA

根据用户 ID 获取某个用户发表内容的时间线

调用饭否 API 的 /statuses/user_timeline.json 接口获取指定用户的时间线。 如果 user_id 为空,则获取当前登录用户的时间线。

当提供搜索关键词时,会调用 /search/user_timeline.json 接口进行搜索。

Args: user_id: 用户 ID,如果为空则获取当前用户时间线 max_id: 返回列表中内容最新 ID,用于分页获取更早的内容 count: 获取数量,默认 5 条 q: 搜索关键词,如果为空则获取普通用户时间线;如果不为空则搜索该用户包含该关键词的消息

Returns: 用户时间线列表,每个元素包含: - 饭否内容: 消息文本内容(HTML 格式) * 转发:以「转@」开头,后跟用户链接,如 转@kingcos,其中 href 中的是用户 ID,inner Text 是被转发用户的显示名称,一条饭否可能有多个转发 * 话题:以「#」包围,如 #正在播放#,其中 q/ 后面的是话题名,一条饭否可能有多个话题 * 审核状态:如果内容末尾显示「【审核中】」,表示该内容正在审核中 - 发布 ID: 消息的唯一标识符 - 发布时间: 消息发布时间,需转为北京时间 - 发布者: 发布者的用户名 - 发布者 ID: 发布者的用户 ID - 图片链接: 如果包含图片,则提供图片链接

Inputs: user_id, max_id, count, q. Returns: result

manage_favoriteA

管理饭否内容的收藏状态

调用饭否 API 的 /favorites/create/id.json 或 /favorites/destroy/id.json 接口 来收藏或取消收藏指定的饭否内容。

Args: status_id: 饭否内容的 ID action: 操作类型,"create" 表示收藏,"destroy" 表示取消收藏 confirm: 是否确认操作(二次确认参数)

Returns: 操作结果字典,包含: - 是否收藏: 操作后的收藏状态 - 操作结果: 操作是否成功的描述信息 - 操作类型: 执行的具体操作(收藏/取消收藏)

或者确认信息字典,包含:
- 需要确认: 是否需要用户确认
- 内容预览: 要操作的内容预览
- 确认提示: 如何进行确认的说明

Inputs: status_id (required), action (required), confirm. Returns: object

manage_friendshipA

管理用户关注状态

调用饭否 API 的 /friendships/create.json 或 /friendships/destroy.json 接口 来关注或取消关注指定用户。

注意:在执行关注操作前,会先调用 get_user_info 查询目标用户信息, 如果目标用户账号受保护(protected),关注操作将变为申请关注, 需要对方确认后才能生效。

Args: user_id: 目标用户的 ID action: 操作类型,"create" 表示关注,"destroy" 表示取消关注 confirm: 是否确认操作(二次确认参数)

Returns: 操作结果字典,包含: - 是否关注: 操作后的关注状态 - 操作结果: 操作是否成功的描述信息 - 操作类型: 执行的具体操作(关注/取消关注) - 用户信息: 目标用户的基本信息 - 特殊情况: 如果是受保护账号的关注申请,会包含相关提示

或者确认信息字典,包含:
- 需要确认: 是否需要用户确认
- 用户预览: 要操作的用户预览
- 确认提示: 如何进行确认的说明

Inputs: user_id (required), action (required), confirm. Returns: object

publish_photoA

发布饭否内容(文字+图片)

调用饭否 API 的 /photos/upload.json 接口发布带图片的内容。

Args: status: 要发布的文字内容(最多140字) photo_url: 图片的网络 URL 地址 confirm: 是否确认发布(二次确认参数)

Returns: 发布结果字典,包含: - 发布 ID: 新发布消息的唯一标识符 - 发布时间: 消息发布时间 - 发布结果: 发布是否成功的描述信息 - 重要提示: 关于审核的提醒信息

或者确认信息字典,包含:
- 需要确认: 是否需要用户确认
- 内容预览: 要发布的内容预览
- 确认提示: 如何进行确认的说明

Inputs: status (required), photo_url (required), confirm. Returns: object

publish_statusA

发布饭否内容(仅文字)

调用饭否 API 的 /statuses/update.json 接口发布纯文字内容。

Args: status: 要发布的文字内容(最多140字) confirm: 是否确认发布(二次确认参数)

Returns: 发布结果字典,包含: - 发布 ID: 新发布消息的唯一标识符 - 发布时间: 消息发布时间,需转为北京时间 - 发布结果: 发布是否成功的描述信息 - 重要提示: 关于审核的提醒信息

或者确认信息字典,包含:
- 需要确认: 是否需要用户确认
- 内容预览: 要发布的内容预览
- 确认提示: 如何进行确认的说明

Inputs: status (required), confirm. Returns: object

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool targets a distinct action or resource: deletion, timeline retrieval, status info, user info, publishing, favoriting, friendship management, and OAuth generation. No two tools have overlapping purposes; agents can easily differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern (e.g., delete_status, get_home_timeline, manage_favorite). The verbs (delete, generate, get, manage, publish) clearly indicate the action, and nouns specify the resource, forming a predictable and readable set.

    Tool Count5/5

    With 11 tools covering authentication, multiple timeline retrievals, user info, status CRUD, favoriting, and friendships, the count is well-scoped for a microblogging service. Each tool serves a necessary function without redundancy.

    Completeness4/5

    The tool set covers core operations: publishing text and photos, deleting, favoriting, managing follows, and viewing timelines. However, notable gaps include missing tools to list followers/friends or view a user's favorites list, which an agent might need for full user interaction.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A basic MCP server built with FastMCP framework that provides example tools including message echoing and server information retrieval. Supports both stdio and HTTP transports with Docker deployment capabilities.
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A basic MCP server built with FastMCP framework that provides example tools including message echoing and server information retrieval. Supports both stdio and HTTP transports with Docker deployment capabilities.
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A basic MCP server built with FastMCP framework that provides simple utility tools including message echoing and server information retrieval. Supports both stdio and HTTP transports with Docker deployment capabilities.
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      A basic MCP server built with FastMCP framework that provides example tools including message echoing and server information retrieval. Supports both stdio and HTTP transports for integration with various MCP clients.
      -