listar-usuarios
Retrieve all registered users from the system for user management and administration tasks.
Instructions
Lista todos los usuarios registrados en el sistema
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/userListTool.ts:14-39 (handler)The main handler function for the 'listar-usuarios' tool, which fetches users using getUsers and formats them into a text response.export async function listUsersToolHandler() { // Obtener la lista de usuarios const users = await getUsers(); // Formateamos la lista de usuarios para mostrarla let usersList = users.map(user => `- ID: ${user.id}\n Nombre: ${user.nombre} ${user.apellido}\n DNI: ${user.dni}\n Creado: ${user.createdAt.toLocaleString()}` ).join('\n\n'); // Si no hay usuarios, mostrar un mensaje adecuado if (users.length === 0) { usersList = "No hay usuarios registrados en el sistema."; } else { usersList = `Se encontraron ${users.length} usuario(s):\n\n${usersList}`; } // Devolvemos el resultado formateado para MCP return { content: [ { type: "text" as const, text: usersList } ] }; }
- src/tools/userListTool.ts:8-8 (schema)Input schema for the 'listar-usuarios' tool, which requires no parameters.export const listUsersInputSchema = {};
- src/main.ts:43-50 (registration)Registration of the 'listar-usuarios' tool in the MCP server, linking the name, description, input schema, and handler.server.registerTool( "listar-usuarios", { description: "Lista todos los usuarios registrados en el sistema", inputSchema: listUsersInputSchema }, listUsersToolHandler );
- src/services/userService.ts:62-64 (helper)Helper function that retrieves all users from the in-memory database, called by the tool handler.export async function getUsers(): Promise<User[]> { return [...users]; }