You can now connect Claude Code using either the Claude CLI command or by manually editing the Claude configuration file. The default Claude configuration file is located at: ~/.claude.json

Before integrating the MCP Server with Claude Code, review the Security considerations and Privacy and regulatory sections. The MCP allows external AI systems to access analytics data from your Matomo instance. You must ensure that appropriate authentication, data access controls, and privacy safeguards are in place before allowing an AI tool to query your analytics data.

Before you start

Ensure the Matomo MCP server is enabled. For Matomo On-Premise, install and activate the MCP plugin before use.

Claude CLI

If using the Claude CLI command, run the following command to add the Matomo MCP server. Replace $YOUR_API_TOKEN with the Matomo API token you generated.

claude mcp add --scope user --transport http analytics 'YOUR MCP URL' --header 'Authorization: Bearer $YOUR_API_TOKEN'

Claude configuration file

Alternatively, you can edit the configuration file manually.

Open ~/.claude.json and add the following configuration. Replace YOUR_MCP_URL with your Matomo MCP endpoint and $YOUR_API_TOKEN with your Matomo API token or the access token obtained using OAuth 2.0.

{
  "mcpServers": {
    "analytics": {
      "type": "http",
      "url": "YOUR_MCP_URL",
      "headers": {
        "Authorization": "Bearer $YOUR_API_TOKEN"
      }
    }
  }
}

Save the file after making the changes and restart the Claude CLI so the new MCP server configuration is loaded.

Previous FAQ: Integrate the MCP Server with ChatGPT