Skip to main content
Glama

抖音 MCP Server (Node.js)

抖音视频搜索、无水印下载、用户信息获取工具。支持 MCP 协议和独立命令行两种使用方式。

功能

功能

说明

需要 Cookie

搜索视频

按关键词搜索抖音视频

是

无水印下载

获取无水印视频下载链接并下载

是

用户信息

获取发布者的性别、头像、粉丝数等

是

用户全部视频

获取指定用户发布的所有视频

是

一键获取全部

搜索关键词 → 获取每个作者的全部视频 + 性别 + 头像

是

分享链接解析

从分享链接提取视频信息(备用方案)

否

扫码获取Cookie

打开浏览器扫码登录,自动获取并保存Cookie

否

Related MCP server: Douyin MCP Server

快速安装

git clone <repo-url> douyin-mcp-node
cd douyin-mcp-node
npm install
npm run build

大部分功能需要抖音 Cookie 才能使用。

获取方式:

# 自动扫码登录获取(推荐)
npx tsx src/demo.ts cookie

或手动获取:

  1. 浏览器打开 douyin.com 并登录

  2. 按 F12 打开开发者工具 → Application → Cookies → 复制全部 cookie

  3. 粘贴到项目根目录的 cookies.txt 文件

Cookie 包含 sessionid、ttwid、sid_guard 等关键字段才算完整。有效期通常几天到几周。

MCP 配置

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "douyin": {
      "command": "node",
      "args": ["/你的完整路径/douyin-mcp-node/dist/index.js"],
      "cwd": "/你的完整路径/douyin-mcp-node"
    }
  }
}

Claude Code

在项目目录创建 .mcp.json:

{
  "mcpServers": {
    "douyin": {
      "command": "node",
      "args": ["/你的完整路径/douyin-mcp-node/dist/index.js"],
      "cwd": "/你的完整路径/douyin-mcp-node"
    }
  }
}

Cursor / Windsurf / 其他 MCP 客户端

同样添加 MCP Server 配置,command 为 node,args 指向 dist/index.js。

MCP 工具列表

search_videos - 搜索视频

参数

类型

默认

说明

keyword

string

必填

搜索关键词

count

number

10

返回数量(最大20)

offset

number

0

分页偏移

sort_type

number

0

0=综合,1=最多点赞,2=最新

publish_time

number

0

0=不限,1=1天,7=1周,180=半年

download_video - 无水印视频下载

参数

类型

说明

aweme_id

string

视频ID(从 search_videos 获取)

get_user_info - 获取用户信息

参数

类型

说明

sec_user_id

string

用户安全ID(MS4wLjABAAAA...开头)

返回:性别、头像、粉丝数、作品数、IP属地等。

get_user_videos - 获取用户全部视频

参数

类型

默认

说明

sec_user_id

string

必填

用户安全ID

max_count

number

0

最大获取数量(0=全部)

自动翻页获取用户发布的所有视频。

search_and_get_all - 一键获取全部

参数

类型

默认

说明

keyword

string

必填

搜索关键词

count

number

3

搜索结果数量

流程:搜索关键词 → 去重作者 → 获取每个作者的性别、头像、全部视频列表。

参数

类型

说明

share_link

string

抖音分享链接或包含链接的文本

无需 Cookie 的备用方案。

无参数。打开浏览器窗口,提示用户用抖音APP扫码登录,自动获取并保存 Cookie 到 cookies.txt。

登录成功后自动重置 API 客户端,后续请求直接使用新 Cookie。

独立命令行

# 搜索视频
npx tsx src/demo.ts search 美女 5

# 获取视频详情 + 下载无水印视频
npx tsx src/demo.ts video 7412568048542076170

# 获取用户信息
npx tsx src/demo.ts user MS4wLjABAAAAgmkQIxbm...

# 获取用户所有视频
npx tsx src/demo.ts uservideos MS4wLjABAAAAgmkQIxbm...

# 一键完成:搜索 → 获取作者全部视频 + 性别 + 头像 + 下载
npx tsx src/demo.ts all 美女 3

# 从分享链接解析(无需 Cookie)
npx tsx src/demo.ts share "https://v.douyin.com/xxx/"

# 扫码登录获取Cookie
npx tsx src/demo.ts cookie

项目结构

douyin-mcp-node/
├── package.json
├── tsconfig.json
├── cookies.txt              # 抖音 Cookie(需自行创建)
├── douyin.js                # a_bogus 签名算法
├── src/
│   ├── index.ts             # MCP 服务器入口(7个工具)
│   ├── demo.ts              # 独立命令行脚本
│   ├── client.ts            # 抖音 API 客户端
│   ├── models.ts            # TypeScript 类型定义
│   ├── sign.ts              # a_bogus 签名
│   ├── token-manager.ts     # Token 生成
│   ├── utils.ts             # 常量和工具函数
│   ├── share-parser.ts      # 分享链接解析
│   └── cookie-fetcher.ts    # Puppeteer 扫码获取Cookie
└── dist/                    # 编译输出

