Skip to main content
Glama
crazyrabbitLTC

Twitter MCP Server

unfollowUser

Stop following a Twitter user by their username to manage your following list and control your feed content.

Instructions

Unfollow a user by their username

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
usernameYesThe username of the user to unfollow

Implementation Reference

  • Core handler function that executes the unfollowUser tool: resolves current user ID, looks up target user by username, calls Twitter API v2.unfollow, returns success/error response.
    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;
        }
    };
  • TypeScript interface defining input arguments for unfollowUser: requires 'username' string.
    export interface UnfollowUserArgs {
        username: string;
    }
  • MCP tool input schema definition: JSON schema object specifying required 'username' parameter for the unfollowUser tool.
    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)
    Tool dispatch registration in main MCP server: switch case that extracts arguments and calls the handleUnfollowUser function.
    case 'unfollowUser': {
        const { username } = request.params.arguments as { username: string };
        response = await handleUnfollowUser(client, { username });
        break;
  • Runtime argument validator: Type guard function that asserts and validates input conforms to UnfollowUserArgs interface.
    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');
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While 'unfollow' implies a mutation operation, the description doesn't specify whether this requires authentication, what permissions are needed, whether the action is reversible, what happens to existing relationships, or what the response looks like. For a mutation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that gets straight to the point with zero wasted words. It's appropriately sized for a simple single-parameter tool and front-loads the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after unfollowing, whether there are side effects, what the return value might be, or error conditions. Given the complexity of user relationship management and the lack of structured data, the description should provide more context about the operation's behavior and outcomes.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents the single 'username' parameter. The description adds no additional parameter information beyond what's in the schema. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('unfollow') and target resource ('a user by their username'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'unfollowUser' vs 'blockUser' or 'muteUser' - all could involve ceasing some form of user interaction, so the distinction isn't explicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance about when to use this tool versus alternatives like 'blockUser', 'muteUser', or 'removeUserFromList'. There's no mention of prerequisites (e.g., must be following the user first), consequences, or typical use cases for unfollowing versus other user management actions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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