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 30 sept 2026·10 min read
~/tiktok-mcp-cli
$ claude
Claude Code v2.1.220
>
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 2 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.

Here's what the TikTok MCP server and CLI is, how to set it up in each app, and every tool it has.

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 2 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.

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.

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.

Before you start0/3

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 auth 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 auth

Add --publish to that command if you added the publishing scopes. Those 3 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 auth step again.

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, and tiktok-cli <command> --help shows what a command takes. Publishing and revoking need --confirm, the terminal's version of the check your AI has to pass.

These flags work on every command:

FlagWhat it does
--jsonPrints JSON
--compactPrints the JSON on one line
--agentMachine mode: JSON, compact, no prompts and no color
--select a,b.cKeeps only those fields, and a dotted path goes deeper
--confirmLets a write that asks first go ahead

A script can branch on the exit code:

Exit codeWhat it means
0It worked
2The command was typed wrong, or a write needed --confirm
3It wasn't found
4TikTok rejected the credentials
5TikTok's API failed
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
6,000 tokens
CLI
Nothing
Every message, in Claude Code
MCP server
730 tokens
CLI
Nothing
When TikTok comes up
MCP server
Nothing more, or in Claude Code the tools it picks
CLI
3,100 tokens, once
20 messages with TikTok in 1, every tool loaded
MCP server
119,000 tokens
CLI
3,100 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 170 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.

Where the MCP server's tokens go

Part of the tool listShare
JSON Schema structure, like types, required lists and nesting51%
Argument descriptions27%
Tool descriptions22%

51% of it is MCP writing every tool out as JSON Schema, which any server with this many tools pays. The rest is the wording that lets your AI use each tool without guessing.

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 9 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 September 27, 2026 in Claude Code 2.1.257 with Claude Opus 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

All 14 tools, grouped the way the repo groups them. 9 only read, and 5 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 3 things you can't take back from a chat window ask first: they refuse to run until your AI passes confirm: true. 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.

Make it read-only

Set TIKTOK_READ_ONLY=1 and every write disappears from the tool list, leaving 9 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.

⚠️

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 auth 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 auth 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

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 auth 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 auth step again
A redirect_uri error during authYour app's URI isn't exactly http://127.0.0.1:8481/callback/, usually the trailing slash
Auth hangs and never returnsPort 8481 is taken. Run auth --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 9 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.

TikTok MCP Server FAQs

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.

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.

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 only run once your AI passes a confirm check, 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 auth step again.

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

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

Navid Moazzez built the TikTok MCP server and maintains it.

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

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. Learn more.

More MCP servers & CLIs

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