Matomo MCP Server
Provides tools for querying the Matomo Analytics HTTP Reporting API, enabling LLM agents to run reporting queries, fetch historical trend analysis, inspect report metadata, and retrieve dynamically generated graph images directly from a Matomo instance.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Matomo MCP Servershow me the number of visits for the last 7 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Matomo MCP Server
Matomo Direct MCP (Model Context Protocol) Server is a robust, lightweight TypeScript implementation that exposes the full power of the Matomo Analytics HTTP Reporting API directly to LLM agents.
Unlike intermediary solutions, this server connects directly to your Matomo instance, allowing clients (like Claude Desktop, Cursor, or custom MCP wrappers) to run reporting queries, fetch historical trend analysis, inspect report metadata, and retrieve dynamically generated graph imagesβall through beautifully typed, auto-documented MCP tools.
π Key Features
Direct Integration β No proxy databases or external authentication gateways; queries the Matomo HTTP API directly using your
token_auth.Full Reporting Coverage β Call any API method from any core or custom plugin.
Auto-Validated Inputs β Every tool payload is checked against strict
JSON-Schemaschemas via the MCP SDK and Zod.Image Generation Support β Directly outputs binary PNG charts (
ImageGraph.get) for visualization-capable LLM interfaces.Resilience & Reliability β Configurable request timeouts and robust HTTP retry logic with exponential back-off.
Flexible Environments β Fully supports command-line flags, environment variables, and Docker deployment.
Related MCP server: Matomo MCP Server
π οΈ Technology Stack
Language: TypeScript (ESNext Modules, Strict Mode)
Runtime: Node.js (Recommended
>= 22.0.0for native fetch)Server Framework: @modelcontextprotocol/sdk (v1.15.0)
Configuration & Validation: Zod (v3.23.8)
Development Tooling: tsx (watch mode/TS execution), typescript compiler (v5.6.x)
π Project Architecture
The Matomo Direct MCP Server operates as a STDIO transport process. It communicates via system standard input/output streams and is fully stateless.
βββββββββββββββββββ STDIO βββββββββββββββββββββββββββ
β β βββββββββββββββββββββββββββββΊ β β
β MCP Client β (List Tools, Call Tool) β Matomo Direct MCP Srv β
β (Claude/Cursor) β βββββββββββββββββββββββββββββΊ β (TypeScript Process) β
βββββββββββββββββββ βββββββββββββ¬ββββββββββββββ
β
HTTPS Fetch API
(token_auth, JSON)
β
βΌ
βββββββββββββββββββββββββββ
β Matomo Analytics β
β HTTP Reporting API β
βββββββββββββββββββββββββββWhen started, the server:
Parses & Validates Configuration: Parses CLI flags or environment variables to find the
MATOMO_HOSTandMATOMO_TOKEN_AUTH.Verifies Connectivity: Performs a non-blocking startup check against
API.getMatomoVersionto ensure the host is reachable.Exposes Typed Tools: Publishes structured JSON-schemas describing all report actions to the client.
Handles Requests: Receives tool invocations, dynamically builds requests (serializing parameters and authentication tokens), executes HTTP queries, detects content-types (JSON, XML, TSV, CSV, PNG), and formats clean, structured outputs back to the agent.
π¦ Project Structure
mcp-matomo/
βββ src/
β βββ index.ts # Standalone CLI entrypoint, configuration parsing, and startup
β βββ server.ts # Core MCP server definition, API client, and tool handlers
βββ dist/ # Compiled production JavaScript files (generated via tsc)
βββ package.json # Dependencies, compilation scripts, and metadata
βββ tsconfig.json # Strict TypeScript compiler options
βββ .gitignore # Comprehensive secrets & artifact ignore rules
βββ README.md # Documentation (this file)π₯ Getting Started
Prerequisites
Node.js
>= 22.0.0npm
>= 10.0.0A running Matomo Analytics instance with an API token (
token_auth).
Installation
Clone the repository to your local machine:
git clone https://github.com/alexgenovese/matomo-mcp.git cd matomo-mcpInstall development and runtime dependencies:
npm ci
βοΈ Configuration
The server can be configured seamlessly using either Command Line Arguments or Environment Variables. CLI flags take priority over environment variables.
CLI Argument | Environment Variable | Default | Description |
|
| Required | Base URL of your Matomo instance (e.g., |
|
| Required | Your Matomo secret API token ( |
|
|
| HTTP request timeout in milliseconds. |
|
|
| Maximum HTTP request retries. |
|
|
| Initial retry delay in ms. Multiplied exponentially on consecutive failures. |
|
|
| Default response format for reporting queries (e.g., |
π Running the Server
1. Local Development (with Hot Reloading)
Run the server directly from TypeScript source code using tsx:
npm run dev -- --matomo-host=https://your-matomo-url.com --matomo-token=your_token_auth2. Production Build & Execution
Compile the TypeScript project to production-ready ES modules, then execute using Node:
# Compile TS to JS in /dist
npm run build
# Run stand-alone server
node dist/index.js --matomo-host=https://your-matomo-url.com --matomo-token=your_token_auth3. Running with Docker
You can containerize and run the server inside a Docker environment:
# Build the Docker image
docker build -t matomo-mcp .
# Run the container
docker run -i --rm -e MATOMO_HOST="https://your-matomo-url.com" -e MATOMO_TOKEN_AUTH="your_token_auth" matomo-mcpπ οΈ MCP Tools Overview
The server exposes six highly focused, dynamically parameterized tools:
1. matomo_call
Generic, escape-hatch endpoint to run any Matomo HTTP API reporting method.
Required Arguments:
method(string): TheModule.actionsignature (e.g.,VisitsSummary.getorUsersManager.getUsers).
Optional Arguments:
params(object): Key-value pairs representing request arguments.format(enum): Output serialization format (json,xml,csv,tsv,html,rss,original,png).
2. matomo_list_report_metadata
Fetch the complete metadata suite of compatible reports for a site.
Required Arguments:
idSite(integer): ID of the Matomo website.
Optional Arguments:
period,date,language,showSubtableReports,hideMetricsDoc.
3. matomo_get_metadata
Query granular metadata schemas, documentation, and specific column dimensions of a single report action.
Required Arguments:
idSite(integer),apiModule(string),apiAction(string).
4. matomo_get_processed_report
Retrieve high-level processed metrics, calculations, and tables complete with arithmetic.
Required Arguments:
idSite(integer),apiModule(string),apiAction(string).
Optional Arguments:
segment(segment filter string),flat(boolean),expanded(boolean),filter_limit(integer).
5. matomo_get_row_evolution
Analyze historical trend lines for a specific report row label over time.
Required Arguments:
idSite(integer),apiModule(string),apiAction(string),label(string).
6. matomo_get_image_graph
Acquire raw PNG chart visualizations directly generated by Matomo's Graph Engine.
Required Arguments:
idSite(integer),apiModule(string),apiAction(string).
Optional Arguments:
graphType(evolution, horizontalBar, verticalBar, pie),width,height,columns.
π Integration Guides
Claude Desktop Integration
To register this server with your local Claude Desktop app, edit your configuration file (usually located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS, or %APPDATA%\Claude\claude_desktop_config.json on Windows) and add the following entry:
{
"mcpServers": {
"matomo-direct-mcp": {
"command": "node",
"args": [
"/Users/alexgenovese/Documents/GitHub/mcp/mcp-matomo/dist/index.js",
"--matomo-host=https://your-matomo-instance.com",
"--matomo-token=YOUR_MATOMO_TOKEN_AUTH"
]
}
}
}Note: Ensure you have compiled the server beforehand by running npm run build.
π» Development Workflow
Coding Standards
We enforce highly clean, structured, and modern development standards:
Strict Types: Explicit typings everywhere;
anyis restricted only to generic API parsing.Modular ES Imports: Node.js ES Modules are strictly enforced. Relative file imports must include the
.jsextension (e.g.import { Server } from "./server.js").Robust Error Handling: Network failures are monitored and retried using structured back-offs, while standard error objects are printed to standard error (
console.error) so as not to corrupt the STDIO transport on standard output.
Linting
Validate codebase health and alignment to guidelines:
npm run lintπ€ Contributing
Contributions are welcome! Please follow these simple steps to contribute:
Fork the repository and create your feature branch (
git checkout -b feature/amazing-feature).Verify changes build perfectly and conform to standard formatting guidelines.
Open a Pull Request detailing the purpose and scope of your modifications.
π License
This project is licensed under the MIT License - see the package.json file for licensing declarations.
This server cannot be installed
Maintenance
Latest Blog Posts
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/alexgenovese/matomo-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server