How to integrate Twitter MCP with Kimi Code

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Twitter logo
Kimi Code logo
divider

How to integrate Twitter MCP with Kimi Code

Kimi Code is Moonshot AI's open-source coding agent, powered by Kimi K2.6. It runs in your terminal, reads and edits code, executes shell commands, and plans multi-step tasks, with native MCP support for extending it to outside tools.

In this guide, I will explain the easiest and most secure way to connect your Twitter account to Kimi Code via Composio Connect, so it can post a tweet with latest blog link, add user to your conference list, retrieve your most recent bookmarked tweets, and more without ever putting your account credentials at risk.

Also integrate Twitter with

Why use Composio?

Composio provides:

  • Access to 1,000+ managed apps from a single MCP endpoint. This makes it convenient for agents to run cross-app workflows.
  • Managed OAuth. You do not have to worry about authentication and authorization flows for every app.
  • Programmatic tool calling. Allows LLMs to write code in a remote workbench to handle complex tool chaining. This reduces back-and-forth for frequent tool calls.
  • Large tool response handling outside the LLM context. This minimizes context bloat from large tool responses.
  • Dynamic just-in-time access to thousands of tools across hundreds of apps. Composio loads the tools your agent needs, so LLMs are not overwhelmed by tools they do not need.

Connect Twitter to Kimi Code

Kimi Code is a TypeScript agent distributed through npm. It acts as an MCP client and reads server definitions from an mcp.json file, and it can also add and authenticate servers conversationally through /mcp-config. Composio is a remote HTTP server that authenticates with OAuth, so no API key is stored anywhere.

1. Install Kimi Code

The quickest way is the official install script, which requires no pre-installed Node.js and places the kimi executable on your PATH.

bash
# macOS or Linux
curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash

# Windows PowerShell
irm https://code.kimi.com/kimi-code/install.ps1 | iex

# Confirm the installation
kimi --version

2. Log in

Start Kimi Code in your project directory, then sign in from the interactive UI:

bash
kimi

Run /login and choose Kimi Code OAuth using the device-code flow, or use a Moonshot API key.

3. Add Composio with /mcp-config

In current versions of Kimi Code, MCP servers are managed inside the app, not with a shell subcommand. From the interactive UI, run:

bash
/mcp-config
Kimi Code MCP config flow for adding the Composio MCP server

Tell it the server name and URL in plain language. For example:

Server name is Composio, and here is the server URL: https://connect.composio.dev/mcp

Kimi Code asks whether to add it globally, at ~/.kimi-code/mcp.json, or project-local for the current checkout, then writes the entry for you:

bash
{
  "mcpServers": {
    "Composio": {
      "url": "https://connect.composio.dev/mcp"
    }
  }
}

There is no transport field to set. Kimi Code infers HTTP from the url.

4. Restart the session

The new server is picked up on a fresh session, not the current one. Start a new session:

bash
/new

On the new session, Kimi Code detects that the server needs authorization and prompts you to run:

bash
/mcp-config login Composio

5. Authorize with OAuth

Run the command Kimi suggests:

bash
/mcp-config login composio

Kimi Code opens Composio's authorization page or surfaces a URL. Approve access, then return to the session. You should see confirmation that the Composio MCP server is connected.

Composio authorization page for Kimi Code MCP setup

Check the connection status any time with /mcp. Composio should appear as connected with its tools listed.

Kimi Code showing Composio connected after OAuth authorization

Connect your Twitter account

Back in a Kimi Code session, ask the agent to connect to Twitter or give it any Twitter-related task.

For example, ask it to:

  • "Post a tweet with latest blog link"
  • "Add user to your conference list"
  • "Retrieve your most recent bookmarked tweets"

It will prompt you to authenticate and authorize access to Twitter.

That is it. Composio tools are now available in Kimi Code, and your Twitter account is ready to use.

Supported Tools & Triggers

