Cover image
Try Now
2025-04-14

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

SproutVideo MCP Server

License: ISC

A Model Context Protocol (MCP) server that wraps the SproutVideo API, enabling AI models to interact with SproutVideo content through standardized tools with advanced database persistence, semantic search, and security features.

Overview

This project implements a Model Context Protocol server that allows AI models to access, search, and manipulate video content on SproutVideo. It follows the MCP specification to expose SproutVideo functionality as tools that can be called by AI systems, with an additional layer for metadata persistence, semantic search, and enhanced security.

Features

  • MCP Compliant: Implements the Model Context Protocol for seamless integration with AI systems
  • SproutVideo Integration: Provides a bridge to SproutVideo's API with robust rate limiting and retry mechanisms
  • Tool-based Architecture: Exposes SproutVideo functionality as callable tools
  • Environment-based Configuration: Simple setup using environment variables
  • Metadata Persistence: Stores video metadata in PostgreSQL for advanced querying capabilities
  • Semantic Search: Uses vector embeddings to enable natural language searching of video content
  • Security Layer: Implements API key management, access control, and audit logging
  • Caching System: Optimizes performance for frequent operations

Current Tools

Tool Name Description Parameters
get_a_video Retrieves video information from SproutVideo videoId: The ID of the video to retrieve
list_videos Lists all videos from SproutVideo page: Page number for pagination (defaults to 1 if not provided)
perPage: Number of videos per page, max 100 (defaults to 25 if not provided)
orderBy: Field to order by: created_at, updated_at, duration, title (optional)
orderDir: Sort direction: asc or desc (optional)
folderId: Filter by folder ID (optional)
tagId: Filter by tag ID (optional)
tagName: Filter by tag name (optional)
search_videos Semantically searches videos using natural language query: The natural language search query
limit: Maximum number of results to return (optional)
filter: Additional metadata filters (optional)
edit_video_metadata Updates video metadata videoId: The ID of the video to update
title: New title (optional)
description: New description (optional)
tags: New tags array (optional)
privacy: Privacy setting (optional)
generate_video_summary Creates a concise summary of video content videoId: The ID of the video to summarize

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • PostgreSQL (with pgvector extension)
  • Ollama (for local embeddings) or OpenAI API key
  • SproutVideo API Key

Installation

  1. Clone the repository:

    git clone https://github.com/twentynineteen/sproutvideo-mcp-server.git
    cd sproutvideo-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Set up PostgreSQL database with pgvector:

    psql -c "CREATE DATABASE sproutvideo_mcp;"
    psql -d sproutvideo_mcp -c "CREATE EXTENSION IF NOT EXISTS vector;"
    
  4. Create a .env file in the root directory with your configuration:

    # API Keys
    SPROUTVIDEO_API_KEY=your_api_key_here
    
    # Database Configuration
    DB_HOST=localhost
    DB_PORT=5432
    DB_NAME=sproutvideo_mcp
    DB_USER=postgres
    DB_PASSWORD=your_db_password
    
    # Embedding Configuration
    EMBEDDING_PROVIDER=ollama  # or 'openai'
    EMBEDDING_MODEL=nomic-embed-text
    OLLAMA_URL=http://localhost:11434
    # OPENAI_API_KEY=your_openai_key  # Uncomment if using OpenAI
    
    # Security and Performance
    API_RATE_LIMIT=100
    CACHE_TTL=3600
    LOGGING_LEVEL=info
    
  5. Run database migrations:

    npm run migrate
    

Usage

Build the project

npm run build

Run the server

npm start

The server will initialize and start listening for MCP requests on standard input/output channels.

Sync video metadata

npm run sync

This command synchronizes video metadata from SproutVideo API to your local database.

Project Structure

sproutvideo-mcp-server/
├── src/                        # Source code
│   ├── api/                    # API Integration Layer
│   │   ├── client.ts           # SproutVideo API client
│   │   ├── rateLimiter.ts      # Rate limiting implementation
│   │   └── transformers/       # Response transformers
│   ├── database/               # Persistence Layer
│   │   ├── entities/           # Database entity definitions
│   │   ├── migrations/         # Database migrations
│   │   └── connection.ts       # Database connection manager
│   ├── embedding/              # Intelligence Layer
│   │   ├── ollama.ts           # Ollama client for embeddings
│   │   ├── openai.ts           # OpenAI client (alternative)
│   │   └── service.ts          # Embedding service
│   ├── mcp/                    # MCP Protocol Layer
│   │   ├── handlers/           # Tool handler implementations
│   │   ├── schema.ts           # Tool schemas and validation
│   │   └── server.ts           # MCP server implementation
│   ├── search/                 # Search Functionality
│   │   ├── cache.ts            # Search result caching
│   │   └── vectorSearch.ts     # Vector similarity search
│   ├── security/               # Security Layer
│   │   ├── access.ts           # Access control
│   │   ├── audit.ts            # Audit logging
│   │   └── encryption.ts       # Data encryption utilities
│   ├── tools/                  # Tool Implementations
│   │   ├── videoTools.ts       # Video-related tools
│   │   └── searchTools.ts      # Search-related tools
│   ├── utils/                  # Common utilities
│   ├── config.ts               # Configuration management
│   └── index.ts                # Entry point
├── tests/                      # Test files mirroring src structure
├── build/                      # Compiled JavaScript files
├── scripts/                    # Utility scripts
│   ├── sync.ts                 # Database synchronization
│   └── migrations.ts           # Migration runner
├── .env                        # Environment variables (not in git)
├── .env.example                # Example environment configuration
├── .eslintrc                   # ESLint configuration
├── .gitignore                  # Git ignore file
├── .prettierrc                 # Prettier configuration
├── jest.config.js              # Jest test configuration
├── package.json                # Project metadata and dependencies
├── tsconfig.json               # TypeScript configuration
├── PLANNING.md                 # Technical vision and architecture
├── TASKS.md                    # Development task tracking
└── README.md                   # This documentation

