TikTok MCP Server & CLI

A free, open source TikTok MCP server and CLI that lets Claude Code, Codex, Cursor and other AI agents read your stats, rank your videos and publish to TikTok.

Navid Moazzezby Navid Moazzez·Updated Oct 5, 2026·12 min read·
Your computer
  1. 1

    Get your refresh token once in a terminal, with your app's key and secret.

    It prints a sign-in link, then a refresh token that lasts about 365 days. That token goes in the next step. Put your own key, secret and refresh token in place of the examples.

    export TIKTOK_CLIENT_KEY=your_client_key
    export TIKTOK_CLIENT_SECRET=your_client_secret
    npx -y @thenavidm/tiktok-mcp-cli@latest login
  2. 2

    Add it with a single command in a terminal.

    Put your own key, secret and refresh token in place of the examples.

    claude mcp add tiktok \
    -e TIKTOK_CLIENT_KEY=your_client_key \
    -e TIKTOK_CLIENT_SECRET=your_client_secret \
    -e TIKTOK_REFRESH_TOKEN=your_refresh_token \
    -- npx -y @thenavidm/tiktok-mcp-cli@latest
  3. 3

    In Claude Code, type /mcp. TikTok should show as connected.

    /mcp

Needs Node 22 or newer and a TikTok app of your own, with its client key and secret. Set it up.

It's free and open source. If it saves you time, star it on GitHub, so more people find it.

Rate this tool

This free TikTok MCP server and CLI gives your AI real access to your TikTok account. It reads your videos and stats, ranks what worked, and publishes videos, photo carousels and drafts.

It's one install with two ways in. Claude, Codex, Cursor or any other MCP app calls its 14 tools for you, and the same tools work as a CLI that agents like Claude Code, Codex and OpenCode run, or that you type yourself.

In this guide, I'll show you:

  • What the TikTok MCP server & CLI is, and what you can ask it
  • How to install it and check that it works
  • When to use the MCP server, and when the CLI
  • Every tool, and how to keep your account safe

Every tool on this page comes from the server itself, and every cost was measured in Claude Code.

key_takeaways.mdTL;DR

Key takeaways

It gives your AI 14 tools for your TikTok account: your videos and stats, what worked, and publishing.
It publishes videos, photo carousels and drafts.
Publishing and revoking wait for your approval, while drafts go to your own TikTok inbox first.
The same tools run as a CLI, which costs your AI nothing until it runs.

What is the TikTok MCP server & CLI?

The TikTok MCP server & CLI is a free, open source program that lets AI agents work with your TikTok account for you, in two ways. The MCP server is what an AI app like Claude, Codex or Cursor connects to, through MCP (Model Context Protocol), the open standard AI apps use to call outside tools.

You ask in plain language. Your AI picks the right tool, and the server makes the call to TikTok's official API.

The CLI is the same program as commands. tiktok-cli top-videos runs the same code your AI runs when you ask which videos travelled, whether an agent like Claude Code runs it or you do.

In an AI OS, the layer that connects your AI to your context, your data and your tools, a server like this is how your AI reaches TikTok. My guide to building an AI operating system names TikTok among the tools it reaches, and here's how I use AI myself.

What can you ask it?

Once it's set up, you ask the way you'd ask an assistant. These are real prompts it handles:

Try asking
Which of my TikToks beat my median view count, and what do they have in common?
What is my real engagement rate per post, not the number the app shows me?
Rank my last 200 posts by shares rather than views.
Draft a TikTok from this MP4 and put it in my inbox, so I can review it on my phone.
Publish this photo carousel with the first image as the cover and comments off.
Did the video I posted 20 minutes ago clear moderation yet?

The third one shows why this is useful. TikTok's app sorts your videos by date, and here your AI can rank 200 of them by shares, the posts that actually travelled.

It works well next to my ScrapeCreators MCP server and YouTube MCP server, so your AI can study what other creators post and manage your YouTube videos in the same chat. Every server I've made is on my MCP servers page.

