# import gradio as gr # def add_numbers(a: float, b: float) -> float: # """ # Adds two numbers together. # Args: # a: The first number. # b: The second number. # """ # return a + b # # Create a simple interface for our tool # iface = gr.Interface( # fn=add_numbers, # inputs=[ # gr.Number(label="First Number"), # gr.Number(label="Second Number") # ], # outputs=gr.Number(label="Sum"), # title="Addition MCP Server", # description="A simple MCP tool that adds two numbers. [1, 2]" # ) # # Launch the app as an MCP server. This is the most important part. # if __name__ == "__main__": # iface.launch(mcp_server=True) import gradio as gr from youtube_transcript_api import YouTubeTranscriptApi def get_transcript(video_id: str) -> str: """ Fetches the transcript for a given YouTube video ID. Args: video_id: The unique ID of the YouTube video (e.g., 'dQw4w9WgXcQ'). """ try: # Fetch the transcript using the library transcript_list = YouTubeTranscriptApi.get_transcript(video_id) # Combine the list of dictionaries into a single string transcript = " ".join([item['text'] for item in transcript_list]) return transcript except Exception as e: # Return an error message if the transcript can't be found return f"Could not retrieve transcript. Error: {e}" # Create a simple Gradio interface for our tool iface = gr.Interface( fn=get_transcript, inputs=gr.Textbox(label="YouTube Video ID"), outputs=gr.Textbox(label="Transcript"), title="Transcript MCP Server", description="An MCP tool that fetches a YouTube transcript from a video ID. [1, 2]" ) # Launch the app as an MCP server if __name__ == "__main__": iface.launch(mcp_server=True)