get_twitter_profile
Retrieve Twitter/X profile information including user data and engagement metrics by providing a username handle.
Instructions
Get Twitter/X profile data
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | Twitter username |
Input Schema (JSON Schema)
{
"properties": {
"handle": {
"description": "Twitter username",
"type": "string"
}
},
"required": [
"handle"
],
"type": "object"
}
Implementation Reference
- src/index.ts:379-389 (handler)Handler logic for the 'get_twitter_profile' tool. Makes an API call to Sociavault's twitter/profile endpoint with the provided handle, extracts the profile data using extractTwitterProfile helper, and returns the JSON stringified result.if (name === "get_twitter_profile") { const { handle } = args as { handle: string }; const response = await axios.get(`${BASE_URL}/twitter/profile`, { headers: { "X-API-Key": API_KEY }, params: { handle }, }); const extracted = extractTwitterProfile(response.data); return { content: [{ type: "text", text: JSON.stringify(extracted, null, 2) }], }; }
- src/index.ts:234-244 (registration)Registration of the 'get_twitter_profile' tool in the tools array, including name, description, and input schema. This is used by the ListToolsRequestHandler.{ name: "get_twitter_profile", description: "Get Twitter/X profile data", inputSchema: { type: "object", properties: { handle: { type: "string", description: "Twitter username" }, }, required: ["handle"], }, },
- src/index.ts:237-243 (schema)Input schema definition for the 'get_twitter_profile' tool, specifying the required 'handle' parameter.inputSchema: { type: "object", properties: { handle: { type: "string", description: "Twitter username" }, }, required: ["handle"], },
- src/index.ts:71-83 (helper)Helper function to extract and normalize Twitter profile data from the API response.function extractTwitterProfile(data: any) { const user = data?.data?.user || data?.user || {}; return { username: user.screen_name || user.username, name: user.name, description: user.description, followers: user.followers_count || 0, following: user.friends_count || 0, tweets: user.statuses_count || 0, verified: user.verified, profile_image: user.profile_image_url_https, }; }