Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

postTweet

Publish tweets to Twitter using the Model Context Protocol. This tool enables automated posting of text content to the social media platform.

Instructions

Post a tweet to Twitter

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYesThe text of the tweet

Implementation Reference

  • Core handler function that executes the postTweet tool by calling the Twitter v2 API to post the tweet.
    export async function handlePostTweet( client: TwitterClient | null, { text }: { text: string } ): Promise<HandlerResponse> { if (!client) { return createMissingTwitterApiKeyResponse('Post Tweet'); } try { const tweet = await client.v2.tweet(text); return createResponse(`Successfully posted tweet: ${tweet.data.id}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'posting tweet')); } throw new Error('Failed to post tweet: Unknown error occurred'); } }
  • MCP tool schema definition for postTweet, including input schema and description.
    postTweet: { description: 'Post a tweet to Twitter', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'The text of the tweet' }, }, required: ['text'], },
  • src/index.ts:152-155 (registration)
    Registration and dispatch logic in the main MCP server handler that calls the postTweet handler.
    case 'postTweet': { const { text } = request.params.arguments as { text: string }; response = await handlePostTweet(client, { text }); break;
  • TypeScript interface defining the input arguments for postTweet.
    export interface PostTweetArgs { text: string;

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/crazyrabbitLTC/mcp-twitter-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server