Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getUserInfo

Retrieve detailed information about a Twitter user by providing their username. Supports data extraction for user profiles on the Twitter MCP Server.

Instructions

Get information about a Twitter user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user

Implementation Reference

  • Core handler function that fetches Twitter user information using the Twitter API v2 client.v2.userByUsername endpoint, handles errors and missing credentials.
    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; } };
  • MCP tool schema definition with input validation requiring 'username' parameter.
    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)
    Registration and dispatch of the getUserInfo tool in the MCP server's CallToolRequestHandler switch statement.
    case 'getUserInfo': { const { username } = request.params.arguments as { username: string }; response = await handleGetUserInfo(client, { username }); break;
  • TypeScript interface defining the arguments for getUserInfo handler.
    export interface GetUserInfoArgs { username: 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