get_users
Retrieve user data from the mock database with optional role-based filtering for admin, user, or moderator roles.
Instructions
Get all users from the mock database
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_users"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| role | No | Filter users by role (admin, user, moderator) |
Implementation Reference
- src/domains/users.js:4-16 (handler)The static method getAll in UserService that executes the get_users tool logic: filters users by optional role and returns them.
static getAll(filters = {}) { let filteredUsers = users; if (filters.role) { filteredUsers = filteredUsers.filter(user => user.role === filters.role); } return { success: true, data: filteredUsers, total: filteredUsers.length }; } - src/domains/users.js:72-85 (schema)Input/output schema definition for the get_users tool.
{ name: 'get_users', description: 'Get all users from the mock database', inputSchema: { type: 'object', properties: { role: { type: 'string', description: 'Filter users by role (admin, user, moderator)', enum: ['admin', 'user', 'moderator'] } } } }, - mcp-server.js:38-46 (registration)Registration of available tools list, including the get_users schema via userToolSchemas.
this.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ ...userToolSchemas, ...taskToolSchemas, searchToolSchema ] }; }); - mcp-server.js:54-55 (registration)Dispatch/handling registration for the get_users tool call, invoking the handler.
case 'get_users': return createMcpResponse(UserService.getAll(args)); - src/domains/users.js:1-16 (helper)Import of mock users data used by the get_users handler.
import { users } from '../data/mockData.js'; export class UserService { static getAll(filters = {}) { let filteredUsers = users; if (filters.role) { filteredUsers = filteredUsers.filter(user => user.role === filters.role); } return { success: true, data: filteredUsers, total: filteredUsers.length }; }