Skip to main content
Glama
thichcode

Matomo MCP Server

by thichcode

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
NameRequiredDescriptionDefault
siteIdYesID của site

Implementation Reference

  • 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 : [];
    }
  • 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 });
  • 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)}`,
          },
        ],
      };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thichcode/matomo_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server