Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

likeTweet

Like a tweet on Twitter by specifying its unique ID using the Twitter MCP Server's tool, enabling direct engagement through the platform.

Instructions

Like a tweet by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tweetIdYesThe ID of the tweet to like

Implementation Reference

  • Core handler function that executes the likeTweet tool. Checks for Twitter client, fetches current user ID, calls Twitter API v2.like(userId, tweetId), and returns success or formatted error.
    export const handleLikeTweet: TwitterHandler<TweetEngagementArgs> = async ( client: TwitterClient | null, { tweetId }: TweetEngagementArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('likeTweet'); } try { const { data: { id: userId } } = await client.v2.me(); await client.v2.like(userId, tweetId); return createResponse(`Successfully liked tweet: ${tweetId}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'liking tweet')); } throw error; } };
  • Tool schema definition including description and JSON schema for input validation (requires tweetId string). Used for tool listing and input validation.
    likeTweet: { description: 'Like a tweet by its ID', inputSchema: { type: 'object', properties: { tweetId: { type: 'string', description: 'The ID of the tweet to like' } }, required: ['tweetId'], }, },
  • src/index.ts:182-185 (registration)
    Tool dispatch/registration in the main CallToolRequest handler switch statement. Extracts tweetId from arguments and calls the handleLikeTweet function.
    case 'likeTweet': { const { tweetId } = request.params.arguments as { tweetId: string }; response = await handleLikeTweet(client, { tweetId }); break;
  • TypeScript interface defining the input arguments for likeTweet (tweetId: string).
    export interface LikeTweetArgs { tweetId: string; }
  • Runtime type assertion helper function to validate likeTweet arguments, ensuring tweetId is present and a string.
    export function assertLikeTweetArgs(args: unknown): asserts args is LikeTweetArgs { if (typeof args !== 'object' || args === null) { throw new Error('Invalid arguments: expected object'); } if (!('tweetId' in args) || typeof (args as any).tweetId !== 'string') { throw new Error('Invalid arguments: expected tweetId 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