Real-Time YouTube Script Generator MCP Server

Real-Time YouTube Script Generator MCP Server

Generates production-ready short video scripts from real-time web search data using Tavily and Gemini, exposed as MCP tools.

Category
访问服务器

README

🎬 Real-Time YouTube Script Generator & MCP Server

🚀 Live Demo: Real-Time YouTube Script Generator

project structure

An AI-powered application that retrieves real-time web information using Tavily Search and converts it into high-retention, production-ready short video scripts (YouTube Shorts / Instagram Reels) using Gemini LLM.

The project features both a Streamlit Web App interface and a FastMCP (Model Context Protocol) Server for seamless integration with AI assistants (Claude, Cursor, etc.).


✨ Features

  • 🔍 Real-Time Web Search: Integrates Tavily API for fetching up-to-date web data.
  • 📌 AI Summarization: Automatically synthesizes search snippets into concise, structured summaries.
  • 📜 Production-Ready Script Generation: Formats context into short-video scripts complete with visual cues, verbal hooks, and call-to-actions.
  • 💻 Interactive Streamlit Web UI: Simple web browser interface to search, preview, and download scripts as .txt.
  • 🔌 Model Context Protocol (FastMCP): Exposes search and script generation tools as standard MCP endpoints for external AI clients.

🧠 Key Learnings & Important Takeaways

  1. Real-Time Grounding Eliminates Hallucination:

    • Standard LLMs suffer from knowledge cutoff dates. Combining Tavily real-time web search with Gemini allows the generator to craft accurate scripts on breaking news and trending topics.
  2. Fault-Tolerant Fallback Architecture:

    • If the LLM summarization call fails (rate limits, network glitches), the pipeline gracefully falls back to displaying raw web search snippets, ensuring the user never receives a blank page or error crash.
  3. Decoupled Architecture with FastMCP:

    • By separating the core utility functions (app.py) from the transport interface (mcp_server.py), the exact same business logic powers both an interactive web application (Streamlit) and external IDE/Assistant workflows (Claude Desktop, Cursor).
  4. Structured Short-Form Script Prompting:

    • Short-video scripts (Shorts/Reels) require immediate engagement. Using structured prompt directives (Visual Cues [...] vs. Spoken Words (...) and Hook → Frame → Payload → CTA layout) produces production-grade output.
  5. Multi-Provider Compatibility:

    • Utilizing standard client abstractions (such as the OpenAI SDK with custom base_url for AICredits or official Google Gemini SDK) allows switching between underlying model backends effortlessly.

🛠️ Project Structure

├── app.py              # Streamlit web application & core logic (Tavily + LLM)
├── mcp_server.py       # FastMCP server exposing tool endpoints
├── assests/            # Project diagrams & images
│   └── 3242.png
├── pyproject.toml      # Project configuration & dependencies
├── .env                # API keys configuration (not committed)
└── README.md           # Project documentation

🔑 Environment Setup

Create a .env file in the root directory:

AICREDITS_API_KEY=your_aicredits_or_openai_key
TAVILY_API_KEY=your_tavily_api_key
GEMINI_API_KEY=your_google_gemini_api_key

📦 Installation

Using uv (recommended):

uv sync

🚀 Usage

1. Run the Streamlit Web Application

To launch the interactive web interface:

uv run streamlit run app.py

Open your browser at http://localhost:8501.

2. Test/Dev MCP Server with FastMCP Inspector

To test the MCP tools (get_latest_info_mcp and get_video_script_mcp) in an interactive browser UI:

uv run mcp dev mcp_server.py

3. Connect MCP Server to Claude / Cursor

Add the server definition to your MCP client configuration (e.g. claude_desktop_config.json):

{
  "mcpServers": {
    "youtube-script-generator": {
      "command": "uv",
      "args": ["run", "python", "C:/Users/DELL/Desktop/New folder/mcp_server.py"]
    }
  }
}

🛠️ MCP Tools Offered

Tool Name Description
get_latest_info_mcp(query) Performs a real-time web search and returns an AI summary.
get_video_script_mcp(query) Fetches real-time web search data and generates a production-ready script.

user workflow


💻 API Code Examples, Parameters & Incoming Result Formats

Below is complete reference code to interact with all the APIs integrated into this project, including parameter definitions and sample response payloads.


1. Tavily Search API (tavily-python)

Used to retrieve real-time web search results and snippets.

Code Example

import os
from tavily import TavilyClient

# Initialize client
tavily_client = TavilyClient(api_key=os.getenv("TAVILY_API_KEY"))

# Execute web search
response = tavily_client.search(
    query="Latest developments in AI agents",
    max_results=3,
    topic="general",
    search_depth="advanced"
)

