matomo_get_goals
Retrieve goals list for a Matomo site to track and analyze conversion metrics using site ID.
Instructions
Lấy danh sách goals của một site
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| siteId | Yes | ID của site |
Implementation Reference
- src/services/matomo-api.ts:106-109 (handler)Core implementation of the matomo_get_goals tool. Makes API request to Matomo's Goals.getGoals endpoint for the given siteId and returns the goals array.async getGoals(siteId: number): Promise<MatomoGoal[]> { const response = await this.makeRequest('Goals.getGoals', { idSite: siteId }); return Array.isArray(response) ? response : []; }
- src/index.ts:140-149 (schema)Input schema definition for the matomo_get_goals tool, specifying siteId as required number parameter.inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, }, required: ['siteId'], },
- src/index.ts:137-150 (registration)Tool registration in ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'matomo_get_goals', description: 'Lấy danh sách goals của một site', inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, }, required: ['siteId'], }, },
- src/index.ts:271-272 (registration)Dispatch in CallToolRequestSchema switch statement to the handleGetGoals method.case 'matomo_get_goals': return await this.handleGetGoals(args as { siteId: number });
- src/index.ts:410-423 (handler)MCP server handler wrapper that checks connection, calls MatomoApiService.getGoals, and formats response.private async handleGetGoals(args: { siteId: number }) { 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 goals = await this.matomoService.getGoals(args.siteId); return { content: [ { type: 'text', text: `Danh sách goals:\n${JSON.stringify(goals, null, 2)}`, }, ], };