For the videos themselves, my free TikTok script generator and TikTok post analyzer help too. TikTok Shop is one of the ways I cover in ways to make money on your phone.

How to install the TikTok MCP server

Pick your app in the box at the top of this page. You get a refresh token once in a terminal, then add the server to your app with a single command or a pasted block.

Windsurf, Zed and Cline take the same server, though they don't have a tab in the box yet. Follow the box's Cursor tab, and put its block here instead:

AppWhere the block goes
WindsurfIn the Cascade panel, open the Actions menu (…) and choose Open MCP config file, then paste the block.
ClineClick the MCP Servers icon in the Cline panel, open the Configure tab, click Configure MCP Servers, and paste the block.
ZedGo to Settings, then AI, then MCP Servers, and choose Add Server, then Add Local Server. Enter the block's command, arguments and variables, and Zed saves them under context_servers.
Before you start0/4

Pro tip: Use Sandbox mode while you set this up. A sandbox app works right away with no review, for TikTok accounts you add to it yourself.

Set up your TikTok app

TikTok has no personal access tokens, so everyone makes a small app of their own. It's more work than most platforms, and it's the same for everybody.

Make your TikTok app0/6

Get your refresh token

Run the login step with your app's key and secret. It prints a sign-in link, and once you approve, it prints a refresh token that lasts about 365 days.

export TIKTOK_CLIENT_KEY=your_client_key
export TIKTOK_CLIENT_SECRET=your_client_secret
npx -y @thenavidm/tiktok-mcp-cli login

Add --publish to that command if you added the publishing scopes. Those three values go in your app's config, as the box at the top shows.

Watch out: Only ask for scopes your app actually has. One scope TikTok hasn't approved fails the sign-in completely, not just that permission.

Publishing needs a verified domain

TikTok pulls your video or photos from a link, and only from a domain you've proved you own. Verify it under URL properties on the app page, or skip this if you only read your stats or use drafts.

Check that it works

Run the doctor. It tests every connected account, names the scopes it was given, and says which tools are unavailable and why.

npx -y @thenavidm/tiktok-mcp-cli doctor

A "token rejected" means the refresh token ran out or was revoked, so run the login step again.

In Claude Code, /mcp also shows whether the TikTok server is connected. It's one of the Claude Code commands worth knowing.

Use the TikTok CLI

The CLI is the same 14 tools as commands. AI agents that run commands, like Claude Code, Codex and OpenCode, use it on their own, and you can type the same commands in a terminal or a script.

Every tool name becomes a command with dashes, so top_videos runs as tiktok-cli top-videos.

npm install -g @thenavidm/tiktok-mcp-cli
tiktok-cli
tiktok-cli get-profile
tiktok-cli top-videos

The bare tiktok-cli lists every command, tiktok-cli which <words> finds the command for a task, and tiktok-cli <command> --help shows what a command takes. Publishing and revoking need --confirm, the terminal's version of your approval.

tiktok-cli install <app> adds the server to Claude Code, Codex, Claude Desktop, Cursor, VS Code or Gemini CLI, in each app's own format.

These are the flags you'll use most:

FlagWhat it does
--jsonPrints JSON
--compactPrints the JSON on one line
--select a,b.cKeeps only those fields, and a dotted path goes deeper
--agentMachine mode: compact JSON, no prompts, and it never confirms anything
--confirmLets a write that asks first go ahead
--dry-runShows what a write would do, without doing it

A script can branch on the exit code:

Exit codeWhat it means
0It worked
1Something unexpected went wrong
2The command was typed wrong, or a write needed --confirm
3It wasn't found
4TikTok rejected the credentials
5TikTok failed or couldn't be reached
7You hit a rate limit, so wait and try again
10Nothing is set up yet

MCP server or CLI: which one?

Both are the same program with the same 14 tools. The difference is when your AI pays for them, in the tokens it reads.

