search-users
Find Zulip users by partial name or email when exact details are unknown. Use to identify recipients before sending direct messages, returning matching results with basic information.
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
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Name, email, or partial match to search for users | |
| limit | No | Maximum number of results to return (default: 10) |
Implementation Reference
- src/server.ts:337-366 (handler)Handler function for the 'search-users' MCP tool. Fetches all users from Zulip via zulipClient.getUsers(), performs client-side filtering by partial match on full_name or email (case-insensitive), limits results to the specified number, handles no-results case, maps to simplified output format (name, email, id, active), and returns formatted JSON response or error.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'}`); } }
- src/server.ts:333-336 (schema)Zod input schema definition for the 'search-users' tool: required 'query' string for search term, optional 'limit' number 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-332 (registration)Registration of the 'search-users' tool on the MCP server, including tool name, description, and schema 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).",