muteUser
Stop seeing a specific user's tweets in your timeline by muting their account using their user ID or username.
Instructions
Mute a user account to stop seeing their tweets in your timeline
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| userId | No | The ID of the user to mute | |
| username | No | The username of the user to mute (alternative to userId) |
Implementation Reference
- The handler function that implements the muteUser tool logic, muting a Twitter user by resolving user ID if needed and calling the Twitter v2 mute API.export const handleMuteUser: TwitterHandler<MuteUserArgs> = async ( client: TwitterClient | null, { userId, username }: MuteUserArgs ): Promise<HandlerResponse> => { if (!client) { return createMissingTwitterApiKeyResponse('muteUser'); } try { if (!userId && !username) { throw new Error('Either userId or username must be provided'); } let targetUserId = userId; // If username provided, get the user ID first if (username && !userId) { const userResponse = await client.v2.userByUsername(username); if (!userResponse.data) { throw new Error(`User with username '${username}' not found`); } targetUserId = userResponse.data.id; } // Get authenticated user's ID const me = await client.v2.me(); const myUserId = me.data.id; // Mute the user const result = await client.v2.mute(myUserId, targetUserId!); return createResponse(`Successfully muted user ${username || targetUserId}. Response: ${JSON.stringify(result, null, 2)}`); } catch (error) { if (error instanceof Error) { throw new Error(formatTwitterError(error, 'muting user')); } throw error; } };
- src/tools.ts:674-689 (schema)The MCP tool schema definition for muteUser, including description and input schema validation.muteUser: { description: 'Mute a user account to stop seeing their tweets in your timeline', inputSchema: { type: 'object', properties: { userId: { type: 'string', description: 'The ID of the user to mute' }, username: { type: 'string', description: 'The username of the user to mute (alternative to userId)' } }, required: [] }
- src/index.ts:406-409 (registration)Registration and dispatch logic in the main CallToolRequest handler switch statement that invokes the muteUser handler.case 'muteUser': { const { userId, username } = request.params.arguments as { userId?: string; username?: string }; response = await handleMuteUser(client, { userId, username }); break;
- src/types/handlers.ts:131-134 (schema)TypeScript type definition for the MuteUserArgs used by the handler.export interface MuteUserArgs { userId?: string; username?: string; }