matomo_get_users
Retrieve a complete list of users from Matomo Analytics using the Matomo MCP Server. Facilitates user management and access control for analytics reports.
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/index.ts:103-110 (registration)Registration of the 'matomo_get_users' tool in the ListToolsRequestSchema handler, including its name, description, and empty input schema.{ name: 'matomo_get_users', description: 'Lấy danh sách tất cả users trong Matomo', inputSchema: { type: 'object', properties: {}, }, },
- src/index.ts:378-392 (handler)The main handler function for the 'matomo_get_users' tool, which checks the connection and calls the MatomoApiService.getUsers method, then formats the response.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/services/matomo-api.ts:68-71 (handler)Core implementation of user retrieval in MatomoApiService by calling the Matomo API method 'UsersManager.getUsers' via the makeRequest helper.async getUsers(): Promise<MatomoUser[]> { const response = await this.makeRequest('UsersManager.getUsers'); return Array.isArray(response) ? response : []; }
- src/services/matomo-api.ts:16-33 (helper)Helper method used by getUsers to make authenticated API requests to Matomo.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; } }