plausible-mcp

plausible-mcp

Enables teams to query Plausible Analytics from Claude using Google sign-in, with org-wide access managed through allowlisted domains or emails and no per-person API keys.

Category
访问服务器

README

plausible-mcp

An MCP server that lets everyone in an organisation query Plausible Analytics from Claude.

One deployment serves the whole org. It holds a single Plausible API key server-side and authenticates each person with Google, so nobody needs their own key and nobody has to be granted access individually: put your Google Workspace domain in ALLOWED_DOMAINS and anyone with an address there can connect the first time they try. Colleagues outside that domain go in ALLOWED_EMAILS, one address at a time.

If you run analytics for a team and want them reading the numbers themselves rather than asking you for them, that is what this is for.

How authentication works

Claude registers itself with this server using OAuth 2.1 dynamic client registration. Google does not support dynamic client registration, so this server acts as its own authorization server and delegates the human login upstream to Google.

Google establishes who the person is. It does not decide whether they may read your analytics. A middleware checks each caller's verified email address against ALLOWED_DOMAINS and ALLOWED_EMAILS on every tool call. If you set neither, the server refuses to start.

ALLOWED_DOMAINS is the part that makes this org-wide: it matches the domain of the verified address exactly, so example.com admits alice@example.com but not alice@evil-example.com or alice@example.com.evil.com.

To revoke someone, take them out of ALLOWED_EMAILS or ALLOWED_DOMAINS and redeploy. Suspending their Google account stops them signing in again, but the allowlist reads the claims from a token this server signed, so one already issued keeps working until it expires. Rotating JWT_SIGNING_KEY invalidates every token at once, at the cost of signing everybody out.

Tools

  • query runs a Stats API v2 query. Grouping by different dimensions gives you timeseries, breakdowns and goal conversions from the same tool. To compare two periods, call it once per period.
  • list_sites returns the site domains you can pass as site_id.
  • usage_stats reports who has used the server, how often, and which accounts were refused.

Usage tracking

The allowlist middleware sees every caller's email address, because it has to check it. It records a per-person call count, a first-seen and last-seen time, and a per-tool breakdown to the volume at USAGE_PATH. Refused accounts are counted separately, which is how you spot someone outside the allowlist trying to connect.

Read it with the usage_stats tool. Anyone on the allowlist can see everyone's rows. Unset USAGE_PATH to turn tracking off.

Configuration

Variable Required Purpose
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET yes Google OAuth client used to sign people in
PLAUSIBLE_API_KEY yes Plausible key with Stats API access; shared by everyone
BASE_URL yes Public URL of this server; the Google redirect URI is BASE_URL + /auth/callback
ALLOWED_DOMAINS / ALLOWED_EMAILS one of them Who may query. Neither set means the server refuses to start
JWT_SIGNING_KEY recommended Signs this server's access tokens. Without it a restart signs everyone out
CLIENT_STORAGE_PATH no Where to persist OAuth client registrations. Unset means in-memory
USAGE_PATH no Where to record per-person usage. Unset turns tracking off

See .env.example for the same list in copy-pasteable form.

Deploy

The repo ships a fly.toml, so the instructions below are for Fly.io, but nothing in the server is Fly-specific: it is one container that wants a writable directory and the environment above. Replace YOUR-APP throughout.

  1. Create an OAuth client in the Google Cloud console. Choose Web application and set the authorized redirect URI to https://YOUR-APP.fly.dev/auth/callback. The URI must match exactly.

  2. Create the app and its volume:

    fly apps create YOUR-APP --org YOUR-ORG
    fly volumes create plausible_mcp_data --app YOUR-APP --region fra --size 1 --yes
    

    Use fly apps create rather than fly launch, which regenerates fly.toml and would discard the volume mount and health check.

  3. Point app in fly.toml at your app name.

  4. Set the configuration. BASE_URL and ALLOWED_DOMAINS go here rather than in fly.toml because they differ per deployment, and a placeholder committed to the repo would overwrite the real value on the next deploy:

    fly secrets set --app YOUR-APP \
      BASE_URL=https://YOUR-APP.fly.dev \
      ALLOWED_DOMAINS=your-domain.org \
      GOOGLE_CLIENT_ID=xxx.apps.googleusercontent.com \
      GOOGLE_CLIENT_SECRET=GOCSPX-xxx \
      PLAUSIBLE_API_KEY=xxx \
      JWT_SIGNING_KEY="$(openssl rand -hex 32)"
    

    Keep JWT_SIGNING_KEY stable: changing it signs everyone out.

  5. fly deploy --ha=false

    Without --ha=false Fly may start two machines. Each would get its own volume, so a sign-in that registers on one machine fails when the next request lands on the other.

Add it to Claude

To add it for a whole team, go to Settings > Connectors in claude.ai, choose Add custom connector, and enter https://YOUR-APP.fly.dev/mcp. Each person signs in with Google the first time they use it.

To add it to Claude Code:

claude mcp add --transport http plausible https://YOUR-APP.fly.dev/mcp

Run it locally

uv venv && uv pip install -r pyproject.toml
cp .env.example .env    # then fill it in
set -a && source .env && set +a
python server.py

Add http://localhost:8000/auth/callback to the Google client's redirect URIs to test the sign-in flow locally.

Run the tests with python test_server.py. To exercise the OAuth flow and the tools by hand, use npx @modelcontextprotocol/inspector.

Licence

MIT — see LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选