技术栈

  • 运行时: Node.js 18+

  • 语言: TypeScript 5.5+

  • MCP SDK: @modelcontextprotocol/sdk

  • HTTP: axios

  • 浏览器自动化: puppeteer-core

  • 签名: Node.js vm 模块 + douyin.js

常见问题

Q: 搜索返回空结果? A: 检查 Cookie 是否完整,必须包含 sessionid、ttwid、sid_guard。

Q: Cookie 多久过期? A: 通常几天到几周。过期后重新获取并替换 cookies.txt 内容即可。

Q: 下载失败? A: 视频 URL 有时效性(通常几小时),需要重新获取。

Q: 不想配置 Cookie 能用吗? A: 可以使用 parse_share_link 工具或 npx tsx src/demo.ts share <链接> 命令,无需 Cookie。

法律声明

免责声明

本项目仅供个人学习和技术研究使用,严禁用于任何商业用途或违法行为。

合规要求

使用本项目前,请确保您已了解并遵守以下规定:

  • 《中华人民共和国网络安全法》:不得利用技术手段非法获取、出售或提供公民个人信息

  • 《中华人民共和国个人信息保护法》:获取的用户信息(头像、性别等)属于个人信息,未经授权不得存储、传播或用于其他目的

  • 《中华人民共和国著作权法》:下载的视频作品受著作权保护,未经权利人许可不得复制、传播或用于商业用途

  • 抖音平台服务协议:使用本工具可能违反抖音的用户协议,相关风险由使用者自行承担

使用限制

  • 仅限获取公开发布的内容,不得用于获取私密或受限内容

  • 下载的视频仅供个人离线观看,不得二次上传、分发或商用

  • 获取的用户信息不得用于人肉搜索、骚扰、诈骗等违法行为

  • 不得利用本工具进行大规模爬取,避免对平台造成负担

风险提示

  • 本项目可能随时因平台接口变更而失效

  • 使用本工具导致账号被封禁、法律纠纷等后果,由使用者自行承担

  • 作者不对因使用本项目造成的任何直接或间接损失负责

知识产权

本项目代码采用 MIT 许可证开源。项目中涉及的抖音商标、标识等知识产权归字节跳动公司所有。

Available Tools

7 tools
download_videoC

获取抖音视频详情和无水印下载地址

Inputs: aweme_id (required).

get_user_infoB

获取抖音用户信息,包括性别、头像、粉丝数等

Inputs: sec_user_id (required).

get_user_videosC

获取指定抖音用户发布的视频列表,支持分页或自动获取全部

Inputs: sec_user_id (required), max_count.

search_and_get_allC

搜索关键词,匹配到视频后,获取每个作者的全部视频、性别、头像下载地址

Inputs: keyword (required), count.

search_videosB

搜索抖音视频,返回视频列表(包含视频ID、标题、作者信息等)

Inputs: keyword (required), count, offset, sort_type, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 7 tools

    Disambiguation3/5

    search_and_get_all overlaps heavily with the search_videos + get_user_videos combination, and download_video vs parse_share_link both return no-watermark download URLs, creating real boundary confusion. The descriptions clarify some of this (backup vs primary, composite vs single-step), but an agent must reason carefully to pick correctly.

    Naming Consistency4/5

    All tools use snake_case with a verb_noun structure (search_videos, get_user_info, download_video, get_cookie), which is predictable. The only deviation is the compound search_and_get_all, which breaks the clean verb_noun pattern.

    Tool Count4/5

    Seven tools is a well-scoped set for a Douyin scraping/download server covering auth, search, user, and download workflows. One tool (search_and_get_all) is arguably redundant with the single-step tools, keeping it just short of ideal.

    Completeness4/5

    The surface covers the core lifecycle: cookie login, keyword search, user info, user video listing, and no-watermark download, with a cookie-free fallback. Minor gaps exist (no comments, likes, or trending/hot-video discovery), but essential workflows are covered.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables automation of Douyin (TikTok China) tasks including parsing share links to get watermark-free download URLs and uploading videos from specified local paths.
      15
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables downloading TikTok videos and photos without watermarks, extracting metadata and analytics, and performing bulk downloads of user profiles via CLI or as an MCP server for AI assistants.
      5
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables local scraping and interaction with Douyin (TikTok China) content, including videos, user data, comments, live streams, and private messages, using personal account cookies without official APIs.
      1
      -