Every message, in an app that loads every tool
MCP server
5,400 tokens
CLI
Nothing
Every message, in Claude Code
MCP server
720 tokens
CLI
Nothing
When TikTok comes up
MCP server
Nothing more, or in Claude Code the tools it picks
CLI
3,200 tokens, once
20 messages with TikTok in one, every tool loaded
MCP server
108,000 tokens
CLI
3,200 tokens
Works in Claude Desktop's chat
MCP server
Yes
CLI
No, there's no terminal there
Works in a script, a cron job or CI
MCP server
No
CLI
Yes

An app that loads every tool up front sends the full list with every message, whether you mention TikTok or not. Claude Code doesn't by default: its tool search sends only the tool names and the server's instructions, and loads a tool's full definition when your AI reaches for it.

The CLI costs nothing until TikTok comes up. Then your agent reads its skill file once and runs the commands it needs. With the skill added, Claude Code also lists its one-line description with every message, about 160 tokens.

When the whole conversation is about TikTok, the gap closes. Then the MCP server is the better experience, because you ask in plain language and your AI never has to look up a command.

How to spend less

In Claude Code, leave tool search on, which it is unless you've set ENABLE_TOOL_SEARCH=false.

Turn the server off when you aren't using TikTok. In Claude Code that's the /mcp panel, and every AI app has its own switch. TIKTOK_READ_ONLY=1 cuts it to the nine reading tools.

Or install the CLI and connect the server later, on the days it earns its place. Every tool stays in reach, and the standing cost drops to nothing.

Every number here was measured on October 5, 2026 in Claude Code 2.1.286 with Claude Opus 5.5. It's the same one-line prompt with and without the server connected, once with tool search off so every tool loads, and once with Claude Code's default. The skill was measured the same way, and other apps and models count tokens a little differently.

What TikTok's API can and can't do

TikTok's official API only sees your own account. There's no endpoint for anyone else's profile, videos, comments, hashtags or search, so no tool here can study a competitor or a trend.

There's no comments API either, even for your own posts. And until TikTok audits your app, every post goes up as private, whatever privacy you ask for.

Publishing returns a job, not a post. get_post_status follows it, and a public post has no post ID until moderation clears it, which usually takes a minute and sometimes hours.

Every TikTok tool

The tables below list all 14 tools, grouped the way the repo groups them. Of these, nine only read, and five change something on your account.

Your videos

list_videos
What it does
Your public TikTok posts, newest first, with views, likes, comments, shares and a computed engagement rate.
Kind
Reads
get_videos
What it does
Fetch up to 20 of your videos by id, with full stats.
Kind
Reads
top_videos
What it does
Your best posts, ranked.
Kind
Reads
search_my_videos
What it does
Find your posts whose title or description matches a query.
Kind
Reads
stats_summary
What it does
Aggregate stats over your recent posts: total and mean views, the median and 90th percentile, mean engagement rate, and how many days apart you post.
Kind
Reads

Publishing

get_creator_info
What it does
What this account is allowed to post: which privacy levels are available, whether comments, duet or stitch are switched off, and the longest video it may upload.
Kind
Reads
post_video
What it does
Publish a video straight to the account from a public URL.
Kind
Asks first
post_photos
What it does
Publish a photo carousel of up to 35 images from public URLs.
Kind
Asks first
send_video_to_drafts
What it does
Send a video to the account's TikTok inbox instead of publishing it.
Kind
Writes
send_photos_to_drafts
What it does
Send photos to the account's TikTok inbox for the creator to finish in the app.
Kind
Writes
get_post_status
What it does
Track a post created by post_video, post_photos or either drafts tool.
Kind
Reads

Account

