Skip to main content
Glama
umami-mcp

umami-mcp

by chukycheese

umami-mcp

셀프호스팅 Umami 분석 서버를 OpenCode를 비롯한 MCP 클라이언트에서 바로 쓸 수 있게 해 주는 MCP(Model Context Protocol) 서버입니다. 사이트 목록 조회·새 사이트 등록부터 방문자 통계, 시계열 페이지뷰, 유입 경로·기기·국가 순위, 커스텀 이벤트 집계까지 자연어로 물어볼 수 있습니다.

  • Python + FastMCP (mcp SDK 2.x의 MCPServer), httpx 기반의 가벼운 단일 패키지

  • stdio 트랜스포트 → uvx --from git+https://github.com/chukycheese/umami-mcp umami-mcp 한 줄로 실행

  • API 키(UMAMI_API_TOKEN) 또는 아이디/비밀번호 로그인(JWT 자동 캐싱·401 시 재로그인) 지원

  • Umami v3(예: 3.4.1) 기준으로 구현하고, v2 응답 형태도 자동 정규화

요구 사항

  • Python 3.10 이상

  • uv (권장) 또는 pip

  • git — uvx/pip가 GitHub 저장소에서 바로 빌드할 때 사용합니다

  • 접근 가능한 Umami 인스턴스 (셀프호스팅 v2/v3)

Related MCP server: umami-mcp-server

설치 및 실행

1. uvx로 GitHub에서 바로 실행 (권장)

UMAMI_URL=https://umami.example.com \
UMAMI_API_TOKEN=umami_xxxxxxxx \
uvx --from git+https://github.com/chukycheese/umami-mcp umami-mcp

표준입출력으로 MCP 프로토콜을 말하는 서버이므로, 터미널에서 직접 실행하면 입력을 기다립니다. 실제 사용은 아래처럼 OpenCode 같은 MCP 클라이언트에 연결합니다.

2. 로컬 클론에서 실행

git clone https://github.com/chukycheese/umami-mcp.git
cd umami-mcp
cp .env.example .env        # 값 채우기
uv sync
set -a && source .env && set +a
uv run umami-mcp

3. pip

pip install "git+https://github.com/chukycheese/umami-mcp"
umami-mcp

OpenCode 설정

opencode.json(또는 opencode.jsonc)에 MCP 서버를 추가합니다. 최신 OpenCode(v2)는 서버 이름을 mcp.servers 아래에 둡니다.

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "umami": {
        "type": "local",
        "command": [
          "uvx",
          "--from",
          "git+https://github.com/chukycheese/umami-mcp",
          "umami-mcp"
        ],
        "environment": {
          "UMAMI_URL": "https://umami-gray-mu.vercel.app",
          "UMAMI_TIMEZONE": "Asia/Seoul",
          "UMAMI_USERNAME": "{env:UMAMI_USERNAME}",
          "UMAMI_PASSWORD": "{env:UMAMI_PASSWORD}"
        }
      }
    }
  }
}

저장소의 opencode.json.example을 그대로 복사해 써도 됩니다.

  • {env:NAME}은 OpenCode가 환경변수로 치환합니다. 비밀번호를 파일에 직접 적지 말고 셸에서 export 하세요.

    export UMAMI_USERNAME=admin
    export UMAMI_PASSWORD='...'
  • API 키를 쓴다면 environment에 "UMAMI_API_TOKEN": "{env:UMAMI_API_TOKEN}"을 넣고 아이디/비밀번호 항목은 빼면 됩니다.

  • 구버전 OpenCode는 서버 이름을 mcp 바로 아래에 두는 형식("mcp": { "umami": { ... } })을 씁니다. 버전에 맞는 쪽을 쓰세요.

  • 추가 후 opencode mcp list로 연결 상태를 확인할 수 있습니다.

환경변수

변수

필수

설명

UMAMI_URL

✅

Umami 인스턴스 주소. 예: https://umami-gray-mu.vercel.app. 끝의 /는 자동 제거됩니다. 하위 경로 배포(https://host/umami)도 지원합니다.

UMAMI_API_TOKEN

⬜

API 키(umami_...) 또는 JWT. 있으면 로그인 없이 이 토큰을 사용합니다.

UMAMI_USERNAME

⬜

UMAMI_API_TOKEN이 없을 때 필요. /api/auth/login으로 JWT 발급.

UMAMI_PASSWORD

⬜

위와 함께 사용.

UMAMI_TIMEZONE

⬜

날짜 묶음·날짜-only 입력에 쓸 IANA 시간대. 예: Asia/Seoul. 기본값은 실행 환경의 로컬 시간대.

UMAMI_TIMEOUT

⬜

HTTP 타임아웃(초). 기본 30.

UMAMI_API_TOKEN이 없으면 UMAMI_USERNAME과 UMAMI_PASSWORD가 둘 다 있어야 하며, 없으면 툴 호출 시 설정 오류를 돌려줍니다.

