Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getUserInfo

Retrieve Twitter user details by providing a username to access profile information through the Twitter MCP Server.

Instructions

Get information about a Twitter user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user

Implementation Reference

  • The core handler function that implements the getUserInfo tool. It fetches user information from Twitter API v2 using the provided username, handles errors, and returns formatted user data.
    export const handleGetUserInfo: TwitterHandler<GetUserInfoArgs> = async ( client: TwitterClient | null, { username, fields }: GetUserInfoArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('getUserInfo'); } try { const user = await client.v2.userByUsername( username, { 'user.fields': fields || ['description', 'public_metrics', 'profile_image_url', 'verified'] as TTweetv2UserField[] } ); if (!user.data) { throw new Error(`User not found: ${username}`); } return createResponse(`User info: ${JSON.stringify(user.data, null, 2)}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'getting user info')); } throw error; } };
  • The MCP tool schema definition for getUserInfo, including description and input schema requiring a 'username' string.
    getUserInfo: { description: 'Get information about a Twitter user', inputSchema: { type: 'object', properties: { username: { type: 'string', description: 'The username of the user' }, }, required: ['username'], }, },
  • src/index.ts:212-215 (registration)
    The registration and dispatch logic in the main MCP server request handler switch statement that routes 'getUserInfo' calls to the handler function.
    case 'getUserInfo': { const { username } = request.params.arguments as { username: string }; response = await handleGetUserInfo(client, { username }); break;
  • TypeScript interface defining the arguments for the getUserInfo handler, specifying the required 'username' parameter.
    export interface GetUserInfoArgs { username: string; }
  • Local interface in the handler file extending base args with optional Twitter user fields.
    interface GetUserInfoArgs extends UserHandlerArgs { fields?: TTweetv2UserField[]; }

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