Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

unfollowUser

Remove a user from your following list on Twitter by specifying their username. Use this tool to manage your account's connections and streamline your feed.

Instructions

Unfollow a user by their username

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user to unfollow

Implementation Reference

  • Core implementation of the unfollowUser tool handler. Retrieves authenticated user ID, resolves target user by username, and executes Twitter v2 unfollow API call.
    export const handleUnfollowUser: TwitterHandler<UserHandlerArgs> = async ( client: TwitterClient | null, { username }: UserHandlerArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('unfollowUser'); } try { const userId = await client.v2.me().then((response: any) => response.data.id); const targetUser = await client.v2.userByUsername(username); if (!targetUser.data) { throw new Error(`User not found: ${username}`); } await client.v2.unfollow(userId, targetUser.data.id); return createResponse(`Successfully unfollowed user: ${username}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'unfollowing user')); } throw error; } };
  • MCP tool schema definition for unfollowUser, specifying input requirements (username) and description.
    unfollowUser: { description: 'Unfollow a user by their username', inputSchema: { type: 'object', properties: { username: { type: 'string', description: 'The username of the user to unfollow' } }, required: ['username'], }, },
  • src/index.ts:265-268 (registration)
    Registration and dispatch logic in the main MCP server request handler for routing unfollowUser tool calls to the handler function.
    case 'unfollowUser': { const { username } = request.params.arguments as { username: string }; response = await handleUnfollowUser(client, { username }); break;
  • TypeScript interface defining the input arguments for unfollowUser tool.
    export interface UnfollowUserArgs { username: string; }
  • Runtime type assertion function validating unfollowUser input arguments.
    export function assertUnfollowUserArgs(args: unknown): asserts args is UnfollowUserArgs { if (typeof args !== 'object' || args === null) { throw new Error('Invalid arguments: expected object'); } if (!('username' in args) || typeof (args as any).username !== 'string') { throw new Error('Invalid arguments: expected 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