Skip to main content
Glama

search-users

Find users in Zulip workspaces by partial name or email. Returns matching results with basic details like name, email, and ID. Useful for locating users before direct messaging.

Instructions

🔍 DISCOVERY: Search for users by partial name or email when you don't know exact details. Use this first to explore and find users before sending direct messages. Returns multiple matching results with basic info (name, email, ID).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of results to return (default: 10)
queryYesName, email, or partial match to search for users

Implementation Reference

  • The core handler function for the 'search-users' tool. It fetches all users from Zulip, performs client-side filtering based on partial matches in name or email (case-insensitive), limits the results, and returns a formatted JSON response with matching users including name, email, ID, and active status.
    async ({ query, limit }) => { try { const usersResponse = await zulipClient.getUsers(); const lowerQuery = query.toLowerCase(); const filtered = usersResponse.members.filter((user: any) => user.full_name.toLowerCase().includes(lowerQuery) || user.email.toLowerCase().includes(lowerQuery) ).slice(0, limit); if (filtered.length === 0) { return createSuccessResponse(`No users found matching "${query}". Try a shorter search term or check spelling.`); } const results = filtered.map((user: any) => ({ name: user.full_name, email: user.email, id: user.id, active: user.is_active })); return createSuccessResponse(JSON.stringify({ query, found: filtered.length, users: results }, null, 2)); } catch (error) { return createErrorResponse(`Error searching users: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema for the 'search-users' tool using Zod validation. Defines 'query' as required string for search term and optional 'limit' defaulting to 10.
    { query: z.string().describe("Name, email, or partial match to search for users"), limit: z.number().default(10).describe("Maximum number of results to return (default: 10)") },
  • src/server.ts:330-367 (registration)
    Registration of the 'search-users' tool with MCP server, including name, description, input schema, and handler reference.
    server.tool( "search-users", "🔍 DISCOVERY: Search for users by partial name or email when you don't know exact details. Use this first to explore and find users before sending direct messages. Returns multiple matching results with basic info (name, email, ID).", { query: z.string().describe("Name, email, or partial match to search for users"), limit: z.number().default(10).describe("Maximum number of results to return (default: 10)") }, async ({ query, limit }) => { try { const usersResponse = await zulipClient.getUsers(); const lowerQuery = query.toLowerCase(); const filtered = usersResponse.members.filter((user: any) => user.full_name.toLowerCase().includes(lowerQuery) || user.email.toLowerCase().includes(lowerQuery) ).slice(0, limit); if (filtered.length === 0) { return createSuccessResponse(`No users found matching "${query}". Try a shorter search term or check spelling.`); } const results = filtered.map((user: any) => ({ name: user.full_name, email: user.email, id: user.id, active: user.is_active })); return createSuccessResponse(JSON.stringify({ query, found: filtered.length, users: results }, null, 2)); } catch (error) { return createErrorResponse(`Error searching users: ${error instanceof Error ? error.message : 'Unknown error'}`); } } );
  • ZulipClient.getUsers() helper method called by the search-users handler to fetch the complete list of users from the Zulip API endpoint '/users', which is then filtered client-side.
    async getUsers(params: { client_gravatar?: boolean; include_custom_profile_fields?: boolean; } = {}): Promise<{ members: ZulipUser[] }> { // Filter out undefined values const filteredParams = Object.fromEntries( Object.entries(params).filter(([, value]) => value !== undefined) ); const response = await this.client.get('/users', { params: filteredParams }); return response.data; }

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/avisekrath/zulip-mcp-server'

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