Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

getAuthenticatedUser

Retrieve your own Twitter profile information, including username, bio, and metrics, without specifying user credentials.

Instructions

Get the authenticated user's own profile information without needing to specify username or ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userFieldsNoAdditional user fields to include (e.g., ["id", "username", "name", "description", "public_metrics", "verified", "profile_image_url", "created_at"])

Implementation Reference

  • The handler function that implements the core logic for the 'getAuthenticatedUser' tool. It fetches the authenticated user's profile information using the Twitter API v2.me() endpoint, handles missing client, authentication errors, rate limits, and formats the response.
    /** * Get the authenticated user's own profile information */ export const handleGetAuthenticatedUser: TwitterHandler<GetAuthenticatedUserArgs> = async ( client: TwitterClient | null, { userFields }: GetAuthenticatedUserArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('getAuthenticatedUser'); } try { const me = await client.v2.me({ 'user.fields': (userFields as TTweetv2UserField[]) || ['id', 'username', 'name', 'description', 'public_metrics', 'verified', 'profile_image_url', 'created_at'] as TTweetv2UserField[] }); if (!me.data) { throw new Error('Unable to retrieve authenticated user information'); } return createResponse(`Authenticated user info: ${JSON.stringify(me.data, null, 2)}`); } catch (error) { if (error instanceof Error) { if (error.message.includes('401')) { throw new Error(`Authentication failed. Please check your API credentials and tokens. This endpoint requires valid OAuth 1.0a User Context or OAuth 2.0 Authorization Code with PKCE authentication.`); } if (error.message.includes('429')) { throw new Error(`Rate limit exceeded. Please wait before making another request.`); } throw new Error(formatTwitterError(error, 'getting authenticated user')); } throw error; } };
  • src/tools.ts:172-185 (registration)
    Registers the 'getAuthenticatedUser' tool in the MCP tools manifest, defining its description and JSON input schema for validation.
    getAuthenticatedUser: { description: 'Get the authenticated user\'s own profile information without needing to specify username or ID', inputSchema: { type: 'object', properties: { userFields: { type: 'array', items: { type: 'string' }, description: 'Additional user fields to include (e.g., ["id", "username", "name", "description", "public_metrics", "verified", "profile_image_url", "created_at"])' } }, required: [] } },
  • TypeScript interface defining the input arguments for the getAuthenticatedUser handler, providing type safety for the userFields parameter.
    export interface GetAuthenticatedUserArgs { userFields?: TTweetv2UserField[]; }
  • src/index.ts:217-220 (registration)
    Dispatches the 'getAuthenticatedUser' tool call to the appropriate handler function in the main server switch statement.
    case 'getAuthenticatedUser': { const { userFields } = request.params.arguments as { userFields?: TTweetv2UserField[] }; response = await handleGetAuthenticatedUser(client, { userFields }); break;

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