Skip to main content
Glama
thichcode

Matomo MCP Server

by thichcode

matomo_add_goal

Add a new goal to a Matomo Analytics site by specifying tracking criteria like URL patterns or event attributes to measure conversions and user actions.

Instructions

Thêm một goal mới cho site

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteIdYesID của site
nameYesTên của goal
descriptionYesMô tả của goal
matchAttributeYesThuộc tính khớp (url, title, event, etc.)
patternYesMẫu khớp
patternTypeYesLoại mẫu (exact, contains, regex, etc.)

Implementation Reference

  • Input schema definition for the matomo_add_goal tool, specifying parameters and validation.
    {
      name: 'matomo_add_goal',
      description: 'Thêm một goal mới cho site',
      inputSchema: {
        type: 'object',
        properties: {
          siteId: {
            type: 'number',
            description: 'ID của site',
          },
          name: {
            type: 'string',
            description: 'Tên của goal',
          },
          description: {
            type: 'string',
            description: 'Mô tả của goal',
          },
          matchAttribute: {
            type: 'string',
            description: 'Thuộc tính khớp (url, title, event, etc.)',
          },
          pattern: {
            type: 'string',
            description: 'Mẫu khớp',
          },
          patternType: {
            type: 'string',
            description: 'Loại mẫu (exact, contains, regex, etc.)',
          },
        },
        required: ['siteId', 'name', 'description', 'matchAttribute', 'pattern', 'patternType'],
      },
    },
  • src/index.ts:274-282 (registration)
    Registration of the tool in the switch statement dispatching to the handler method.
    case 'matomo_add_goal':
      return await this.handleAddGoal(args as {
        siteId: number;
        name: string;
        description: string;
        matchAttribute: string;
        pattern: string;
        patternType: string;
      });
  • Tool handler function that checks Matomo connection, calls the service to add the goal, and returns success response.
    private async handleAddGoal(args: {
      siteId: number;
      name: string;
      description: string;
      matchAttribute: string;
      pattern: string;
      patternType: string;
    }) {
      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 goalId = await this.matomoService.addGoal(
        args.siteId,
        args.name,
        args.description,
        args.matchAttribute,
        args.pattern,
        args.patternType
      );
      return {
        content: [
          {
            type: 'text',
            text: `Đã thêm goal thành công với ID: ${goalId}`,
          },
        ],
      };
    }
  • Core helper method in MatomoApiService that performs the actual API request to Matomo's Goals.addGoal endpoint.
    async addGoal(siteId: number, name: string, description: string, matchAttribute: string, pattern: string, patternType: string): Promise<number> {
      const response = await this.makeRequest('Goals.addGoal', {
        idSite: siteId,
        name,
        description,
        matchAttribute,
        pattern,
        patternType,
      });
      return response.value;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It implies a write operation ('Thêm' means add), but doesn't disclose behavioral traits such as required permissions, whether the operation is idempotent, error handling, or what happens on success/failure. This is a significant gap for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Vietnamese that directly states the tool's purpose with zero waste. It's appropriately sized and front-loaded, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a write operation with 6 required parameters and no annotations or output schema, the description is incomplete. It lacks crucial context such as return values, error conditions, or behavioral details, leaving significant gaps for an AI agent to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description adds no additional meaning beyond what's in the schema (e.g., no examples, constraints, or context for parameters like matchAttribute or patternType). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Thêm một goal mới cho site' clearly states the action (add/Thêm) and resource (goal for a site) in Vietnamese, making the purpose understandable. It distinguishes from siblings like matomo_get_goals (read vs. write) but doesn't explicitly differentiate from other add tools like matomo_add_site or matomo_add_user beyond the resource type.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing site), exclusions, or comparisons to sibling tools like matomo_get_goals for retrieval or matomo_add_site for site creation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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