Skip to main content

RabbitMV MCP Service - A Model Context Protocol implementation for media data services

Project description

RabbitMV MCP Service

基于 Model Context Protocol 实现的数据服务,提供视频、文章、演员、角色和网站数据的访问能力。

特性

  • 基于 MCP (Model Context Protocol) SDK 构建
  • 提供标准化的数据访问工具
  • 支持多种数据过滤和查询方式
  • 内置缓存机制
  • 完整的错误处理和日志记录
  • 类型注解和全面的测试覆盖

系统要求

  • Python 3.12 或更高版本
  • 支持 asyncio 的操作系统(Linux, macOS, Windows)

安装

  1. 确保已安装 uv:
pip install uv
  1. 克隆仓库:
git clone https://github.com/yourusername/rabbitmv-mcp.git
cd rabbitmv-mcp
  1. 创建并激活虚拟环境:
uv venv
source .venv/bin/activate  # Linux/macOS
# 或
.venv\Scripts\activate  # Windows
  1. 安装依赖:
uv pip install -r requirements.txt
  1. 安装开发依赖(可选):
uv pip install -r requirements.txt[dev]

配置

  1. 复制示例配置文件:
cp .env.example .env
  1. 根据需要修改 .env 文件中的配置项:
  • LOG_LEVEL: 日志级别 (DEBUG, INFO, WARNING, ERROR)
  • CACHE_TIME: 缓存时间(秒)
  • NEED_AUTH: 是否启用鉴权
  • AUTH_KEY: 鉴权密钥
  • IMG_URL: 图片域名前缀

MCP 工具

服务提供以下 MCP 工具:

1. get_vod - 视频数据工具

获取视频相关数据。

参数:

  • ids: 视频ID,多个用逗号分隔
  • t: 分类ID
  • h: 几小时内的数据
  • wd: 关键词搜索
  • year: 年份范围,如:2020或2020-2023
  • from: 播放器组标识
  • isend: 是否完结 (1完结,0未完结)
  • ac: 是否获取详情 (detail获取详情)
  • pg: 页码,默认1
  • pagesize: 每页数量,默认20,最大100

2. get_art - 文章数据工具

获取文章相关数据。

参数:

  • ids: 文章ID,多个用逗号分隔
  • t: 分类ID
  • h: 几小时内的数据
  • wd: 关键词搜索
  • ac: 是否获取详情
  • pg: 页码
  • pagesize: 每页数量

3. get_actor - 演员数据工具

获取演员相关数据。

参数:

  • ids: 演员ID,多个用逗号分隔
  • t: 分类ID
  • h: 几小时内的数据
  • wd: 关键词搜索
  • ac: 是否获取详情
  • pg: 页码
  • pagesize: 每页数量

4. get_role - 角色数据工具

获取角色相关数据。

参数:

  • ids: 角色ID,多个用逗号分隔
  • t: 分类ID
  • h: 几小时内的数据
  • wd: 关键词搜索
  • ac: 是否获取详情
  • pg: 页码
  • pagesize: 每页数量

5. get_website - 网站数据工具

获取网站相关数据。

参数:

  • ids: 网站ID,多个用逗号分隔
  • t: 分类ID
  • h: 几小时内的数据
  • wd: 关键词搜索
  • ac: 是否获取详情
  • pg: 页码
  • pagesize: 每页数量

开发指南

运行测试

uv pip install -r requirements.txt[dev]  # 如果还没有安装开发依赖
pytest

代码格式化

black .
isort .

类型检查

mypy .

使用示例

from modelcontextprotocol import MCPClient

async def main():
    client = MCPClient()
    
    # 获取视频列表
    result = await client.call_tool("get_vod", {
        "pg": 1,
        "pagesize": 20,
        "wd": "示例"
    })
    print(result)
    
    # 获取文章详情
    result = await client.call_tool("get_art", {
        "ids": "1",
        "ac": "detail"
    })
    print(result)

asyncio.run(main())

特别说明

  • 所有接口支持缓存机制,缓存时间通过 CACHE_TIME 环境变量配置
  • 接口支持鉴权,通过 NEED_AUTHAUTH_KEY 环境变量控制
  • 图片地址支持配置域名前缀,通过 IMG_URL 环境变量设置
  • 所有数据查询都支持基于 ID、分类、时间和关键词的过滤
  • 详情模式(ac=detail)会返回更完整的数据内容
  • 项目使用 uv 进行依赖管理,确保依赖安装的确定性和可重现性

许可证

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rabbitmv_mcp-0.1.2.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rabbitmv_mcp-0.1.2-py3-none-any.whl (37.5 kB view details)

Uploaded Python 3

File details

Details for the file rabbitmv_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: rabbitmv_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rabbitmv_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ded416eb9f781157dcf264a252a75c5ba8665af5f2ad878c222b510e97d08747
MD5 983ad289f95db03e876c8905063231d6
BLAKE2b-256 f4b5f7dc71e239453f3d597f0d47db3cd03ba362a45efcf69a84365b797ffd67

See more details on using hashes here.

File details

Details for the file rabbitmv_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: rabbitmv_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for rabbitmv_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 79ad8c98c8e7b755ec71e26c307efc4930939afe82522e8f4d1e8809af8d8994
MD5 5a361c530dfd6923e93b8e0f20c6a6ec
BLAKE2b-256 e5394c88741cb2ad25b7e3286bfcedc959960804718129cd1d7c70af793f33db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page