Skip to main content
Glama
friendship.ts2.26 kB
import { z } from 'zod'; import { InstagramClient } from '../instagram/client.js'; import { formatErrorForMcp } from '../utils/errors.js'; // Follow User export const followUserSchema = { username: z.string().describe('Instagram username to follow.'), }; export const followUserDescription = 'Send a follow request to an Instagram user. For public accounts, you will follow immediately. For private accounts, a follow request will be sent.'; export async function followUser( client: InstagramClient, params: { username: string } ): Promise<{ content: Array<{ type: 'text'; text: string }>; isError?: boolean }> { try { const result = await client.followUser(params.username); const message = result.status === 'requested' ? `Follow request sent to @${result.username} (private account)` : `Now following @${result.username}`; return { content: [ { type: 'text', text: JSON.stringify( { success: true, message, ...result, }, null, 2 ), }, ], }; } catch (error) { return { isError: true, content: [ { type: 'text', text: formatErrorForMcp(error), }, ], }; } } // Unfollow User export const unfollowUserSchema = { username: z.string().describe('Instagram username to unfollow.'), }; export const unfollowUserDescription = 'Unfollow an Instagram user.'; export async function unfollowUser( client: InstagramClient, params: { username: string } ): Promise<{ content: Array<{ type: 'text'; text: string }>; isError?: boolean }> { try { const result = await client.unfollowUser(params.username); return { content: [ { type: 'text', text: JSON.stringify( { success: true, message: `Unfollowed @${result.username}`, ...result, }, null, 2 ), }, ], }; } catch (error) { return { isError: true, content: [ { type: 'text', text: formatErrorForMcp(error), }, ], }; } }

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/arjun1194/insta-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server