Matomo MCP Server
Click on "Deploy 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 last week's visits for site ID 1"
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 Plugin
A complete Model Context Protocol (MCP) server implementation for Matomo that works out of the box with any AI model. No configuration files or NPM requirements needed on the client side - just copy and paste a URL with your API token.
Features
Complete MCP Server: Full implementation of MCP protocol with tools, prompts, and resources
Zero Configuration: Works immediately after plugin installation
HTTP-Based: No WebSocket or stdio transport required
Secure Authentication: Uses Matomo's built-in API token system
Extensible Architecture: Easy to add new tools and prompts
Production Ready: Built following Matomo plugin best practices
Quick Start
1. Install the Plugin
Copy this plugin directory to your Matomo
plugins/folderActivate the plugin in Matomo Admin � Plugins
2. Get Your API Token
Go to Matomo Admin � Personal � Security
Create or copy your API authentication token
3. Connect to AI Models
Claude Desktop Configuration
Add this to your Claude Desktop configuration:
{
"mcpServers": {
"matomo": {
"command": "node",
"args": ["/path/to/matomo/plugins/MCP/mcp-http-client.js", "https://your-matomo-domain.com/", "YOUR_API_TOKEN"]
}
}
}Direct HTTP API Access
You can also integrate directly via HTTP POST requests to:
https://your-matomo-domain.com/index.php?module=MCP&action=indexAvailable Tools
Analytics Data Tool (get_analytics_data)
Get comprehensive analytics data from Matomo.
Parameters:
idSite(integer): Site ID to get data forperiod(string): Time period (day, week, month, year)date(string): Date or date range (e.g., "2024-01-01" or "last7")metric(string): Metric to retrieve (visits, pageviews, visitors, bounces, conversions)
Example:
{
"method": "tools/call",
"params": {
"name": "get_analytics_data",
"arguments": {
"idSite": 1,
"period": "week",
"date": "last4",
"metric": "visits"
}
}
}Site Management Tool (manage_sites)
Manage Matomo sites - list, create, update, or delete.
Parameters:
action(string): Action to perform (list, create, update, delete, get)idSite(integer): Site ID (for get, update, delete)siteName(string): Site name (for create, update)urls(array): Site URLs (for create, update)timezone(string): Timezonecurrency(string): Currency code
Available Prompts
Analytics Reporting (generate_analytics_report)
Generate comprehensive analytics reports and insights.
Arguments:
report_type: Type of report (summary, performance, growth, technical)site_data: Analytics data for analysis
Available Resources
Sites Information (matomo://sites)
List of all sites in your Matomo instance with basic information.
Server Configuration (matomo://config)
Matomo server configuration and system information.
Authentication
The MCP server supports both OAuth 2.0 (recommended) and API Token authentication:
OAuth 2.0 (Recommended)
For production use and MCP client compatibility:
Register OAuth Client:
curl -X POST "https://your-matomo.com/index.php?module=MCP&action=register" \
-d '{"name": "My App", "redirect_uri": "http://localhost:8080/callback", "scopes": ["read"]}'Authorization Flow:
Direct users to authorization URL
Exchange authorization code for access token
Use access token in API calls
Use Access Token:
{
"method": "tools/list"
}With header: Authorization: Bearer YOUR_ACCESS_TOKEN
See OAuth Guide for complete implementation details.
API Token (Backward Compatibility)
For simple setups, use Matomo API tokens:
In request body:
{
"method": "tools/list",
"auth": {
"token": "YOUR_API_TOKEN"
}
}In Authorization header:
Authorization: Bearer YOUR_API_TOKENPermissions & Scopes
OAuth Scope | API Token Equivalent | Permissions |
| View access | Analytics data, reports |
| Admin access | Modify settings, goals |
| Super user | Full admin access |
Development
Adding New Tools
Create a new PHP class in
/tools/directoryImplement
getToolDefinition()andexecute($params)methodsThe tool will be automatically registered
Example tool structure:
<?php
namespace Piwik\Plugins\MCP\Tools;
class MyTool {
public function getToolDefinition() {
return [
'name' => 'my_tool',
'description' => 'Description of what the tool does',
'inputSchema' => [
'type' => 'object',
'properties' => [
'param1' => [
'type' => 'string',
'description' => 'Parameter description'
]
],
'required' => ['param1']
]
];
}
public function execute($params) {
// Tool implementation
return ['result' => 'success'];
}
}Adding New Prompts
Create a new PHP class in
/prompts/directoryImplement
getPromptDefinition()andexecute($args)methodsThe prompt will be automatically registered
API Endpoints
GET /index.php?module=MCP&action=capabilities- Get server capabilitiesPOST /index.php?module=MCP&action=index- Main MCP endpoint
Requirements
Matomo 5.0+
PHP 7.4+
Valid Matomo API token
License
GPL v3+ - Same as Matomo
Support
Related MCP Connectors
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
- ZapierOAuthcom.zapier
Hosted MCP server connecting AI assistants to 9,000+ apps and 40,000+ actions via Zapier.
Clamp Analytics MCP server: traffic, revenue, funnels, cohorts, errors, and search, for AI agents.