Skip to main content
Glama
thichcode

Matomo MCP Server

by thichcode

matomo_get_top_pages

Retrieve the most visited pages from Matomo Analytics for a specific site and date range to identify popular content and user behavior patterns.

Instructions

Lấy danh sách trang được truy cập nhiều nhất

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteIdYesID của site
dateYesNgày cần lấy dữ liệu (YYYY-MM-DD)
periodNoChu kỳ (day, week, month, year)day
limitNoSố lượng kết quả tối đa

Implementation Reference

  • Core handler implementing the tool logic by calling Matomo API method Actions.getPageUrls to fetch top pages.
    async getTopPages(siteId: number, date: string, period: string = 'day', limit: number = 10): Promise<any> { return await this.makeRequest('Actions.getPageUrls', { idSite: siteId, date, period, filter_limit: limit, }); }
  • MCP server wrapper handler that checks connection and calls the MatomoApiService.getTopPages.
    private async handleGetTopPages(args: { siteId: number; date: string; period?: string; limit?: 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 pages = await this.matomoService.getTopPages(args.siteId, args.date, args.period, args.limit); return { content: [ { type: 'text', text: `Top pages:\n${JSON.stringify(pages, null, 2)}`, }, ], }; }
  • Input schema defining parameters for the matomo_get_top_pages tool.
    inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, date: { type: 'string', description: 'Ngày cần lấy dữ liệu (YYYY-MM-DD)', }, period: { type: 'string', description: 'Chu kỳ (day, week, month, year)', default: 'day', }, limit: { type: 'number', description: 'Số lượng kết quả tối đa', default: 10, }, }, required: ['siteId', 'date'], },
  • src/index.ts:208-235 (registration)
    Tool registration in the ListTools response, including name, description, and input schema.
    { name: 'matomo_get_top_pages', description: 'Lấy danh sách trang được truy cập nhiều nhất', inputSchema: { type: 'object', properties: { siteId: { type: 'number', description: 'ID của site', }, date: { type: 'string', description: 'Ngày cần lấy dữ liệu (YYYY-MM-DD)', }, period: { type: 'string', description: 'Chu kỳ (day, week, month, year)', default: 'day', }, limit: { type: 'number', description: 'Số lượng kết quả tối đa', default: 10, }, }, required: ['siteId', 'date'], }, },
  • src/index.ts:287-288 (registration)
    Switch case registration in CallToolRequest handler dispatching to the tool's handler function.
    case 'matomo_get_top_pages': return await this.handleGetTopPages(args as { siteId: number; date: string; period?: string; limit?: number });

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