
How to Schedule Tweets from Claude Code CLI (2026 Setup Guide)
If you write code in the terminal, you can schedule tweets from the terminal too. Claude Code -- Anthropic's command-line interface for Claude -- supports MCP servers, which means you can connect it directly to your Twitter/X account and manage your entire posting workflow without opening a browser.
This guide covers the full setup: getting your API key, configuring the MCP server, verifying the connection, and then actually using it with real developer workflows. By the end, you'll be scheduling tweets, creating threads, and checking analytics from the same terminal session where you write and ship code.
Why Use Claude Code for Twitter
There's a practical reason this works so well for developers: context.
When you're in a Claude Code session, Claude already knows what you're working on. It can see your files, read your git history, and understand your project. So when you tell it to tweet about what you just shipped, it can write something specific and accurate instead of generic filler.
Here's why developers are using this workflow:
- Post directly from your development flow. You commit a feature, then tell Claude to tweet about it. Same session, no switching.
- Automate tweets about releases, deployments, and milestones. Claude reads your changelog or git tags and writes the announcement.
- Manage your X presence without leaving the terminal. Check analytics, review drafts, schedule a week of content -- all from your shell.
- Perfect for build-in-public. The barrier to posting drops to near zero when the AI assistant you're already talking to can also handle Twitter.
Prerequisites
Three things before you start:
- Claude Code CLI installed -- If you haven't set it up yet, run
npm install -g @anthropic-ai/claude-codeor follow Anthropic's official installation instructions. Verify withclaude --version. - An OpenTweet account with an API key -- Sign up at opentweet.io (7-day free trial, no credit card). Connect your X/Twitter account, then create an API key from the Developer Dashboard. Your key starts with
ot_. - Node.js 18+ installed -- Run
node --versionto check. The MCP server needs Node to run.
No Twitter developer account is required. OpenTweet handles the X API connection.
Step 1: Get Your OpenTweet API Key
- Sign up at opentweet.io if you haven't already.
- Connect your X/Twitter account through the dashboard (one-time OAuth flow).
- Go to your Developer Dashboard.
- Click "Generate API Key." Copy the key -- it looks like
ot_abc123def456.
API access is included on all plans, starting at $11.99/month. The free trial gives you full access.
Step 2: Add the MCP Server
There are three ways to configure the server. Choose based on whether you want it available globally, per-project, or somewhere in between.
Method A: CLI Command (Recommended)
The fastest approach. One command registers the server:
claude mcp add opentweet -e OPENTWEET_API_KEY=ot_your_key_here -- npx -y @opentweet/mcp-server
This adds the server to your user-level Claude Code config with the API key baked in. It's available in every Claude Code session on your machine.
Alternatively, register the server without the key inline and set the environment variable separately:
claude mcp add opentweet -- npx -y @opentweet/mcp-server
Then add the API key to your shell profile (~/.bashrc, ~/.zshrc, or ~/.profile):
export OPENTWEET_API_KEY="ot_your_key_here"
Reload your shell or run source ~/.zshrc for it to take effect.
Method B: Project Config (.mcp.json)
If you want the MCP server tied to a specific project -- useful for teams or for separating work and personal accounts -- create a .mcp.json file in your project root:
{
"mcpServers": {
"opentweet": {
"command": "npx",
"args": ["-y", "@opentweet/mcp-server"],
"env": {
"OPENTWEET_API_KEY": "ot_your_key_here"
}
}
}
}
When you launch Claude Code from that directory, the MCP server loads automatically.
Important: If you commit .mcp.json to git for your team, do not put your API key directly in the file. Use an environment variable reference instead, and have each team member set their own key in their shell profile. More on this in the team config section below.
Method C: User Config (~/.claude.json)
For global access across all projects without using the CLI command, you can edit your user-level config directly. Open ~/.claude.json and add the MCP server entry:
{
"mcpServers": {
"opentweet": {
"command": "npx",
"args": ["-y", "@opentweet/mcp-server"],
"env": {
"OPENTWEET_API_KEY": "ot_your_key_here"
}
}
}
}
This has the same effect as Method A but gives you direct control over the config file.
Step 3: Verify Setup
Run a quick check to confirm everything is connected.
First, verify the server is registered:
claude mcp list
You should see opentweet in the list of configured servers.
Next, start a Claude Code session and test the connection:
claude
Inside the session, type:
What OpenTweet tools are available?
Claude should list all 18 tools: opentweet_create_tweet, opentweet_create_thread, opentweet_list_tweets, opentweet_get_tweet, opentweet_update_tweet, opentweet_delete_tweet, opentweet_publish_tweet, opentweet_batch_schedule, opentweet_upload_media, opentweet_get_analytics, opentweet_get_account, opentweet_list_accounts, and 6 evergreen queue tools.
For a more concrete test:
Show me my OpenTweet account status
This calls the opentweet_get_account tool and returns your plan, connected accounts, and daily limits. If you see that information, you're ready.
Step 4: Developer Workflows
Here's where this setup earns its keep. These are practical, developer-specific workflows that take advantage of Claude Code's ability to see your project context.
Auto-announce releases
You just tagged a new version. Instead of writing a tweet manually, let Claude do it from the context of what actually changed:
I just tagged v2.1.0. Look at the CHANGELOG.md and create a tweet thread announcing the release with the top 3 changes. Schedule it for tomorrow at 9am EST.
Claude reads your changelog, picks the most interesting items, writes a thread that's technically accurate, and schedules the whole thing. This works because Claude Code has access to your files -- it's not guessing what you shipped.
Build-in-public updates
After wrapping up a productive day:
Schedule a tweet for tomorrow morning sharing that we hit 1,000 registered users this week. Keep it authentic, not braggy. Save as draft so I can review it first.
Claude writes the tweet in a natural tone, creates it as a draft on OpenTweet, and you can review it in the dashboard or right there in the terminal before scheduling.
Content from code context
Your project's README is already a good description of what you built. Use it:
Read the README.md and create 3 tweet variations promoting this project. Each should have a different angle -- one technical, one problem-focused, one social proof.
Claude analyzes your README and generates three distinct tweets. You pick the best one, schedule it, or save all three as drafts to post throughout the week.
Batch scheduling
Planning your week in one session:
Generate 5 tweets about TypeScript best practices based on patterns I use in this codebase. Schedule them Monday through Friday at 10am EST.
Claude scans your TypeScript files, identifies interesting patterns, and writes tweets about them. Then it batch schedules all five using opentweet_batch_schedule. Five tweets, one command, all rooted in your actual code.
Evergreen management
Your best tweets deserve a longer life:
Show my posting analytics for the last 30 days. Find my top 3 performing tweets and add them to my evergreen queue with a 14-day cooldown.
Claude fetches your analytics, identifies the winners, and adds them to your evergreen queue. Those tweets will automatically repost on rotation, keeping your best content in circulation while you focus on new work.
Post-deploy announcements
Wire this into your deploy workflow mentally (or literally with a script):
I just deployed to production. The main changes are: dark mode support, 40% faster search, and a new onboarding flow. Write a tweet about the deploy and publish it now.
Claude writes the tweet and publishes it immediately using opentweet_publish_tweet. Your followers hear about changes the moment they go live.
Project-Scoped Config for Teams
If you work on a team and want everyone to have the same MCP setup, use a .mcp.json in the project root. But never commit API keys.
Here's the pattern that works:
Create .mcp.json with environment variable references:
{
"mcpServers": {
"opentweet": {
"command": "npx",
"args": ["-y", "@opentweet/mcp-server"],
"env": {
"OPENTWEET_API_KEY": "${OPENTWEET_API_KEY}"
}
}
}
}
Commit this file to git. Each team member sets their own OPENTWEET_API_KEY in their shell profile. When they launch Claude Code from the project directory, the server connects to their individual OpenTweet account.
Add a note in your project's README or contributing guide:
## Twitter posting (optional)
Set `OPENTWEET_API_KEY` in your shell profile to enable tweet scheduling from Claude Code.
Get your key at https://opentweet.io/developer
This way the team gets a shared workflow without sharing credentials.
Multi-Account for Agencies and Teams
If you manage multiple X accounts -- your personal brand, a company account, a client's account -- the MCP server handles this with a single config.
First, connect all accounts through the OpenTweet dashboard. Multi-account is available on Advanced (3 accounts) and Agency (10 accounts) plans.
Then, in Claude Code:
Show my connected X accounts
Claude calls opentweet_list_accounts and shows each connected handle with its ID.
To target a specific account:
Post this release announcement to the @companyname account
Claude automatically passes the correct x_account_id parameter. You don't need to remember IDs -- just reference the account by its handle or nickname.
For details on multi-account management, see the Multi X Account feature page.
Using Built-in Prompts
The MCP server includes 4 prompt templates for common workflows:
Weekly Content Plan -- Provide your topics and tone. Claude checks your analytics for optimal posting times, generates 7-14 tweets, and schedules them across the week.
Review & Schedule Drafts -- Claude pulls your existing drafts, suggests improvements, and helps you batch schedule the ones that are ready.
Content from URL -- Give Claude a URL (blog post, landing page, GitHub repo) and it generates 3-5 tweet variations with different hooks and angles.
Performance Review -- A full analytics breakdown with actionable suggestions: what's working, what's not, and what to try next.
These prompts combine multiple tools into cohesive workflows, saving you from issuing individual commands.
Combining with Development Workflows
Because Claude Code already integrates with your development toolchain, you can create natural handoffs between coding and tweeting:
After merging a PR:
I just merged the auth refactor PR. Summarize what changed and schedule a build-in-public tweet about it for tomorrow.
After a successful deploy:
The deploy succeeded. Tweet about the new features we just shipped to production.
After hitting a project milestone:
We just crossed 10,000 npm downloads. Create a milestone tweet and a follow-up tweet asking what feature people want next.
When writing documentation:
I just updated the API docs. Create a tweet promoting the new endpoints and link to the docs.
The key advantage is that Claude Code can read your actual project files, diffs, and git history. Tweets about your work are grounded in what you actually built, not what a generic AI imagines you might have built.
Common Issues and Fixes
Server not found in claude mcp list
If the server doesn't appear after running claude mcp add, check that the command completed without errors. Try removing and re-adding:
claude mcp remove opentweet
claude mcp add opentweet -e OPENTWEET_API_KEY=ot_your_key_here -- npx -y @opentweet/mcp-server
Environment variable not set
If you see an error about OPENTWEET_API_KEY being required, the variable isn't reaching the MCP server. The most reliable fix is to include it directly in the claude mcp add command using the -e flag, rather than relying on your shell profile.
Node.js not found
The MCP server runs with npx, which requires Node.js. Run node --version to verify it's installed and is version 18 or higher. If you use nvm, make sure the correct version is active in the shell where you run Claude Code.
Permission errors on .mcp.json
If Claude Code can't read the project-level config, check file permissions. The file needs to be readable by your user. Run ls -la .mcp.json to verify.
Timeout on first run
The first time the server starts, npx downloads the @opentweet/mcp-server package. On slow connections, this can take a few seconds. Subsequent runs use the cached package and start much faster.
Frequently Asked Questions
Do I need both Claude Code and an OpenTweet account?
Yes. Claude Code is the AI interface (the terminal where you type). OpenTweet is the Twitter connection (the service that actually schedules and publishes your tweets). The MCP server is the bridge between them.
Does Claude Code need to stay open for scheduled tweets to post?
No. When you schedule a tweet, it's stored on OpenTweet's servers. OpenTweet publishes it at the scheduled time regardless of whether Claude Code is running. You can close the terminal, shut down your machine, and your tweets still go out.
Can Claude Code read my codebase and write tweets about it?
Yes, and this is the main reason to use Claude Code over other MCP clients for this. Claude Code has full context about your project directory -- files, git history, README, changelog. When you ask it to tweet about what you shipped, it can reference actual changes instead of writing generic content.
How many tweets can I schedule per day?
Depends on your plan: Pro allows 20 per day, Advanced allows 100 per day, Agency allows 300 per day. You can batch schedule up to 50 tweets in a single API call.
Can I publish immediately instead of scheduling?
Yes. Ask Claude to "publish this now" and it uses opentweet_publish_tweet to post immediately. You can also save as draft (no schedule) or schedule for a specific date and time.
Does this work on Linux?
Yes. Claude Code runs on macOS and Linux. The OpenTweet MCP server runs anywhere Node.js 18+ is available. Windows support depends on Claude Code's availability for your platform.
Is the MCP server open source?
Yes. The @opentweet/mcp-server package is published on npm and you can inspect the source code. It communicates with OpenTweet's API using your API key -- no Twitter credentials are stored locally.
Get Started
The full setup path:
- Sign up for OpenTweet (7-day free trial, no credit card)
- Connect your X/Twitter account in the dashboard
- Generate an API key from the Developer page
- Add the MCP server:
claude mcp add opentweet -e OPENTWEET_API_KEY=ot_your_key_here -- npx -y @opentweet/mcp-server - Start Claude Code and schedule your first tweet
You're already in the terminal building things. Now you can tell people about it without breaking your flow.
The OpenTweet MCP server is open-source and available on npm. Works with Claude Code, Claude Desktop, Cursor, Windsurf, and any MCP-compatible client. For setup instructions and documentation, visit opentweet.io/mcp. For the Twitter scheduling API, see opentweet.io/features/twitter-scheduling-api.
Start Scheduling Your X Posts Today
Join hundreds of creators using OpenTweet to stay consistent, save time, and grow their audience.