matomo_get_users
Retrieve all user accounts from Matomo Analytics to manage access permissions and user administration.
Instructions
Lấy danh sách tất cả users trong Matomo
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/services/matomo-api.ts:68-71 (handler)Core handler function that retrieves the list of Matomo users by calling the 'UsersManager.getUsers' API endpoint via the private makeRequest method.async getUsers(): Promise<MatomoUser[]> { const response = await this.makeRequest('UsersManager.getUsers'); return Array.isArray(response) ? response : []; }
- src/index.ts:378-392 (handler)MCP server wrapper handler that validates the Matomo service connection and delegates to MatomoApiService.getUsers(), formatting the response as MCP content.private async handleGetUsers() { if (!this.matomoService) { throw new Error('Chưa kết nối đến Matomo. Vui lòng sử dụng matomo_connect trước.'); } const users = await this.matomoService.getUsers(); return { content: [ { type: 'text', text: `Danh sách users:\n${JSON.stringify(users, null, 2)}`, }, ], }; }
- src/index.ts:103-110 (schema)Tool registration schema defining the 'matomo_get_users' tool with empty input schema (no parameters required).{ name: 'matomo_get_users', description: 'Lấy danh sách tất cả users trong Matomo', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:265-267 (registration)Registration of the tool handler in the CallToolRequestSchema switch statement, dispatching to handleGetUsers().case 'matomo_get_users': return await this.handleGetUsers();
- src/services/matomo-api.ts:16-33 (helper)Helper method used by getUsers to make authenticated HTTP requests to the Matomo API.private async makeRequest(method: string, params: Record<string, any> = {}): Promise<any> { const requestParams = { module: 'API', format: 'JSON', token_auth: this.config.tokenAuth, ...params, }; try { const response = await this.client.get('', { params: requestParams }); return response.data; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Matomo API error: ${error.response?.data?.message || error.message}`); } throw error; } }