print("Search Response:", response)

Input Parameters

Parameter Type Description
query str Search topic or query string.
max_results int Maximum number of search results to return (e.g., 3).
topic str Category of search ("general", "news").
search_depth str Level of search detail ("basic", "advanced").

Incoming Result Format (JSON Response)

{
  "query": "Latest developments in AI agents",
  "follow_up_questions": null,
  "answer": null,
  "images": [],
  "results": [
    {
      "title": "Autonomous AI Agents in 2026: Trends & Breakthroughs",
      "url": "https://example.com/ai-agents-2026",
      "content": "AI agents are transforming software engineering with multi-agent orchestration and tool calling capabilities...",
      "score": 0.9821,
      "raw_content": null
    },
    {
      "title": "Open Source AI Agent Frameworks Overview",
      "url": "https://example.com/agent-frameworks",
      "content": "A comprehensive review of modern agent frameworks built for fast model context protocol (MCP) integration...",
      "score": 0.9543,
      "raw_content": null
    }
  ],
  "response_time": 0.84
}

2. AICredits API (OpenAI Client Interface)

Used in app.py to route model requests through OpenAI-compatible proxy endpoints.

Code Example

import os
from openai import OpenAI

# Initialize client pointing to AICredits endpoint
client = OpenAI(
    base_url="https://api.aicredits.in/v1",
    api_key=os.getenv("AICREDITS_API_KEY")
)

# Request completion
completion = client.chat.completions.create(
    model="gemini-2.0-flash-lite-001",
    messages=[
        {"role": "user", "content": "Summarize key features of quantum computing."}
    ],
    temperature=0.3
)

print(completion.choices[0].message.content)

Input Parameters

Parameter Type Description
model str Model identifier (e.g., "gemini-2.0-flash-lite-001").
messages list[dict] Chat history array of `{"role": "user"
temperature float Sampling randomness (0.0 for deterministic, 0.7 for creative).

Incoming Result Format (ChatCompletion JSON Object)

{
  "id": "chatcmpl-8x92a01bf982",
  "object": "chat.completion",
  "created": 1772500000,
  "model": "gemini-2.0-flash-lite-001",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Key features of quantum computing include:\n- **Superposition**: Qubits exist in multiple states simultaneously.\n- **Entanglement**: Interconnected qubit states enable exponentially faster calculations.\n- **Quantum Interference**: Amplifies correct paths to solve complex optimization problems."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 88,
    "total_tokens": 130
  }
}

3. Official Google Gemini API (google-genai SDK)

Used to call Gemini models directly via Google's official client library (google-genai).

Code Example

import os
from google import genai
from google.genai import types

# Initialize official Gemini client
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))

# Generate content call
response = client.models.generate_content(
    model="gemini-2.0-flash",
    contents="Write a 30-second YouTube Short hook on space exploration.",
    config=types.GenerateContentConfig(
        temperature=0.7,
        max_output_tokens=500
    )
)

print("Generated Output:", response.text)

Input Parameters

Parameter Type Description
model str Model selection ("gemini-2.0-flash", "gemini-1.5-pro").
contents str / list Text prompt or multi-modal input.
config GenerateContentConfig Generation settings (temperature, max_output_tokens, system_instruction).

Incoming Result Format (GenerateContentResponse Object)

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "[Visual Cue: Fast zoom onto Mars surface]\n(Voiceover): Did you know we just found proof of liquid water under the Martian crust?"
          }
        ],
        "role": "model"
      },
      "finish_reason": "STOP",
      "index": 0,
      "safety_ratings": []
    }
  ],
  "usage_metadata": {
    "prompt_token_count": 28,
    "candidates_token_count": 45,
    "total_token_count": 73
  }
}

4. Core Internal Functions (app.py Interface)

Core helper functions combining real-time web retrieval and AI script generation.

Code Example

from app import get_realtime_info, generate_video_script

query = "Latest SpaceX Launch"

# Step 1: Get real-time summary & raw search backup
summary_text, raw_search_backup = get_realtime_info(query)

# Step 2: Generate production script using context
script = generate_video_script(summary_text or raw_search_backup)

print("--- SUMMARY ---")
print(summary_text)

print("\n--- SCRIPT ---")
print(script)

Input & Output Signatures

def get_realtime_info(query: str) -> tuple[str, str]:
    """
    Inputs:
        query (str): The search topic or keyword string.

    Returns:
        tuple[str, str]: (llm_summary_text, raw_source_info_markdown)
    """

def generate_video_script(info_text: str) -> str:
    """
    Inputs:
        info_text (str): Summarized or raw information context.

    Returns:
        str: Production-ready YouTube Short / Reel script.
    """

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选