Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

postTweet

Publish tweets to Twitter using a structured input format. Enables integration with the Twitter MCP Server for streamlined social media interaction.

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: checks for Twitter client, posts the tweet via Twitter API v2, handles success response with tweet ID and formats errors.
    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 definition and input schema for postTweet, specifying the required 'text' parameter.
    postTweet: { description: 'Post a tweet to Twitter', inputSchema: { type: 'object', properties: { text: { type: 'string', description: 'The text of the tweet' }, }, required: ['text'], },
  • TypeScript interface defining the input arguments for postTweet.
    export interface PostTweetArgs { text: string;
  • src/index.ts:152-155 (registration)
    Tool dispatch registration in the MCP server: maps 'postTweet' tool call to handlePostTweet handler.
    case 'postTweet': { const { text } = request.params.arguments as { text: string }; response = await handlePostTweet(client, { text }); break;
  • src/index.ts:17-17 (registration)
    Import of the postTweet handler function.
    handlePostTweet,

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