search_users
Find users by name, email, department, or position within the MCP JSON Database Server using a search query. Simplify user management and retrieval with targeted search functionality.
Instructions
Kullanıcıları ad, email, departman veya pozisyona göre arar
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Arama terimi |
Implementation Reference
- src/index.js:691-705 (handler)The handler for the 'search_users' tool. Extracts query from arguments, calls the searchUsers helper function on the database users, removes passwords from results for security, and returns the filtered users as JSON text.case 'search_users': { const { query } = args; const results = searchUsers(db.users, query); const resultsWithoutPasswords = results.map(user => { const { password, ...userWithoutPassword } = user; return userWithoutPassword; }); return { content: [{ type: 'text', text: JSON.stringify(resultsWithoutPasswords, null, 2) }] }; }
- src/index.js:244-254 (registration)Registration of the 'search_users' tool in the MCP server's tool list, including name, description, and input schema requiring a 'query' string.{ name: 'search_users', description: 'Kullanıcıları ad, email, departman veya pozisyona göre arar', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Arama terimi' } }, required: ['query'] } },
- src/database.js:46-54 (helper)Helper function implementing the core search logic: case-insensitive filtering of users array by name, email, department, or position matching the query.export function searchUsers(users, query) { const searchTerm = query.toLowerCase(); return users.filter(user => user.name.toLowerCase().includes(searchTerm) || user.email.toLowerCase().includes(searchTerm) || user.department.toLowerCase().includes(searchTerm) || user.position.toLowerCase().includes(searchTerm) ); }