Skip to main content
Glama

get_video_info

Retrieve detailed metadata for a Bilibili video by specifying its unique BVID, enabling precise access to video information for analysis or integration purposes.

Instructions

Get detailed information about a Bilibili video

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bvidYesBilibili video ID (BVID)

Implementation Reference

  • The main execution logic for the 'get_video_info' tool. Fetches Bilibili video details, formats title, uploader, stats, description, tags into a multi-line text response using i18n translations and utility formatters, returns as MCP content block. Handles fetch errors.
    async ({ bvid }) => { try { const t = i18n.video const videoDetail = (await getVideoDetail(bvid)) || {} const stats = videoDetail.stat || {} const detailLines = [ `${t.title}: ${videoDetail.title}`, `${t.url}: https://www.bilibili.com/video/${videoDetail.bvid}`, `${t.aid}: ${videoDetail.aid}`, `${t.uploader}: ${videoDetail.owner?.name} (${t.uploaderUID}: ${videoDetail.owner?.mid})`, `${t.publishDate}: ${formatTimestamp(videoDetail.pubdate)}`, `${t.duration}: ${formatDuration(videoDetail.duration)}`, "", `${t.stats}:`, `- ${t.views}: ${stats.view?.toLocaleString()}`, `- ${t.danmaku}: ${stats.danmaku?.toLocaleString()}`, `- ${t.comments}: ${stats.reply?.toLocaleString()}`, `- ${t.likes}: ${stats.like?.toLocaleString()}`, `- ${t.coins}: ${stats.coin?.toLocaleString()}`, `- ${t.favorites}: ${stats.favorite?.toLocaleString()}`, `- ${t.shares}: ${stats.share?.toLocaleString()}`, "", `${t.description}:`, ...videoDetail.desc?.split("\n")?.map?.((line) => line), "", `${t.tags}: ${videoDetail.tags?.join(", ")}`, ] const formattedDetail = detailLines.map((line) => line).join("\n") return { content: [ { type: "text", text: formattedDetail.trim(), }, ], } } catch (error) { return { content: [ { type: "text", text: `Failed to fetch video info: ${error instanceof Error ? error.message : String(error)}`, }, ], } } } )
  • Input schema for the tool using Zod: requires 'bvid' as string (Bilibili Video ID).
    { bvid: z.string().describe("Bilibili video ID (BVID)"), },
  • Registers the 'get_video_info' tool on the MCP server, specifying name, description, input schema, and handler function.
    export function registerVideoTools(server: McpServer): void { server.tool( "get_video_info", "Get detailed information about a Bilibili video", { bvid: z.string().describe("Bilibili video ID (BVID)"), }, async ({ bvid }) => { try { const t = i18n.video const videoDetail = (await getVideoDetail(bvid)) || {} const stats = videoDetail.stat || {} const detailLines = [ `${t.title}: ${videoDetail.title}`, `${t.url}: https://www.bilibili.com/video/${videoDetail.bvid}`, `${t.aid}: ${videoDetail.aid}`, `${t.uploader}: ${videoDetail.owner?.name} (${t.uploaderUID}: ${videoDetail.owner?.mid})`, `${t.publishDate}: ${formatTimestamp(videoDetail.pubdate)}`, `${t.duration}: ${formatDuration(videoDetail.duration)}`, "", `${t.stats}:`, `- ${t.views}: ${stats.view?.toLocaleString()}`, `- ${t.danmaku}: ${stats.danmaku?.toLocaleString()}`, `- ${t.comments}: ${stats.reply?.toLocaleString()}`, `- ${t.likes}: ${stats.like?.toLocaleString()}`, `- ${t.coins}: ${stats.coin?.toLocaleString()}`, `- ${t.favorites}: ${stats.favorite?.toLocaleString()}`, `- ${t.shares}: ${stats.share?.toLocaleString()}`, "", `${t.description}:`, ...videoDetail.desc?.split("\n")?.map?.((line) => line), "", `${t.tags}: ${videoDetail.tags?.join(", ")}`, ] const formattedDetail = detailLines.map((line) => line).join("\n") return { content: [ { type: "text", text: formattedDetail.trim(), }, ], } } catch (error) { return { content: [ { type: "text", text: `Failed to fetch video info: ${error instanceof Error ? error.message : String(error)}`, }, ], } } } ) }
  • src/index.ts:15-15 (registration)
    Invocation of registerVideoTools during MCP server startup to enable the tool.
    registerVideoTools(server)
  • Helper function called by the handler to fetch raw video detail data from the API.
    export async function getVideoDetail(bvid: string): Promise<VideoDetail> { try { return await videoAPI.getDetail(bvid) } catch (error) { console.error("Error fetching video detail:", error) throw error } }

Other Tools

Related Tools

Latest Blog Posts

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/wangshunnn/bilibili-mcp-server'

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