list_accounts
What it does
Every TikTok account this server can act as, with the name to pass as account on any other tool.
Kind
Reads
get_profile
What it does
Profile and audience for a connected account: username, display name, bio, verified flag, follower and following counts, total likes across all videos, and how many videos are public.
Kind
Reads
revoke_access
What it does
Hands the token back to TikTok and removes your app from the account's connected-apps list.
Kind
Asks first

Is the TikTok MCP server safe?

Publishing is the point of the tool, so writes work from the start. The three things you can't take back from a chat window ask first. They're the ones marked "Asks first" in the tool tables above.

Drafts don't ask, because they land in your own TikTok inbox and go nowhere until you finish them.

When your AI calls one of them, the call needs a yes first. Where you use it decides who gives it:

  • Claude Code (2.1.246 and later) asks you before every call, in every one of its permission modes.
  • An app that can show forms asks you in a form.
  • Any other app takes your AI's confirm: true as the yes, so tell your AI to check with you first.
  • An agent with no person to ask needs TIKTOK_CONFIRM=model, so its confirm: true counts in every app.
  • In a terminal, you add --confirm to the command.

If the answer is no, nothing reaches TikTok.

Make it read-only

Set TIKTOK_READ_ONLY=1 and every write disappears from the tool list, leaving nine reading tools. TIKTOK_ALLOW_DESTRUCTIVE=0 is the middle setting: drafts still work, and publishing and revoking don't.

Keep a log of every write

Set TIKTOK_AUDIT_LOG to a file path. The server writes one line per attempted write, allowed or blocked, with what it was about to do and who approved it.

Watch out: Captions and bios are text other people wrote, and one can try to give your AI orders. The server labels them as someone else's words, but TIKTOK_READ_ONLY=1 is the real defense for an agent working on its own.

Your data

Nothing goes anywhere but TikTok's API. Your key, secret and refresh token stay in your app's config or your shell, and there's no tracking of any kind.

To disconnect, call the revoke_access tool, or remove the app in TikTok under Settings, then Security and permissions, then Manage app permissions.

Connect more than one TikTok account

Run the login step once per account, then list them together in TIKTOK_ACCOUNTS as name:token,name:token. Every tool that acts as you takes an optional account, so you can say which one posts.

TikTok MCP server settings

Every setting is an environment variable, in your app's config or your shell.

TIKTOK_CLIENT_KEY
Default
none
What it does
Holds your app's client key
TIKTOK_CLIENT_SECRET
Default
none
What it does
Holds your app's client secret
TIKTOK_REFRESH_TOKEN
Default
none
What it does
Holds what the login step printed, for one account
TIKTOK_ACCOUNTS
Default
none
What it does
Lists several accounts as name:token pairs
TIKTOK_READ_ONLY
Default
0
What it does
1 hides every write
TIKTOK_ALLOW_DESTRUCTIVE
Default
1
What it does
0 keeps drafts and blocks publishing and revoking
TIKTOK_AUDIT_LOG
Default
none
What it does
Logs every attempted write to a file
TIKTOK_SURFACE
Default
full
What it does
search lists three tools that find, describe and run the rest
TIKTOK_TOOL_TIMEOUT_MS
Default
none
What it does
Gives up on any tool after this many milliseconds
TIKTOK_CONFIRM
Default
human
What it does
model lets your AI's confirm: true approve on its own, for an agent with no person to ask
TIKTOK_HTTP_PORT
Default
8000
What it does
Sets the port for --http
TIKTOK_HTTP_HOST
Default
127.0.0.1
What it does
Sets the address for --http, and any other needs a token
TIKTOK_HTTP_TOKEN
Default
none
What it does
Sets the bearer token every --http request needs
TIKTOK_HTTP_ALLOWED_ORIGINS
Default
none
What it does
Lists other websites allowed to call --http, comma separated
TIKTOK_DEBUG
Default
off
What it does
1 prints debug lines

Troubleshooting

Run the doctor first. It names the step that failed and the fix.

