Skip to main content
Glama

YouTube Transcript Extractor MCP

index.ts1.22 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { YoutubeTranscript } from 'youtube-transcript'; import getVideoId from 'get-video-id'; import { z } from "zod"; // Create server instance const server = new McpServer({ name: "mcp-server-template", version: "0.0.1", }); // Define a sample tool server.tool( "youtube-transcript-extractor", "Extracts the transcript of a YouTube video.", { input: z.string().describe("a youtube video url"), }, async ({ input }) => { const videoData = getVideoId(input); const output = await YoutubeTranscript.fetchTranscript(videoData.id as string).then((transcript: any) => { const text = transcript.map((t: any) => t.text).join(' '); return text; }); return { content: [ { type: "text", text: output, }, ], }; } ); async function main() { const transport = new StdioServerTransport(); await server.connect(transport); console.log("MCP Server running on stdio"); } main().catch((error) => { console.error("Fatal error in main():", error); process.exit(1); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MalikElate/yt-description-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server