인증 동작

  • API 키 (권장): Umami에서 프로필 → Settings → API keys → Create key로 발급합니다. 키는 한 번만 보이니 안전한 곳에 보관하세요. 만료가 없고 개별 폐기가 가능합니다.

  • 아이디/비밀번호: 첫 요청 때 JWT를 받아 캐시하고, 요청이 401을 돌려주면 한 번 자동 재로그인 후 재시도합니다.

  • 2단계 인증(2FA) 계정은 아이디/비밀번호 로그인으로 토큰을 받을 수 없습니다. 이 경우 API 키를 발급해 UMAMI_API_TOKEN으로 사용하세요.

제공 툴

툴

설명

반환

list_websites()

추적 중인 사이트 목록

[{id, name, domain, shareId, createdAt}]

create_website(name, domain)

새 사이트 등록

{websiteId, name, domain, shareId, shareUrl, script} — 바로 붙여넣을 수 있는 <script> 스니펫 포함

get_active_visitors(website_id)

현재 접속자 수

정수

get_stats(website_id, start_at=None, end_at=None, days=7)

방문자·페이지뷰·세션·이탈·체류시간

{visitors, pageviews, visits, bounces, totaltime, comparison}

get_pageviews(website_id, start_at=None, end_at=None, days=7, unit="day")

페이지뷰/세션 시계열

{unit, pageviews: [{x, y}], sessions: [{x, y}]}

get_metrics(website_id, metric_type="url", start_at=None, end_at=None, days=7, limit=20)

한 차원의 상위 값 순위

[{x: 값, y: 횟수}]

get_events(website_id, start_at=None, end_at=None, days=7)

커스텀 이벤트 이름별 집계

{totalEvents, events: [{name, count}], series: [{event, t, count}]}

날짜 범위 규칙

  • start_at / end_at은 ISO 날짜·날짜시간(2026-11-01, 2026-11-01T09:00:00+09:00) 또는 에폭 밀리초(1735689600000)를 받습니다.

  • start_at을 생략하면 end_at(없으면 현재)에서 days일 전부터 조회합니다.

  • end_at에 날짜만 주면 그날 하루 전체를 포함합니다.

  • get_pageviews의 unit은 minute, hour, day, month, year 중 하나입니다.

  • 일 단위 버킷은 Umami 서버가 timezone 기준으로 묶습니다. UMAMI_TIMEZONE을 비우면 UTC로 묶여 한국 시간 기준 하루가 09:00에 끊기니, Asia/Seoul처럼 지정해 두세요.

get_metrics 차원

url(기본, 최신 Umami에서는 자동으로 path로 변환), entry, exit, title, referrer, domain, channel, event, tag, browser, os, device, screen, language, country, region, city, utmSource, utmMedium, utmCampaign.

Umami v2는 path 차원을 모르기 때문에, 서버가 400을 받으면 원래 값(url)으로 한 번 더 시도합니다.

사용 예시

OpenCode 채팅에서 이렇게 물으면 됩니다.

  • "Umami에 등록된 사이트 뭐가 있어?"

  • "kult-archive 사이트 최근 7일 방문자랑 페이지뷰 알려줘."

  • "지난달 국가별 방문자 top 10 보여줘."

  • "최근 24시간 시간대별 페이지뷰 그래프로 볼 수 있게 데이터 줘."

  • "새 사이트 play-lounge, 도메인 play.example.com으로 Umami에 등록하고 추적 스크립트 줘."

create_website가 돌려주는 예:

{
  "websiteId": "0b7c9b4e-1f5e-4c43-a1f1-5a2f5f9d4a11",
  "name": "play-lounge",
  "domain": "play.example.com",
  "shareId": "sh4re",
  "shareUrl": "https://umami-gray-mu.vercel.app/share/sh4re",
  "script": "<script defer src=\"https://umami-gray-mu.vercel.app/script.js\" data-website-id=\"0b7c9b4e-1f5e-4c43-a1f1-5a2f5f9d4a11\"></script>"
}

API 호환성

Umami v2와 v3의 REST API는 대부분 같지만 응답 모양이 일부 다릅니다. 이 서버는 다음을 자동 처리합니다.

  • GET /api/websites: v3의 {data: [...]} 페이지 객체와 v2의 배열을 모두 처리하고, 사이트가 많으면 v3의 페이지네이션을 끝까지 따라갑니다.

  • GET /api/websites/{id}/stats: v2의 {visitors: {value, prev}} 중첩 형태와 v3의 평면 값 + comparison을 동일한 형태로 정규화

  • GET /api/websites/{id}/metrics: v3의 path 차원을 기본값으로 쓰고, v2에서 실패하면 url로 재시도

  • GET /api/websites/{id}/events: v3는 /events/series(집계 시계열), v2는 /events(집계 시계열)를 사용

날짜 범위는 두 버전 모두에서 동작하는 startAt/endAt(에폭 밀리초)로 보냅니다.

개발

uv sync
uv run pytest          # 단위 테스트 + stdio 스모크 테스트
uv build               # wheel/sdist 빌드

구조:

src/umami_mcp/
  client.py    # Umami REST 클라이언트, 인증·날짜 범위·응답 정규화
  server.py    # FastMCP 툴 정의와 main() 엔트리포인트
tests/
  test_client.py  # httpx.MockTransport 기반 단위 테스트
  test_server.py  # stdio로 기동해 tools/list 응답 확인

