Skip to main content
Glama
ubie-oss

Slack MCP Server

by ubie-oss

slack_search_users

Find Slack users by searching across usernames, display names, and real names using partial keyword matches. Specify a limit and optionally include bot users in results.

Instructions

Search for users by partial name match across username, display name, and real name. Use this when you need to find users containing specific keywords in their names. Returns up to the specified limit of matching users.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch users by name, display name, or real name (partial match, case-insensitive)
limitNoMaximum number of users to return (default 20)
include_botsNoInclude bot users in results (default false)

Implementation Reference

  • Handler implementation for the slack_search_users tool. Parses input, fetches and paginates all users via Slack API, filters by query on multiple name fields (case-insensitive), optionally excludes bots, limits results, parses response with GetUsersResponseSchema, and returns JSON.
    case 'slack_search_users': { const args = SearchUsersRequestSchema.parse(request.params.arguments); // Fetch all users with a reasonable limit const allUsers: Array<{ id?: string; name?: string; real_name?: string; is_bot?: boolean; profile?: { display_name?: string; display_name_normalized?: string; [key: string]: unknown; }; [key: string]: unknown; }> = []; let cursor: string | undefined; const maxPages = 5; // Limit to prevent infinite loops let pageCount = 0; // Fetch multiple pages if needed while (pageCount < maxPages) { const response = await slackClient.users.list({ limit: 1000, // Max allowed by Slack API cursor, }); if (!response.ok) { throw new Error(`Failed to search users: ${response.error}`); } if (response.members) { allUsers.push(...(response.members as typeof allUsers)); } cursor = response.response_metadata?.next_cursor; pageCount++; // Stop if no more pages if (!cursor) break; } // Filter users (case-insensitive partial match across multiple fields) const searchTerm = args.query.toLowerCase(); const filteredUsers = allUsers.filter((user) => { // Skip bots if requested if (!args.include_bots && user.is_bot) { return false; } // Search across multiple name fields const name = user.name?.toLowerCase() || ''; const realName = user.real_name?.toLowerCase() || ''; const displayName = user.profile?.display_name?.toLowerCase() || ''; const displayNameNormalized = user.profile?.display_name_normalized?.toLowerCase() || ''; return ( name.includes(searchTerm) || realName.includes(searchTerm) || displayName.includes(searchTerm) || displayNameNormalized.includes(searchTerm) ); }); // Limit results const limitedUsers = filteredUsers.slice(0, args.limit); const response = { ok: true, members: limitedUsers, }; const parsed = GetUsersResponseSchema.parse(response); return { content: [{ type: 'text', text: JSON.stringify(parsed) }], }; }
  • Zod schema defining the input parameters for slack_search_users: query (string), limit (number, default 20), include_bots (boolean, default false). Used for validation in the handler and exposed in tool registration.
    export const SearchUsersRequestSchema = z.object({ query: z .string() .describe( 'Search users by name, display name, or real name (partial match, case-insensitive)' ), limit: z .number() .int() .min(1) .max(100) .optional() .default(20) .describe('Maximum number of users to return (default 20)'), include_bots: z .boolean() .optional() .default(false) .describe('Include bot users in results (default false)'), });
  • src/index.ts:170-175 (registration)
    Tool registration in the listTools handler, defining name, description, and inputSchema based on SearchUsersRequestSchema.
    { name: 'slack_search_users', description: 'Search for users by partial name match across username, display name, and real name. Use this when you need to find users containing specific keywords in their names. Returns up to the specified limit of matching users.', inputSchema: zodToJsonSchema(SearchUsersRequestSchema), },

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/ubie-oss/slack-mcp-server'

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