Tools
Add a list memberAdds a user to a specified Twitter List; the list must be owned by the authenticated user.
Add post to bookmarksAdds a specified, existing, and accessible Tweet to a user's bookmarks, with success indicated by the 'bookmarked' field in the response.
Append Media UploadAppend data chunk to an ongoing media upload session on X/Twitter.
Get bookmarks by userRetrieves Tweets bookmarked by the authenticated user, where the provided User ID must match the authenticated user's ID.
Create activity subscriptionTool to create a subscription for an X activity event.
Create compliance jobCreates a new compliance job to check the status of Tweet or user IDs; upload IDs as a plain text file (one ID per line) to the `upload_url` received in the response.
Create group DM conversationCreates a new group Direct Message (DM) conversation on Twitter.
Create a listCreates a new, empty List on X (formerly Twitter), for which the provided name must be unique for the authenticated user; accounts are added separately.
Create a postCreates a Tweet on Twitter; `text` is required unless `card_uri`, `media_media_ids`, `poll_options`, or `quote_tweet_id` is provided.
Delete direct messagePermanently deletes a specific Twitter Direct Message (DM) event using its `event_id` if the authenticated user sent it; this action is irreversible and does not delete entire conversations.
Delete listPermanently deletes a specified Twitter List using its ID, which must be owned by the authenticated user; this action is irreversible and the list must already exist.
Get followers by user idRetrieves a list of users who follow a specified public Twitter user ID.
Get following by user IDRetrieves users followed by a specific Twitter user, allowing pagination and customization of returned user and tweet data fields via expansions.
Follow a listAllows the authenticated user (`id`) to follow a specific Twitter List (`list_id`) they are permitted to access, subscribing them to the list's timeline; this does not automatically follow individual list members.
Follow a userAllows an authenticated user (path `id`) to follow another user (`target_user_id`), which results in a pending request if the target user's tweets are protected.
Search full archive of tweetsSearches the full archive of public Tweets from March 2006 onwards; use 'start_time' and 'end_time' together for a defined time window.
Get users blocked by user IDRetrieves the authenticated user's own block list.
Retrieve compliance job by idRetrieves status, download/upload URLs, and other details for an existing Twitter compliance job specified by its unique ID.
Retrieve compliance jobsReturns a list of recent compliance jobs, filtered by type (tweets or users) and optionally by status.
Get DM events for a DM conversationFetches Direct Message (DM) events for a one-on-one conversation with a specified participant ID, ordered chronologically newest to oldest; does not support group DMs.
Get DM events by IDFetches a specific Direct Message (DM) event by its unique ID, allowing optional expansion of related data like users or tweets; ensure the `event_id` refers to an existing DM event accessible to the authenticated user.
Lookup list by IDReturns metadata for a specific Twitter List, identified by its ID; does not return list members but can expand the owner's User object via the `expansions` parameter.
Get list followersFetches a list of users who follow a specific Twitter List, identified by its ID; ensure the authenticated user has access if the list is private.
Fetch list members by idFetches members of a specific Twitter List, identified by its unique ID.
Get Media Upload StatusGet the processing status of uploaded media (videos/GIFs) on X/Twitter.
Get muted usersReturns user objects muted by the X user identified by the `id` path parameter.
Fetch OpenAPI specificationFetches the OpenAPI specification (JSON) for Twitter's API v2, used to programmatically understand the API's structure for developing client libraries or tools.
Get Post analyticsTool to retrieve analytics data for specified Posts within a defined time range.
Get post retweetersRetrieves users who publicly retweeted a specified public Post ID, excluding Quote Tweets and retweets from private accounts.
Retrieve retweets of a postRetrieves Tweets that Retweeted a specified public or authenticated-user-accessible Tweet ID, optionally customizing the response with fields and expansions.
Fetch tweet usage dataFetches Tweet usage statistics for a Project (e.
Get recent direct message eventsReturns recent Direct Message events for the authenticated user, such as new messages or changes in conversation participants.
Look up space by IDRetrieves details for a Twitter Space by its ID, allowing for customization and expansion of related data, provided the Space ID is valid and accessible.
Retrieve posts from a spaceRetrieves Tweets that were shared/posted during a Twitter Space broadcast.
Get spaces by creator IDsRetrieves Twitter Spaces created by a list of specified User IDs, with options to customize returned data fields.
Get space information by IDsFetches detailed information for one or more Twitter Spaces (live, scheduled, or ended) by their unique IDs; at least one Space ID must be provided.
Fetch space ticket buyers listRetrieves a list of users who purchased tickets for a specific, valid, and ticketed Twitter Space.
Look up user by IDRetrieves detailed public information for a Twitter user by their ID, optionally expanding related data (e.
Get user's followed listsReturns metadata (not Tweets) for lists a specific Twitter user follows, optionally including expanded owner details.
Get a user's list membershipsRetrieves all Twitter Lists a specified user is a member of, including public Lists and private Lists the authenticated user is authorized to view.
Get a user's owned listsCall this action to retrieve Lists created (owned) by a specific Twitter user, not Lists they follow or are subscribed to.
Get a user's pinned listsRetrieves the Lists a specific, existing Twitter user has pinned to their profile to highlight them.
Look up users by IDsRetrieves detailed information for specified X (formerly Twitter) user IDs, optionally customizing returned fields and expanding related entities.
Set reply visibilityHides or unhides an existing reply Tweet.
Initialize Media UploadInitialize a media upload session for X/Twitter.
List post likersRetrieves users who have liked the Post (Tweet) identified by the provided ID.
List posts timeline by list IDFetches the most recent Tweets posted by members of a specified Twitter List.
Mute user by IDMutes a target user on behalf of an authenticated user, preventing the target's Tweets and Retweets from appearing in the authenticated user's home timeline without notifying the target.
Pin a listPins a specified List to the authenticated user's profile, provided the List exists, the user has access rights, and the pin limit (typically 5 Lists) is not exceeded.
Delete tweetIrreversibly deletes a specific Tweet by its ID; the Tweet may persist in third-party caches after deletion.
Look up post by idFetches comprehensive details for a single Tweet by its unique ID, provided the Tweet exists and is accessible.
Get tweets by IDsRetrieves detailed information for one or more Posts (Tweets) identified by their unique IDs, allowing selection of specific fields and expansions.
Search recent tweetsSearches Tweets from the last 7 days matching a query (using X's search syntax), ideal for real-time analysis, trend monitoring, or retrieving posts from specific users (e.
Remove a list memberRemoves a user from a Twitter List; the response `is_member` field will be `false` if removal was successful or the user was not a member, and the updated list of members is not returned.
Remove a bookmarked postRemoves a Tweet, specified by `tweet_id`, from the authenticated user's bookmarks; the Tweet must have been previously bookmarked by the user for the action to have an effect.
Retrieve DM conversation eventsRetrieves Direct Message (DM) events for a specific conversation ID on Twitter, useful for analyzing messages and participant activities.
Retrieve posts that quote a postRetrieves Tweets that quote a specified Tweet, requiring a valid Tweet ID.
Retrieve liked tweets by user IDRetrieves Tweets liked by a specified Twitter user, provided their liked tweets are public or accessible.
Retweet postRetweets a Tweet for the authenticated user.
Get full archive search countsReturns a count of Tweets from the full archive that match a specified query, aggregated by day, hour, or minute; `start_time` must be before `end_time` if both are provided, and `since_id`/`until_id` cannot be used with `start_time`/`end_time`.
Fetch recent tweet countsRetrieves the count of Tweets matching a specified search query within the last 7 days, aggregated by 'minute', 'hour', or 'day'.
Search for spacesSearches for Twitter Spaces by a textual query, optionally filtering by state (live, scheduled, all) to discover audio conversations.
Send a new message to a userSends a new Direct Message with text and/or media (media_id for attachments must be pre-uploaded) to a specified Twitter user; this creates a new DM and does not modify existing messages.
Send a new message to a DM conversationSends a message, with optional text and/or media attachments (using pre-uploaded `media_id`s), to a specified Twitter Direct Message conversation.
Get tweets label streamStream real-time Tweet label events (apply/remove).
Unfollow a listEnables a user (via `id`) to unfollow a specific Twitter List (via `list_id`), which removes its tweets from their timeline and stops related notifications; the action reports `following: false` on success, even if the user was not initially following the list.
Unfollow userAllows the authenticated user to unfollow an existing Twitter user (`target_user_id`), which removes the follow relationship.
Unlike postAllows an authenticated user (`id`) to remove their like from a specific post (`tweet_id`); the action is idempotent and completes successfully even if the post was not liked.
Unmute a user by user IDUnmutes a target user for the authenticated user, allowing them to see Tweets and notifications from the target user again.
Unpin a listUnpins a List (specified by list_id) from the authenticated user's profile.
Unretweet postRemoves a user's retweet of a specified Post, if the user had previously retweeted it.
Update list attributesUpdates an existing Twitter List's name, description, or privacy status, requiring the List ID and at least one mutable property.
Upload MediaUpload media (images only) to X/Twitter using the v2 API.
Get user reverse chronological timelineRetrieves the home timeline (reverse chronological feed) for the authenticated Twitter user.
Like a tweetAllows the authenticated user to like a specific, accessible Tweet, provided neither user has blocked the other and the authenticated user is not restricted from liking.
Look up user by usernameFetches public profile information for a valid and existing Twitter user by their username, optionally expanding related data like pinned Tweets; results may be limited for protected profiles not followed by the authenticated user.
Look up users by usernameRetrieves detailed information for 1 to 100 Twitter users by their usernames (each 1-15 alphanumeric characters/underscores), allowing customizable user/tweet fields and expansion of related data like pinned tweets.
Get authenticated userReturns profile information for the currently authenticated X user, customizable via request fields.

Conclusion

You have successfully connected Twitter to Kimi Code using Composio Connect. Your agent can now manage Twitter from the terminal with natural language, without exposing credentials in prompts or local scripts.

Since the same Composio endpoint exposes 1,000+ apps, you can add Slack, Calendar, Linear, and more to the same server and chain them into cross-app workflows.

How to build Twitter MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Twitter MCP?

With a standalone Twitter MCP server, the agents and LLMs can only access a fixed set of Twitter tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Twitter and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with Kimi Code?

Yes, you can. Kimi Code fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Twitter tools.

Can I manage the permissions and scopes for Twitter while using Tool Router?

Yes, absolutely. You can configure which Twitter scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Twitter data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.