Skip to main content
Glama
wangshunnn

bilibili MCP Server

by wangshunnn

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
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Get' implies a read operation, it doesn't specify whether this requires authentication, has rate limits, returns paginated results, or what kind of detailed information is included (e.g., metadata, statistics, comments). This leaves significant gaps for agent decision-making.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'detailed information' includes, the response format, or behavioral aspects like error handling. Given the complexity of video data and lack of structured output documentation, more context is needed for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'bvid' clearly documented in the schema. The description doesn't add any parameter-specific details beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('detailed information about a Bilibili video'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'search_videos', which might also return video information but with different parameters or scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_videos'. It doesn't mention prerequisites (e.g., needing a BVID), exclusions, or contextual factors that would help an agent choose between sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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