matomo_connect
Connect to a Matomo Analytics instance using base URL and authentication token to access analytics data and manage sites, users, and reports through the MCP interface.
Instructions
Kết nối đến Matomo instance với URL và token xác thực
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baseUrl | Yes | URL của Matomo instance (ví dụ: https://analytics.example.com) | |
| tokenAuth | Yes | Token xác thực Matomo API |
Implementation Reference
- src/index.ts:309-328 (handler)The handler function for matomo_connect tool. It creates a MatomoConfig from input arguments, instantiates MatomoApiService, tests the connection by fetching sites, and returns a success message.private async handleConnect(args: { baseUrl: string; tokenAuth: string }) { const config: MatomoConfig = { baseUrl: args.baseUrl, tokenAuth: args.tokenAuth, }; this.matomoService = new MatomoApiService(config); // Test connection await this.matomoService.getSites(); return { content: [ { type: 'text', text: `Đã kết nối thành công đến Matomo tại ${args.baseUrl}`, }, ], }; }
- src/index.ts:42-55 (schema)Input schema definition for the matomo_connect tool, specifying the required baseUrl and tokenAuth parameters with descriptions.inputSchema: { type: 'object', properties: { baseUrl: { type: 'string', description: 'URL của Matomo instance (ví dụ: https://analytics.example.com)', }, tokenAuth: { type: 'string', description: 'Token xác thực Matomo API', }, }, required: ['baseUrl', 'tokenAuth'], },
- src/index.ts:39-56 (registration)Registration of the matomo_connect tool in the ListToolsRequestSchema handler, defining name, description, and input schema.{ name: 'matomo_connect', description: 'Kết nối đến Matomo instance với URL và token xác thực', inputSchema: { type: 'object', properties: { baseUrl: { type: 'string', description: 'URL của Matomo instance (ví dụ: https://analytics.example.com)', }, tokenAuth: { type: 'string', description: 'Token xác thực Matomo API', }, }, required: ['baseUrl', 'tokenAuth'], }, },
- src/types/matomo.ts:1-5 (schema)TypeScript interface MatomoConfig used in the matomo_connect handler for typing the connection configuration.export interface MatomoConfig { baseUrl: string; tokenAuth: string; siteId?: number; }
- src/services/matomo-api.ts:8-14 (helper)Constructor of MatomoApiService helper class, which sets up the axios HTTP client using the MatomoConfig provided by matomo_connect.constructor(config: MatomoConfig) { this.config = config; this.client = axios.create({ baseURL: config.baseUrl, timeout: 30000, }); }