How It Works

  1. The server initializes with the MCP protocol handlers and establishes database connections.
  2. Video metadata is synced from SproutVideo to the local database, with embeddings generated for search.
  3. The server listens for tool listing requests and returns available tools.
  4. When a tool is called, parameters are validated and the appropriate handler is invoked.
  5. For data retrieval operations, the server first checks the local database before making API calls.
  6. Semantic search leverages vector embeddings to find videos matching natural language queries.
  7. Results are formatted according to the MCP specification and returned to the caller.

Technical Implementation

The server is built with TypeScript and uses the following key components:

  • MCP SDK: For implementing the Model Context Protocol
  • Axios: For making HTTP requests to the SproutVideo API
  • StdioServerTransport: For communication via stdin/stdout
  • PostgreSQL with pgvector: For metadata storage and vector similarity search
  • TypeORM: For database entity management
  • Ollama/OpenAI: For generating embeddings from text
  • Jest: For comprehensive testing
  • Environment Variables: For securely storing configuration

Error Handling

The server implements comprehensive error handling:

  • Parameter validation with clear error messages
  • API error handling with appropriate status codes
  • Graceful error formatting following MCP specifications
  • Rate limiting with exponential backoff
  • Database connection retry mechanisms
  • Audit logging for critical errors

Development

Adding New Tools

To add a new tool to the server:

  1. Add the tool definition to the schema in src/mcp/schema.ts
  2. Create a tool handler in src/mcp/handlers/
  3. Register the handler in the MCP server
  4. Add integration tests in the corresponding test file
  5. Update this README with the new tool details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the ISC License - see the LICENSE file for details.

Acknowledgments

相关推荐

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • 1Panel-dev
  • 🔥 1Panel proporciona una interfaz web intuitiva y un servidor MCP para administrar sitios web, archivos, contenedores, bases de datos y LLM en un servidor de Linux.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • Byaidu
  • Traducción de papel científico en PDF con formatos preservados - 基于 Ai 完整保留排版的 PDF 文档全文双语翻译 , 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 支持 等服务 等服务 等服务 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 提供 cli/mcp/docker/zotero

  • rulego
  • ⛓️Rulego es un marco de motor de regla de orquestación de componentes de alta generación de alto rendimiento, de alto rendimiento y de alto rendimiento para GO.

  • sigoden
  • Cree fácilmente herramientas y agentes de LLM utilizando funciones Plain Bash/JavaScript/Python.

  • hkr04
  • SDK liviano C ++ MCP (Protocolo de contexto del modelo)

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 Qq / 微信(企业微信、个人微信) / 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 Chatgpt 、 Deepseek 、 DiFy 、 Claude 、 Gemini 、 Xai 、 PPIO 、 Ollama 、 LM Studio 、阿里云百炼、火山方舟、 Siliconflow 、 Qwen 、 Moonshot 、 Chatglm 、 SillyTraven 、 MCP 等 LLM 的机器人 / Agente | Plataforma de bots de mensajería instantánea basada en LLM, admite Discord, Telegram, WeChat, Lark, Dingtalk, QQ, Slack

  • dmayboroda
  • Trapo conversacional local con contenedores configurables

  • modelscope
  • Iniciar aplicaciones de múltiples agentes empoderadas con Building LLM de manera más fácil.

    Reviews

    3.2 (5)
    Avatar
    user_86C3PEfx
    2025-04-24

    SproutVideo-MCP-Server by Twentynineteen is an exceptional solution for video hosting and management. It's incredibly user-friendly, offering seamless integration and reliable performance. The server provides impressive customization options and efficiently handles large volumes of content. Highly recommended for anyone needing a robust video management platform!

    Avatar
    user_FSCXXrEq
    2025-04-24

    SproutVideo-MCP-Server by Twentynineteen is an exceptional product for managing video content seamlessly. It offers reliable performance and great features. Highly recommended for anyone in need of a robust video management solution!

    Avatar
    user_9gqZYijp
    2025-04-24

    The sproutvideo-mcp-server by twentynineteen is a fantastic tool for managing and streaming videos efficiently. Its user-friendly interface and robust features make video hosting a breeze. As an avid user, I'm impressed by its seamless integration and reliability. Highly recommended for anyone looking for a professional video server solution!

    Avatar
    user_KcutxdJw
    2025-04-24

    Sproutvideo-mcp-server by Twentynineteen is a phenomenal tool for managing video content seamlessly. Its user-friendly interface and robust performance make it a top choice for both beginners and professionals. The welcoming information ensures an easy start, and the detailed documentation provides comprehensive guidance. Highly recommended for anyone looking to streamline their video management process!

    Avatar
    user_S4bOfa3G
    2025-04-24

    As a dedicated user of sproutvideo-mcp-server by twentynineteen, I am extremely pleased with its performance and reliability. This server is a powerhouse, providing seamless streaming and robust management capabilities. It's clear that a lot of thought and expertise went into its design. Highly recommend it to anyone in need of a top-tier media server!