Get the FREE Ultimate OpenClaw Setup Guide →

mcp -example

获取前 N 条微博热搜的 MCP 服务示例,基于 `fastmcp` 构建,内置 **Stdio、本地 SSE、Streamable HTTP** 三种运行脚本,适配本地和远程多端场景。

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bossdong955-mcp-server-example conda run -n weibo-mcp-server --no-capture-output python E:/your/path/resou_stdio.py \
  --env PYTHONUTF8="1"

How to use

This MCP server is a demonstration that streams the top Weibo hot searches using the fastmcp framework. It exposes three running scripts for different deployment scenarios: Stdio, SSE, and Streamable HTTP. Stdio runs locally via standard input/output, SSE provides a server-sent events stream for remote connections, and Streamable HTTP serves a long-lived HTTP response suitable for custom frontends or other MCP clients. After starting any of the scripts, you can call hot_search(n=20) to fetch the top n hot searches. The example uses the in-repo resou_stdio.py script for local development and can be adapted to deploy the same logic over different transport modes as needed.

How to install

Prerequisites:

  • Conda (or Miniconda) available on your system
  • Python 3.11

Step-by-step installation:

  1. Clone the repository git clone https://github.com/bossdong955/mcp-server-example.git cd weibo-mcp-server

  2. Create and activate the Python environment conda create -n mcp-server-example python=3.11 conda activate mcp-server-example

  3. Install dependencies pip install -r requirements.txt

  4. Run the desired script (examples shown below):

    Stdio (local)

    python resou_stdio.py

    SSE (remote streaming)

    python resou_sse.py --host 0.0.0.0 --port 8006

    Streamable HTTP

    python resou_streamable_http.py --host 0.0.0.0 --port 8005

Note: If you previously installed a conflicting mcp package, uninstall it first with: pip uninstall mcp

Additional notes

Tips and notes:

  • For encoding issues, set PYTHONUTF8=1 in your environment or just in the command preceding the Python invocation.
  • If you encounter dependency conflicts, ensure you install within a clean Conda environment as shown and remove any globally installed old mcp packages.
  • The default hot_search timeout is 10 seconds when using httpx; adjust the timeout in the code if you need longer waits.
  • In SSE mode, you can specify custom Authorization headers in the client if your server requires authentication.
  • The three modes share the same underlying logic; choose the transport that best fits your deployment scenario (local development vs remote streaming vs HTTP streaming).

Related MCP Servers

Sponsor this space

Reach thousands of developers