What you seeWhat to do
scope_not_authorizedThe account never granted that scope. Run the login step again, with --publish for posting
The token is rejected on every callThe refresh token ran out after 365 days, or you revoked the app. Run the login step again
A redirect_uri error during loginYour app's URI isn't exactly http://127.0.0.1:8481/callback/, usually the trailing slash
Login hangs and never returnsPort 8481 is taken. Run login --port 9000 and add that URI to your app too
url_ownership_unverifiedThe media's domain isn't verified under URL properties
Everything posts as privateThat's expected before TikTok audits your app. Post as private, or apply for the audit
Only nine tools appearTIKTOK_READ_ONLY=1 is on, so the writes are hidden

If the server doesn't show up in your app at all, run the command your app runs, in a terminal, and read the error.

More free TikTok tools

Check a caption's length before your AI posts it, or turn a post into an image to share.

FAQs about the TikTok MCP server & CLI

Here are the questions people ask most about the TikTok MCP server and CLI.

The TikTok MCP server & CLI is a free, open source program that lets an AI app like Claude, Codex or Cursor work with your TikTok account.

It has 14 tools for your profile, video stats, top posts, publishing videos and photo carousels, drafts and post status, and the same tools run as a CLI that agents like Claude Code and Codex use, or that you type yourself.

An MCP server is a standard way to give an AI app real access to a tool, so it can act instead of guessing.

MCP stands for Model Context Protocol, and Claude, Codex, Cursor and many other AI apps speak it.

Every server I've made is on my MCP servers page.

The TikTok CLI is the same program as the TikTok MCP server, run as commands.

AI agents like Claude Code, Codex and OpenCode run them for you, and you can type them in a terminal or a script.

One npm package installs both.

Use the TikTok MCP server in an AI app with no terminal, like Claude Desktop's chat, and the CLI in a terminal, a script or a cron job.

In an AI app that can run commands, like Claude Code, Codex or Cursor, the CLI is the lighter choice, because it costs nothing until it runs.

Yes, the TikTok MCP server is free and open source under the MIT license.

TikTok's API is free too, so the only thing you pay for is your own AI app.

You need your own TikTok app because TikTok has no personal access tokens.

Every integration goes through an app you make at developers.tiktok.com, and Sandbox mode works right away with no review.

No, the TikTok MCP server only sees your own account.

TikTok's official API has no endpoint for anyone else's profile, videos, comments or search.

Everything posts as private until TikTok audits your app, whatever privacy level you ask for.

A sandbox app can't post publicly at all.

The TikTok MCP server posts when you ask it to.

Publishing and revoking wait for your approval in an app that can ask, like Claude Code, and read-only mode removes every write.

The TikTok refresh token lasts about 365 days, and the server renews the short access token for you.

When the refresh token runs out, run the login step again.

The TikTok MCP server works with any app that speaks MCP.

That includes Claude Code, Claude Desktop, Codex, Cursor, VS Code, Windsurf, Zed, Cline, GitHub Copilot CLI, Gemini CLI, OpenCode, OpenClaw, Antigravity and Hermes.

I did.

I'm Navid Moazzez, and I made the TikTok MCP server & CLI as one of my free tools on navid.me.

You can read more about me.

The code is on GitHub under the MIT license, and the package is on npm.

More MCP servers & CLIs

Related free tools

Navid Moazzez

AI business strategist & AI OS builder

Navid Moazzez helps creators and founders master AI and build their own AI Operating System (AI OS) to automate their business and life.

Navid.me is reader-supported. When you buy through links on this site, I may earn an affiliate commission. Read the affiliate disclaimer.

Free AI newsletter

The most actionable AI newsletter for founders

Every week, get proven AI strategies, curated tools, and step-by-step systems to grow your audience, create better content, and build a profitable creator business.

No fluff, no filler, no BS. Just five minutes each week that might level up your online business and life.

P.S. Sign up now to get free access to my ultimate AI tools guide for creators.

Loved by 10,000+ readers
Loved by 10,000+ readers