Miku 直播

  • Miku 直播 > 最佳实践 > 如何使用直播MCP Server (Live Streaming)

    如何使用直播MCP Server (Live Streaming)

    最近更新时间: 2025-11-27 12:21:41

    引用本文档展示在VS Code中使用AI编程工具Kilo来调用 七牛云Miku直播MCP Server的对话过程。

    一 环境配置

    1. 在本地运行MCP Server

    # 克隆MCP代码
    git clone git@github.com:qiniu/qiniu-mcp-server.git
    # 参考 README.md 安装配置
    cd qiniu-mcp-server
    uv --directory . run qiniu-mcp-server --transport sse --port 8000
    

    2. 在Kilo中配置MCP Servers

    {
      "mcpServers": {
        "qiniu-miku-live-streaming": {
    	"url": "http://localhost:8000/sse",
    	"disabled": false
         }
      }
    }
    

    kilo-mcp.png

    3. 为Kilo配置大模型

    kilo-live.png


    二 对话过程

    1. 查看直播空间

    User:

    <task>
    查看下我的直播空间
    </task>
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # Current Mode
    
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    
    # Current Workspace Directory (/home/teric/Documents) Files
    </environment_details>
    

    Assistant:

    I'll help you view the live streaming spaces. Let me use the available MCP tool to list all live streaming buckets/spaces.
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_list_buckets</tool_name>
    <arguments>
    {}
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    
    {'status': 'success', 'data': '{"buckets":[{"name":"dfddd","region":"cn-east-1","status":"Enabled","creationDate":"2025-10-28T22:33:46.145+08:00"}],"connectId":"YmgAAJpKaC_cInsY"}', 'message': 'Buckets listed successfully', 'status_code': 200}
    
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    已成功查看到直播空间信息:

    直播空间列表:

    1. 空间名称: dfddd
      • 区域: cn-east-1
      • 状态: Enabled(已启用)
      • 创建时间: 2025-10-28T22:33:46.145+08:00

    连接ID: YmgAAJpKaC_cInsY

    目前有1个可用的直播空间,状态为已启用。


    2. 查看直播流、及流量情况

    User:

    [attempt_completion] Result:
    The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.
    <feedback>
    查看直播流和流量
    </feedback>
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:40:24.570Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    我将帮您查看直播流和流量信息。首先让我查看直播空间中的流列表,然后获取流量统计数据。
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_list_streams</tool_name>
    <arguments>
    {
      "bucket_id": "dfddd"
    }
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    
    {'status': 'success', 'bucket_id': 'dfddd', 'data': '{"items":[{"key":"eeeee","forbidden":false,"creationDate":"2025-10-28T22:33:52.811+08:00","status":"offline","lastStartAt":0,"publishUrl":"","isConverted":false,"streamOnlineInfo":null}],"total":1,"totalPage":1,"pageIndex":1,"pageSize":10}', 'message': "Streams in bucket 'dfddd' listed successfully", 'status_code': 200}
    
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:40:29.908Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    现在让我获取直播流量统计数据。我将查询最近24小时的流量信息:
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_query_live_traffic_stats</tool_name>
    <arguments>
    {
      "begin": "20241125000000",
      "end": "20241125235959"
    }
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    {'status': 'success', 'begin': '20241125000000', 'end': '20241125235959', 'data': '[{"time":"2024-11-25T00:00:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:05:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:10:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:15:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:20:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:25:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:30:00+08:00","values":{"flow":0}},{"time":"2024-11-25T00:35:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:25:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:30:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:35:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:40:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:45:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:50:00+08:00","values":{"flow":0}},{"time":"2024-11-25T23:55:00+08:00","values":{"flow":0}}]', 'message': 'Traffic statistics retrieved successfully', 'status_code': 200}
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:40:36.790Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    已成功查看到直播流和流量信息:

    直播流信息

    空间: dfddd

    直播流列表:

    1. 流名称: eeeee
      • 状态: offline(离线)
      • 创建时间: 2025-10-28T22:33:52.811+08:00
      • 最后开始时间: 0(从未开始)
      • 发布URL:
      • 是否已转换:
      • 在线信息:

    总计: 1个流,当前页面1,每页显示10个流

    流量统计信息

    查询时间范围: 2024-11-25 00:00:00 - 2024-11-25 23:59:59

    流量统计结果:

    • 总流量: 0 字节
    • 平均流量: 0 字节/5分钟
    • 峰值流量: 0 字节/5分钟
    • 时间段: 全天288个时间点(每5分钟一个统计点)

    流量分析:

    • 整天内所有时间点的流量均为0
    • 当前没有活跃的直播流
    • 系统处于空闲状态,无流量消耗

    总结: 当前直播空间中有1个名为"eeeeee"的流,但该流当前处于离线状态,且整个时间范围内没有任何流量产生。


    3. 创建直播流

    User:

    [attempt_completion] Result:
    The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.
    <feedback>
    在当前空间创建一个stream-abc的直播流,显示推流、拉流地址
    </feedback>
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:42:01.541Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    我将为您创建名为"stream-abc"的直播流,然后获取推流和拉流地址。
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_create_stream</tool_name>
    <arguments>
    {
      "bucket": "dfddd",
      "stream": "stream-abc"
    }
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    
    {'status': 'success', 'bucket': 'dfddd', 'stream': 'stream-abc', 'url': 'https://dfddd.mls.cn-east-1.qiniumiku.com/stream-abc', 'message': "Stream 'stream-abc' created successfully in bucket 'dfddd'", 'status_code': 200}
    
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:42:09.501Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    现在我将获取推流地址。我需要使用推流域名来获取推流URL:
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_get_push_urls</tool_name>
    <arguments>
    {
      "push_domain": "mcp-push1.qiniu.com",
      "bucket": "dfddd",
      "stream_name": "stream-abc"
    }
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    
    {'status': 'success', 'push_domain': 'mcp-push1.qiniu.com', 'bucket': 'dfddd', 'stream_name': 'stream-abc', 'rtmp_url': 'rtmp://mcp-push1.qiniu.com/dfddd/stream-abc', 'whip_url': 'https://mcp-push1.qiniu.com/dfddd/stream-abc.whip', 'message': 'Push URLs generated successfully'}
    
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:42:16.362Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    现在我将获取拉流地址:
    
    <use_mcp_tool>
    <server_name>remote-live-streaming</server_name>
    <tool_name>live_streaming_get_play_urls</tool_name>
    <arguments>
    {
      "play_domain": "mcp-play1.qiniu.com",
      "bucket": "dfddd",
      "stream_name": "stream-abc"
    }
    </arguments>
    </use_mcp_tool>
    

    [use_mcp_tool for 'remote-live-streaming'] Result:
    
    {'status': 'success', 'play_domain': 'mcp-play1.qiniu.com', 'bucket': 'dfddd', 'stream_name': 'stream-abc', 'flv_url': 'https://mcp-play1.qiniu.com/dfddd/stream-abc.flv', 'm3u8_url': 'https://mcp-play1.qiniu.com/dfddd/stream-abc.m3u8', 'whep_url': 'https://mcp-play1.qiniu.com/dfddd/stream-abc.whep', 'message': 'Playback URLs generated successfully'}
    
    <environment_details>
    # VSCode Visible Files
    ../.config/Code/User/globalStorage/kilocode.kilo-code/settings/mcp_settings.json
    
    # VSCode Open Tabs
    
    # Current Time
    Current time in ISO 8601 UTC format: 2025-11-25T03:43:31.988Z
    User time zone: Asia/Singapore, UTC+8:00
    
    # Current Cost
    $0.00
    
    # Current Mode
    <slug>code</slug>
    <name>Code</name>
    <model>glm-4.5-air</model>
    You have not created a todo list yet. Create one with `update_todo_list` if your task is complicated or involves multiple steps.
    </environment_details>
    

    Assistant:

    已成功在当前空间创建直播流并获取推流和拉流地址:

    直播流创建成功

    流名称: stream-abc
    所属空间: dfddd
    流地址: https://dfddd.mls.cn-east-1.qiniumiku.com/stream-abc

    推流地址

    RTMP 推流地址:

    rtmp://mcp-push1.qiniu.com/dfddd/stream-abc

    WHIP 推流地址:

    https://mcp-push1.qiniu.com/dfddd/stream-abc.whip

    拉流地址

    FLV 拉流地址:

    https://mcp-play1.qiniu.com/dfddd/stream-abc.flv

    M3U8 拉流地址:

    https://mcp-play1.qiniu.com/dfddd/stream-abc.m3u8

    WHEP 拉流地址:

    https://mcp-play1.qiniu.com/dfddd/stream-abc.whep

    使用说明

    1. 推流: 使用OBS等推流软件,选择RTMP协议并填写对应的推流地址和流密钥
    2. 拉流: 支持多种播放格式:
      • FLV格式适用于大多数播放器
      • M3U8格式适用于HLS播放
      • WHEP格式适用于WebRTC播放

    提示: 推流时需要提供对应的流密钥,请联系管理员获取推流密钥信息。

    以上内容是否对您有帮助?