테스트는 실제 네트워크를 쓰지 않습니다. 실제 인스턴스에 붙여 보려면 .env를 채운 뒤 uv run umami-mcp를 MCP 클라이언트에 연결하세요.

보안

  • .env, API 키, 비밀번호를 커밋하지 마세요. .gitignore에 .env가 포함되어 있습니다.

  • 이 서버는 Umami 계정의 읽기/사이트 생성 권한을 그대로 사용합니다. 키는 Umami에서 언제든 폐기할 수 있습니다.

  • MCP 클라이언트 설정 파일에 비밀번호를 직접 적기보다 {env:...} 치환을 쓰세요.

라이선스

MIT © 2026 chukycheese

Available Tools

7 tools
create_websiteA

Register a new website in Umami and return its tracking snippet.

Args: name: Display name for the site, for example "kult-archive". domain: Bare domain without a scheme or path, for example "kult-archive.pages.dev" or "example.com".

Returns the new websiteId, a shareId/shareUrl when Umami created one, and a ready-to-paste script tag pointing at this Umami instance.

Inputs: name (required), domain (required). Returns: object

get_active_visitorsC

Return the number of visitors active on the website right now.

Inputs: website_id (required). Returns: result

get_eventsA

Return custom events aggregated by name for a date range.

Args: website_id: Website id from list_websites. start_at: Range start (ISO date/datetime or epoch milliseconds). end_at: Range end; defaults to now. days: Length of the default range when start_at is omitted.

Returns totalEvents, events ([{"name": ..., "count": ...}], most frequent first) and the per-bucket series.

Inputs: website_id (required), days, end_at, start_at. Returns: object

get_metricsA

Return the top values of one dimension, ranked by count.

Args: website_id: Website id from list_websites. metric_type: Dimension to rank: url (default; "path" on newer Umami), entry, exit, title, referrer, domain, channel, event, tag, browser, os, device, screen, language, country, region, city, utmSource, utmMedium, utmCampaign. start_at: Range start (ISO date/datetime or epoch milliseconds). end_at: Range end; defaults to now. days: Length of the default range when start_at is omitted. limit: Maximum number of rows.

Returns rows of {"x": value, "y": count} ordered by count, descending.

Inputs: website_id (required), days, limit, end_at, +2 more. Returns: result

get_pageviewsA

Return pageviews and sessions as a time series.

Args: website_id: Website id from list_websites. start_at: Range start (ISO date/datetime or epoch milliseconds). end_at: Range end; defaults to now. days: Length of the default range when start_at is omitted. unit: Bucket size: minute, hour, day, month or year.

Returns {"unit": ..., "pageviews": [{"x": bucket, "y": count}, ...], "sessions": [...]}.

Inputs: website_id (required), days, unit, end_at, +1 more. Returns: object

get_statsA

Return summary totals for a date range.

Args: website_id: Website id from list_websites. start_at: Range start as an ISO date/datetime or epoch milliseconds. Defaults to days before end_at. end_at: Range end; defaults to now. A bare date includes that whole day. days: Length of the default range when start_at is omitted.

Returns visitors, pageviews, visits, bounces, totaltime (seconds) and the same figures for the comparison period.

Inputs: website_id (required), days, end_at, start_at. Returns: object

list_websitesA

List the websites tracked by this Umami instance.

Returns each website's id, name, domain, shareId and creation date. Use the id as website_id in the other tools.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool targets a distinct data shape: list/create manage sites, and the analytics tools split cleanly into realtime (get_active_visitors), totals (get_stats), time series (get_pageviews), ranked dimensions (get_metrics) and custom events (get_events). The only mild overlap is get_stats vs get_pageviews, both returning visitor/pageview figures over a range, but totals-versus-series makes the boundary clear enough.

    Naming Consistency5/5

    All seven tools follow a strict verb_noun snake_case pattern: list_websites, create_website, and a get_* family for the analytics endpoints. No camelCase or mixed conventions, and the get_ prefix is applied uniformly.

    Tool Count5/5

    Seven tools is well within the ideal 3-15 range, and each earns its place: site management, realtime, totals, series, dimension breakdowns, and events cover the analytics surface without redundancy.

    Completeness3/5

    Read-side analytics coverage is solid, but the website lifecycle is half-finished: list and create exist with no update_website or delete_website, so an agent cannot rename or clean up sites. Session-level or individual-record retrieval is also absent, leaving dead ends beyond the aggregate views.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with Umami Analytics for both Cloud and self-hosted instances. It provides tools to retrieve website statistics, visitor metrics, pageview trends, and real-time active user counts.
      5
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Umami Analytics that provides read-only tools to query website stats, events, sessions, reports, and more, enabling natural language analytics queries.
      15 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes Umami analytics (Cloud or self-hosted) as read-only tools for querying website stats, pageviews, metrics, and active visitors.
      2,739 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables natural-language analytics against Umami, including traffic stats, time series, sessions, custom events, and filtered breakdowns, plus self-hosted admin CRUD for websites, users, and teams, and client onboarding.
      48
      1
      MIT